feat : custom menu options in the main dropdown menu (#2250)

Co-authored-by: lalrishav <lalrishav@gmail.com>
This commit is contained in:
Lal Rishav 2021-03-23 03:14:14 +05:30 committed by GitHub
parent fec39c682a
commit 2eb8a24147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 3 deletions

View File

@ -2,11 +2,12 @@ import React from 'react';
import Cookies from 'js-cookie';
import { Menu, Avatar, Dropdown } from 'antd';
import { Link } from 'react-router-dom';
import { useTheme } from 'styled-components';
import defaultAvatar from '../../images/default_avatar.png';
import { EntityType } from '../../types.generated';
import { useEntityRegistry } from '../useEntityRegistry';
import { isLoggedInVar } from '../auth/checkAuthStatus';
import { GlobalCfg } from '../../conf';
import { isLoggedInVar } from '../auth/checkAuthStatus';
interface Props {
urn: string;
@ -19,14 +20,24 @@ const defaultProps = {
export const ManageAccount = ({ urn: _urn, pictureLink: _pictureLink }: Props) => {
const entityRegistry = useEntityRegistry();
const themeConfig = useTheme();
const handleLogout = () => {
isLoggedInVar(false);
Cookies.remove(GlobalCfg.CLIENT_AUTH_COOKIE);
};
const menu = (
<Menu>
{themeConfig.content.menu.items.map((value) => {
return (
<Menu.Item key={value.label}>
<a href={value.path || ''} target={value.shouldOpenInNewTab ? '_blank' : ''} rel="noreferrer">
<div tabIndex={0} role="button">
{value.label}
</div>
</a>
</Menu.Item>
);
})}
<Menu.Item danger>
<div tabIndex={0} role="button" onClick={handleLogout} onKeyDown={handleLogout}>
Log out

View File

@ -27,6 +27,15 @@
},
"search": {
"searchbarMessage": "Search Datasets, People, & more..."
},
"menu": {
"items": [
{
"label": "Datahub Wiki",
"path": "https://github.com/linkedin/datahub",
"shouldOpenInNewTab": true
}
]
}
}
}

View File

@ -29,6 +29,15 @@
},
"search": {
"searchbarMessage": "Search Datasets, People, & more..."
},
"menu": {
"items": [
{
"label": "Datahub Wiki",
"path": "https://github.com/linkedin/datahub",
"shouldOpenInNewTab": true
}
]
}
}
}

View File

@ -30,5 +30,12 @@ export type Theme = {
search: {
searchbarMessage: string;
};
menu: {
items: {
label: string;
path: string;
shouldOpenInNewTab: boolean;
}[];
};
};
};