Skip to content

Commit

Permalink
fix(topology): correct toolbar mode icon (#1019)
Browse files Browse the repository at this point in the history
* fix(topology): correct toolbar mode icon

* chore(topology): localize mode icon label
  • Loading branch information
Thuan Vo authored May 8, 2023
1 parent 093e003 commit 0213921
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions locales/en/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,5 +390,9 @@
"SELECT": "Select a timezone",
"TYPE_AHEAD": "Search a timezone"
}
},
"Topology": {
"GRAPH_VIEW": "Graph View",
"LIST_VIEW": "List View"
}
}
12 changes: 7 additions & 5 deletions src/app/Topology/Toolbar/TopologyToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { HelpButton } from './HelpButton';
import { QuickSearchButton } from './QuickSearchButton';
import { TopologyFilterChips } from './TopologyFilterChips';
import { TopologyFilters } from './TopologyFilters';
import { useTranslation } from 'react-i18next';

export enum TopologyToolbarVariant {
Graph = 'graph',
Expand All @@ -65,6 +66,7 @@ export interface TopologyToolbarProps {
export const TopologyToolbar: React.FC<TopologyToolbarProps> = ({ variant, visualization, isDisabled, ...props }) => {
const isGraphView = variant === TopologyToolbarVariant.Graph;
const dispatch = useDispatch();
const { t } = useTranslation();

const [quicksearchOpen, setQuicksearchOpen] = React.useState(false);

Expand All @@ -85,21 +87,21 @@ export const TopologyToolbar: React.FC<TopologyToolbarProps> = ({ variant, visua
}
}, [setQuicksearchOpen]);

const actionIcon = React.useMemo(
const modeIcon = React.useMemo(
() => (
<Tooltip
entryDelay={0}
content={isGraphView ? 'Graph View' : 'List View'}
content={isGraphView ? t('Topology.LIST_VIEW') : t('Topology.GRAPH_VIEW')}
aria="none"
aria-live="polite"
appendTo={portalRoot}
>
<Button className="topology__view-switcher" aria-label="Clipboard" variant="plain" onClick={toggleView}>
{isGraphView ? <TopologyIcon /> : <ListIcon />}
{isGraphView ? <ListIcon /> : <TopologyIcon />}
</Button>
</Tooltip>
),
[isGraphView, toggleView]
[isGraphView, toggleView, t]
);

const shortcuts = React.useMemo(() => {
Expand Down Expand Up @@ -192,7 +194,7 @@ export const TopologyToolbar: React.FC<TopologyToolbarProps> = ({ variant, visua
</ToolbarItem>
) : null}
{!isDisabled ? <ToolbarItem alignment={{ default: 'alignRight' }}>{shortcuts}</ToolbarItem> : null}
<ToolbarItem alignment={isDisabled ? { default: 'alignRight' } : undefined}>{actionIcon}</ToolbarItem>
<ToolbarItem alignment={isDisabled ? { default: 'alignRight' } : undefined}>{modeIcon}</ToolbarItem>
</ToolbarContent>
</Toolbar>
<TopologyFilterChips className="topology__toolbar-chip-content" />
Expand Down

0 comments on commit 0213921

Please sign in to comment.