Skip to content

Commit

Permalink
[frontend] fix tab highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyCloarec committed May 29, 2024
1 parent ac5a363 commit a6492b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ const RootGrouping = () => {
const enableReferences = useIsEnforceReference('Grouping') && !useGranted([BYPASSREFERENCE]);
const { t_i18n } = useFormatter();
useSubscription(subConfig);

const getCurrentTab = (location, grouping) => {
if (location.pathname.includes(`/dashboard/analyses/groupings/${grouping.id}/knowledge`)) return `/dashboard/analyses/groupings/${grouping.id}/knowledge`;
if (location.pathname.includes(`/dashboard/analyses/groupings/${grouping.id}/content`)) return `/dashboard/analyses/groupings/${grouping.id}/content`;
return location;
};

return (
<>
<QueryRenderer
Expand Down Expand Up @@ -138,13 +145,7 @@ const RootGrouping = () => {
}}
>
<Tabs
value={
location.pathname.includes(
`/dashboard/analyses/groupings/${grouping.id}/knowledge`,
)
? `/dashboard/analyses/groupings/${grouping.id}/knowledge`
: location.pathname
}
value={getCurrentTab(location, grouping)}
>
<Tab
component={Link}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ToggleButton from '@mui/material/ToggleButton';
import { Link } from 'react-router-dom';
import { DifferenceOutlined } from '@mui/icons-material';
import { VectorPolygon } from 'mdi-material-ui';
import Box from '@mui/material/Box';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import { useFormatter } from '../../../../components/i18n';

interface StixCoreObjectContentHeaderProps {
Expand All @@ -20,11 +20,12 @@ const StixCoreObjectContentHeader: FunctionComponent<StixCoreObjectContentHeader

return (
<div style={{
margin: '-80px 0 0 0',
margin: '-75px 0 0 0',
float: 'right',
}}
>
{modes.includes('content') && (
<ToggleButtonGroup size="small" exclusive={true}>
{modes.includes('content') && (
<Tooltip title={t_i18n('Content view')}>
<ToggleButton
component={Link}
Expand All @@ -38,8 +39,8 @@ const StixCoreObjectContentHeader: FunctionComponent<StixCoreObjectContentHeader
/>
</ToggleButton>
</Tooltip>
)}
{modes.includes('mapping') && (
)}
{modes.includes('mapping') && (
<Tooltip title={t_i18n('Content mapping view')}>
<ToggleButton
component={Link}
Expand All @@ -53,7 +54,8 @@ const StixCoreObjectContentHeader: FunctionComponent<StixCoreObjectContentHeader
/>
</ToggleButton>
</Tooltip>
)}
)}
</ToggleButtonGroup>
</div>
);
};
Expand Down

0 comments on commit a6492b1

Please sign in to comment.