Stars: Update star toolbar button to include name only in the label (#113678)
This commit is contained in:
@@ -7,12 +7,10 @@ import { Icon, ToolbarButton } from '@grafana/ui';
|
||||
import { useStarItem, useStarredItems } from './hooks';
|
||||
|
||||
const getStarTooltips = (title: string) => ({
|
||||
star: t('stars.mark-as-starred', 'Mark "{{title}}" as favorite', {
|
||||
title,
|
||||
}),
|
||||
unstar: t('stars.unmark-as-starred', 'Unmark "{{title}}" as favorite', {
|
||||
title,
|
||||
}),
|
||||
star: t('stars.mark-as-starred', 'Mark as favorite'),
|
||||
starWithTitle: t('stars.mark-as-starred-with-title', 'Mark "{{title}}" as favorite', { title }),
|
||||
unstar: t('stars.unmark-as-starred', 'Unmark as favorite'),
|
||||
unstarWithTitle: t('stars.unmark-as-starred-with-title', 'Unmark "{{title}}" as favorite', { title }),
|
||||
});
|
||||
|
||||
type Props = {
|
||||
@@ -51,18 +49,21 @@ export function StarToolbarButton({ title, group, kind, id, onStarChange }: Prop
|
||||
return { name: 'star', type: 'default' } as const;
|
||||
})();
|
||||
|
||||
const tooltip = (() => {
|
||||
const tooltipAndLabel = (() => {
|
||||
if (isLoading) {
|
||||
return undefined;
|
||||
return {};
|
||||
}
|
||||
return isStarred ? tooltips.unstar : tooltips.star;
|
||||
return isStarred
|
||||
? { tooltip: tooltips.unstar, label: tooltips.unstarWithTitle }
|
||||
: { tooltip: tooltips.star, label: tooltips.starWithTitle };
|
||||
})();
|
||||
|
||||
const icon = <Icon {...iconProps} size="lg" />;
|
||||
return (
|
||||
<ToolbarButton
|
||||
disabled={isLoading}
|
||||
tooltip={tooltip}
|
||||
tooltip={tooltipAndLabel.tooltip}
|
||||
aria-label={tooltipAndLabel.label}
|
||||
icon={icon}
|
||||
data-testid={selectors.components.NavToolbar.markAsFavorite}
|
||||
onClick={handleStarToggle}
|
||||
|
||||
@@ -12878,8 +12878,10 @@
|
||||
"view-explanation": "View explanation"
|
||||
},
|
||||
"stars": {
|
||||
"mark-as-starred": "Mark \"{{title}}\" as favorite",
|
||||
"unmark-as-starred": "Unmark \"{{title}}\" as favorite"
|
||||
"mark-as-starred": "Mark as favorite",
|
||||
"mark-as-starred-with-title": "Mark \"{{title}}\" as favorite",
|
||||
"unmark-as-starred": "Unmark as favorite",
|
||||
"unmark-as-starred-with-title": "Unmark \"{{title}}\" as favorite"
|
||||
},
|
||||
"stat": {
|
||||
"add-orientation-option": {
|
||||
|
||||
Reference in New Issue
Block a user