mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(editor): Extend menu item and use it as a recursive component (#6618)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="['n8n-menu-item', $style.item]">
|
<div :class="['n8n-menu-item', $style.item]">
|
||||||
<el-submenu
|
<el-submenu
|
||||||
v-if="item.children && item.children.length > 0"
|
v-if="item.children?.length"
|
||||||
:id="item.id"
|
:id="item.id"
|
||||||
:class="{
|
:class="{
|
||||||
[$style.submenu]: true,
|
[$style.submenu]: true,
|
||||||
@@ -21,25 +21,16 @@
|
|||||||
/>
|
/>
|
||||||
<span :class="$style.label">{{ item.label }}</span>
|
<span :class="$style.label">{{ item.label }}</span>
|
||||||
</template>
|
</template>
|
||||||
<el-menu-item
|
<n8n-menu-item
|
||||||
v-for="child in availableChildren"
|
v-for="item in availableChildren"
|
||||||
:key="child.id"
|
:key="item.id"
|
||||||
:id="child.id"
|
:item="item"
|
||||||
:class="{
|
:compact="compact"
|
||||||
[$style.menuItem]: true,
|
:tooltipDelay="tooltipDelay"
|
||||||
[$style.disableActiveStyle]: !isItemActive(child),
|
:popperClass="popperClass"
|
||||||
[$style.active]: isItemActive(child),
|
:mode="mode"
|
||||||
}"
|
:activeTab="activeTab"
|
||||||
data-test-id="menu-item"
|
/>
|
||||||
:index="child.id"
|
|
||||||
@click="onItemClick(child, $event)"
|
|
||||||
>
|
|
||||||
<n8n-icon v-if="child.icon" :class="$style.icon" :icon="child.icon" />
|
|
||||||
<span :class="$style.label">{{ child.label }}</span>
|
|
||||||
<span v-if="child.secondaryIcon" :class="$style.secondaryIcon">
|
|
||||||
<n8n-icon :icon="child.secondaryIcon.name" :size="child.secondaryIcon.size || 'small'" />
|
|
||||||
</span>
|
|
||||||
</el-menu-item>
|
|
||||||
</el-submenu>
|
</el-submenu>
|
||||||
<n8n-tooltip
|
<n8n-tooltip
|
||||||
v-else
|
v-else
|
||||||
@@ -68,9 +59,16 @@
|
|||||||
:size="item.customIconSize || 'large'"
|
:size="item.customIconSize || 'large'"
|
||||||
/>
|
/>
|
||||||
<span :class="$style.label">{{ item.label }}</span>
|
<span :class="$style.label">{{ item.label }}</span>
|
||||||
<span v-if="item.secondaryIcon" :class="$style.secondaryIcon">
|
<n8n-tooltip
|
||||||
|
v-if="item.secondaryIcon"
|
||||||
|
:class="$style.secondaryIcon"
|
||||||
|
:placement="item.tooltip?.placement || 'right'"
|
||||||
|
:content="item.tooltip?.content"
|
||||||
|
:disabled="compact || !item.tooltip?.content || item.tooltip?.bindTo !== 'secondaryIcon'"
|
||||||
|
: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'" />
|
||||||
</span>
|
</n8n-tooltip>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</n8n-tooltip>
|
</n8n-tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import type { Tooltip } from 'element-ui';
|
||||||
|
|
||||||
export type IMenuItem = {
|
export type IMenuItem = {
|
||||||
id: string;
|
id: string;
|
||||||
label: string;
|
label: string;
|
||||||
@@ -14,6 +16,7 @@ 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 = {
|
||||||
|
|||||||
@@ -193,6 +193,22 @@ export default defineComponent({
|
|||||||
const items: IMenuItem[] = [];
|
const items: IMenuItem[] = [];
|
||||||
const injectedItems = this.uiStore.sidebarMenuItems;
|
const injectedItems = this.uiStore.sidebarMenuItems;
|
||||||
|
|
||||||
|
const workflows: IMenuItem = {
|
||||||
|
id: 'workflows',
|
||||||
|
icon: 'network-wired',
|
||||||
|
label: this.$locale.baseText('mainSidebar.workflows'),
|
||||||
|
position: 'top',
|
||||||
|
activateOnRouteNames: [VIEWS.WORKFLOWS],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.sourceControlStore.preferences.branchReadOnly) {
|
||||||
|
workflows.secondaryIcon = { name: 'lock' };
|
||||||
|
workflows.tooltip = {
|
||||||
|
content: this.$locale.baseText('mainSidebar.workflows.readOnlyEnv.tooltip'),
|
||||||
|
bindTo: 'secondaryIcon',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (injectedItems && injectedItems.length > 0) {
|
if (injectedItems && injectedItems.length > 0) {
|
||||||
for (const item of injectedItems) {
|
for (const item of injectedItems) {
|
||||||
items.push({
|
items.push({
|
||||||
@@ -209,16 +225,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const regularItems: IMenuItem[] = [
|
const regularItems: IMenuItem[] = [
|
||||||
{
|
workflows,
|
||||||
id: 'workflows',
|
|
||||||
icon: 'network-wired',
|
|
||||||
secondaryIcon: this.sourceControlStore.preferences.branchReadOnly
|
|
||||||
? { name: 'lock' }
|
|
||||||
: undefined,
|
|
||||||
label: this.$locale.baseText('mainSidebar.workflows'),
|
|
||||||
position: 'top',
|
|
||||||
activateOnRouteNames: [VIEWS.WORKFLOWS],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'templates',
|
id: 'templates',
|
||||||
icon: 'box-open',
|
icon: 'box-open',
|
||||||
|
|||||||
@@ -619,6 +619,7 @@
|
|||||||
"mainSidebar.showMessage.stopExecution.title": "Execution stopped",
|
"mainSidebar.showMessage.stopExecution.title": "Execution stopped",
|
||||||
"mainSidebar.templates": "Templates",
|
"mainSidebar.templates": "Templates",
|
||||||
"mainSidebar.workflows": "Workflows",
|
"mainSidebar.workflows": "Workflows",
|
||||||
|
"mainSidebar.workflows.readOnlyEnv.tooltip": "Protected mode is active, so no workflows changes are allowed. Change this in Settings, under 'Source Control'",
|
||||||
"mainSidebar.executions": "All executions",
|
"mainSidebar.executions": "All executions",
|
||||||
"menuActions.duplicate": "Duplicate",
|
"menuActions.duplicate": "Duplicate",
|
||||||
"menuActions.download": "Download",
|
"menuActions.download": "Download",
|
||||||
|
|||||||
Reference in New Issue
Block a user