import React from 'react'; import cn from 'classnames'; import { Icon } from 'UI'; import { CLIENT_TABS, client as clientRoute } from 'App/routes'; import { withRouter, RouteComponentProps } from 'react-router'; interface Props { history: any; className: string; account: any; } function SettingsMenu(props: RouteComponentProps) { const { history, account, className }: any = props; const isAdmin = account.admin || account.superAdmin; const isEnterprise = account.edition === 'ee'; const navigateTo = (path: any) => { switch (path) { case 'sessions-listing': return history.push(clientRoute(CLIENT_TABS.SESSIONS_LISTING)); case 'projects': return history.push(clientRoute(CLIENT_TABS.SITES)); case 'team': return history.push(clientRoute(CLIENT_TABS.MANAGE_USERS)); case 'metadata': return history.push(clientRoute(CLIENT_TABS.CUSTOM_FIELDS)); case 'webhooks': return history.push(clientRoute(CLIENT_TABS.WEBHOOKS)); case 'integrations': return history.push(clientRoute(CLIENT_TABS.INTEGRATIONS)); case 'notifications': return history.push(clientRoute(CLIENT_TABS.NOTIFICATIONS)); case 'roles': return history.push(clientRoute(CLIENT_TABS.MANAGE_ROLES)); case 'audit': return history.push(clientRoute(CLIENT_TABS.AUDIT)); } }; return (
navigateTo('sessions-listing')} label='Sessions Listing' icon='folder2' /> navigateTo('integrations')} label='Integrations' icon='puzzle' /> navigateTo('metadata')} label='Metadata' icon='tags' /> navigateTo('webhooks')} label='Webhooks' icon='link-45deg' /> navigateTo('projects')} label='Projects' icon='folder2' /> {isAdmin && ( navigateTo('team')} label='Team' icon='users' /> )} {isEnterprise && isAdmin && ( <> navigateTo('roles')} label='Roles & Access' icon='diagram-3' /> navigateTo('audit')} label='Audit' icon='list-ul' /> )} navigateTo('notifications')} label='Notifications' icon='bell-slash' />
); } export default withRouter(SettingsMenu); function MenuItem({ onClick, label, icon }: any) { return (
); }