-
-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> ## About the changes Update menu for Pro customers - show enterprise options with plan upgrade suggestion page. ![image](https://github.com/Unleash/unleash/assets/2625371/0b670b48-a2fc-4973-89ce-5d0b0c36b81a)
- Loading branch information
Showing
10 changed files
with
376 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { useLocation } from 'react-router-dom'; | ||
import { Box, Paper, styled, Tab, Tabs } from '@mui/material'; | ||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; | ||
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus'; | ||
import { CenteredNavLink } from './CenteredNavLink'; | ||
import { VFC } from 'react'; | ||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; | ||
import { EnterpriseBadge } from 'component/common/EnterpriseBadge/EnterpriseBadge'; | ||
|
||
const StyledPaper = styled(Paper)(({ theme }) => ({ | ||
marginBottom: '1rem', | ||
borderRadius: `${theme.shape.borderRadiusLarge}px`, | ||
boxShadow: 'none', | ||
padding: theme.spacing(0, 2), | ||
})); | ||
|
||
const StyledBadgeContainer = styled('div')(({ theme }) => ({ | ||
marginLeft: theme.spacing(1), | ||
display: 'flex', | ||
alignItems: 'center', | ||
})); | ||
|
||
export const AdminTabsMenu: VFC = () => { | ||
const { uiConfig, isEnterprise, isPro } = useUiConfig(); | ||
const { pathname } = useLocation(); | ||
const { isBilling } = useInstanceStatus(); | ||
const { flags, networkViewEnabled } = uiConfig; | ||
|
||
const activeTab = pathname.split('/')[2]; | ||
|
||
const showEnterpriseFeaturesInPro = | ||
uiConfig?.flags?.frontendNavigationUpdate; | ||
|
||
const tabs = [ | ||
{ | ||
value: 'users', | ||
label: 'Users', | ||
link: '/admin/users', | ||
}, | ||
{ | ||
value: 'service-accounts', | ||
label: 'Service accounts', | ||
link: '/admin/service-accounts', | ||
condition: | ||
isEnterprise() || (isPro() && showEnterpriseFeaturesInPro), | ||
showEnterpriseBadge: true, | ||
}, | ||
{ | ||
value: 'groups', | ||
label: 'Groups', | ||
link: '/admin/groups', | ||
condition: flags.UG, | ||
}, | ||
{ | ||
value: 'roles', | ||
label: 'Roles', | ||
link: '/admin/roles', | ||
condition: | ||
isEnterprise() || (isPro() && showEnterpriseFeaturesInPro), | ||
showEnterpriseBadge: true, | ||
}, | ||
{ | ||
value: 'api', | ||
label: 'API access', | ||
link: '/admin/api', | ||
}, | ||
{ | ||
value: 'cors', | ||
label: 'CORS origins', | ||
link: '/admin/cors', | ||
condition: uiConfig.flags.embedProxyFrontend, | ||
}, | ||
{ | ||
value: 'auth', | ||
label: 'Single sign-on', | ||
link: '/admin/auth', | ||
}, | ||
{ | ||
value: 'instance', | ||
label: 'Instance stats', | ||
link: '/admin/instance', | ||
}, | ||
{ | ||
value: 'network', | ||
label: 'Network', | ||
link: '/admin/network', | ||
condition: networkViewEnabled, | ||
}, | ||
{ | ||
value: 'maintenance', | ||
label: 'Maintenance', | ||
link: '/admin/maintenance', | ||
}, | ||
{ | ||
value: 'instance-privacy', | ||
label: 'Instance privacy', | ||
link: '/admin/instance-privacy', | ||
}, | ||
{ | ||
value: 'billing', | ||
label: 'Billing', | ||
link: '/admin/billing', | ||
condition: isBilling, | ||
}, | ||
]; | ||
|
||
return ( | ||
<StyledPaper> | ||
<Tabs | ||
value={activeTab} | ||
variant="scrollable" | ||
scrollButtons="auto" | ||
allowScrollButtonsMobile | ||
> | ||
{tabs | ||
.filter(tab => tab.condition || tab.condition === undefined) | ||
.map(tab => ( | ||
<Tab | ||
key={tab.value} | ||
value={tab.value} | ||
label={ | ||
<CenteredNavLink to={tab.link}> | ||
{tab.label} | ||
<ConditionallyRender | ||
condition={Boolean( | ||
tab.showEnterpriseBadge | ||
)} | ||
show={ | ||
<StyledBadgeContainer> | ||
<EnterpriseBadge size={16} /> | ||
</StyledBadgeContainer> | ||
} | ||
/> | ||
</CenteredNavLink> | ||
} | ||
/> | ||
))} | ||
</Tabs> | ||
</StyledPaper> | ||
); | ||
}; |
Oops, something went wrong.