Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(topology): correct toolbar mode icon #1019

Merged
merged 2 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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