Skip to content

Commit

Permalink
[frontend] Fix feature flag behaviour on left menu for dashboards (#6509
Browse files Browse the repository at this point in the history
)
  • Loading branch information
SamuelHassine committed Aug 20, 2024
1 parent 5061a4f commit 863d3d1
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -794,38 +794,58 @@ const LeftBar = () => {
<Divider />
<MenuList component="nav">
<Security needs={[EXPLORE]}>
<StyledTooltip title={!navOpen && t_i18n('Dashboards')} placement="right">
<MenuItem
ref={anchors.dashboards}
selected={!navOpen && location.pathname.includes('/dashboard/workspaces/dashboards')}
dense={true}
classes={{ root: classes.menuItem }}
onClick={() => (isMobile || navOpen ? handleSelectedMenuToggle('dashboards') : handleGoToPage('/dashboard/dashboards'))}
onMouseEnter={() => !navOpen && handleSelectedMenuOpen('dashboards')}
onMouseLeave={() => !navOpen && handleSelectedMenuClose()}
>
<ListItemIcon classes={{ root: classes.menuItemIcon }} style={{ minWidth: 20 }}>
<InsertChartOutlinedOutlined />
</ListItemIcon>
{navOpen && (
{isFeatureEnable('PUBLIC_DASHBOARD_LIST') ? (
<>
<MenuItem
ref={anchors.dashboards}
selected={!navOpen && location.pathname.includes('/dashboard/workspaces/dashboards')}
dense={true}
classes={{ root: classes.menuItem }}
onClick={() => (isMobile || navOpen ? handleSelectedMenuToggle('dashboards') : handleGoToPage('/dashboard/workspaces/dashboards'))}
onMouseEnter={() => !navOpen && handleSelectedMenuOpen('dashboards')}
onMouseLeave={() => !navOpen && handleSelectedMenuClose()}
>
<ListItemIcon classes={{ root: classes.menuItemIcon }} style={{ minWidth: 20 }}>
<InsertChartOutlinedOutlined />
</ListItemIcon>
{navOpen && (
<ListItemText
classes={{ primary: classes.menuItemText }}
primary={t_i18n('Dashboards')}
/>
)}
{navOpen && (selectedMenu.includes('dashboards') ? <ExpandLessOutlined/> : <ExpandMoreOutlined/>)}
</MenuItem>
{generateSubMenu(
'dashboards',
[
{ granted: isGrantedToExplore, type: 'Dashboard', link: '/dashboard/workspaces/dashboards', label: 'Custom dashboards', exact: true },
{ granted: isGrantedToExplore, type: 'Dashboard', link: '/dashboard/workspaces/dashboards_public', label: 'Public dashboards', exact: true },
],
)}
</>
) : (
<StyledTooltip title={!navOpen && t_i18n('Dashboards')} placement="right">
<MenuItem
component={Link}
to="/dashboard/workspaces/dashboards"
selected={!navOpen && location.pathname.includes('/dashboard/workspaces/dashboards')}
dense={true}
classes={{ root: classes.menuItem }}
>
<ListItemIcon classes={{ root: classes.menuItemIcon }} style={{ minWidth: 20 }}>
<InsertChartOutlinedOutlined />
</ListItemIcon>
{navOpen && (
<ListItemText
classes={{ primary: classes.menuItemText }}
primary={t_i18n('Dashboards')}
/>
)}
{navOpen && (selectedMenu.includes('dashboards') ? <ExpandLessOutlined/> : <ExpandMoreOutlined/>)}
</MenuItem>
</StyledTooltip>
)}
</MenuItem>
</StyledTooltip>
)}
</Security>
{generateSubMenu(
'dashboards',
isFeatureEnable('PUBLIC_DASHBOARD_LIST') ? [
{ granted: isGrantedToExplore, type: 'Dashboard', link: '/dashboard/workspaces/dashboards', label: 'Custom dashboards' },
{ granted: isGrantedToExplore, type: 'Dashboard', link: '/dashboard/workspaces/public_dashboards', label: 'Public dashboards' },
] : [
{ granted: isGrantedToExplore, type: 'Dashboard', link: '/dashboard/workspaces/dashboards', label: 'Custom dashboards' },
],
)}
<Security needs={[INVESTIGATION]}>
<StyledTooltip title={!navOpen && t_i18n('Investigations')} placement="right">
<MenuItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Root = () => (
}
/>
<Route
path="/public_dashboards/*"
path="/dashboards_public/*"
element={
<Security needs={[EXPLORE]} placeholder={<Navigate to="/dashboard"/>}>
<PublicDashboard/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const WorkspacePopover = ({ workspace, paginationOptions }) => {
operator: 'eq',
}],
};
navigate(`/dashboard/workspaces/public_dashboards?filters=${JSON.stringify(filter)}`);
navigate(`/dashboard/workspaces/dashboards_public?filters=${JSON.stringify(filter)}`);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ const DashboardComponent = ({ workspace, noToolbar }) => {
id="container"
style={{
paddingBottom: noToolbar ? 0 : 50,
marginTop: noToolbar ? -20 : 0,
marginTop: noToolbar ? -20 : 10,
}}
>
{!noToolbar && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const styles = () => ({
container: {
width: '100%',
height: '100%',
margin: 0,
margin: '10px 0 0 0',
padding: 0,
},
});
Expand Down
482 changes: 241 additions & 241 deletions opencti-platform/opencti-graphql/src/generated/graphql.ts

Large diffs are not rendered by default.

0 comments on commit 863d3d1

Please sign in to comment.