fix(editor): Update design system menu item component (#6659)

This commit is contained in:
Csaba Tuncsik 2023-07-13 13:27:25 +02:00 committed by GitHub
parent e6a81f0008
commit 84466e9833
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 9 deletions

View file

@ -31,6 +31,33 @@ defaultMenuItem.args = {
}, },
}; };
export const withSecondaryIcon = template.bind({});
withSecondaryIcon.args = {
item: {
id: 'workflows',
icon: 'heart',
label: 'Workflows',
secondaryIcon: { name: 'lock', size: 'small' },
},
};
export const withSecondaryIconTooltip = template.bind({});
withSecondaryIconTooltip.args = {
item: {
id: 'workflows',
icon: 'heart',
label: 'Workflows',
secondaryIcon: {
name: 'lock',
size: 'small',
tooltip: {
content: 'Locked secret',
bindTo: 'secondaryIcon',
},
},
},
};
export const compact = template.bind({}); export const compact = template.bind({});
compact.args = { compact.args = {
item: { item: {

View file

@ -62,9 +62,9 @@
<n8n-tooltip <n8n-tooltip
v-if="item.secondaryIcon" v-if="item.secondaryIcon"
:class="$style.secondaryIcon" :class="$style.secondaryIcon"
:placement="item.tooltip?.placement || 'right'" :placement="item.secondaryIcon?.tooltip?.placement || 'right'"
:content="item.tooltip?.content" :content="item.secondaryIcon?.tooltip?.content"
:disabled="compact || !item.tooltip?.content || item.tooltip?.bindTo !== 'secondaryIcon'" :disabled="compact || !item.secondaryIcon?.tooltip?.content"
:open-delay="tooltipDelay" :open-delay="tooltipDelay"
> >
<n8n-icon :icon="item.secondaryIcon.name" :size="item.secondaryIcon.size || 'small'" /> <n8n-icon :icon="item.secondaryIcon.name" :size="item.secondaryIcon.size || 'small'" />

View file

@ -4,7 +4,11 @@ export type IMenuItem = {
id: string; id: string;
label: string; label: string;
icon?: string; icon?: string;
secondaryIcon?: { name: string; size?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' }; secondaryIcon?: {
name: string;
size?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
tooltip?: Tooltip;
};
customIconSize?: 'medium' | 'small'; customIconSize?: 'medium' | 'small';
available?: boolean; available?: boolean;
position?: 'top' | 'bottom'; position?: 'top' | 'bottom';
@ -16,7 +20,6 @@ export type IMenuItem = {
// For more specific matching, we can use paths // For more specific matching, we can use paths
activateOnRoutePaths?: string[]; activateOnRoutePaths?: string[];
children?: IMenuItem[]; children?: IMenuItem[];
tooltip?: Tooltip & { bindTo?: 'menuItem' | 'secondaryIcon' };
}; };
export type ILinkMenuItemProperties = { export type ILinkMenuItemProperties = {

View file

@ -202,10 +202,11 @@ export default defineComponent({
}; };
if (this.sourceControlStore.preferences.branchReadOnly) { if (this.sourceControlStore.preferences.branchReadOnly) {
workflows.secondaryIcon = { name: 'lock' }; workflows.secondaryIcon = {
workflows.tooltip = { name: 'lock',
tooltip: {
content: this.$locale.baseText('mainSidebar.workflows.readOnlyEnv.tooltip'), content: this.$locale.baseText('mainSidebar.workflows.readOnlyEnv.tooltip'),
bindTo: 'secondaryIcon', },
}; };
} }