2022-12-14 01:04:10 -08:00
|
|
|
import { STORES } from '@/constants';
|
|
|
|
import { IFakeDoor, INodeUi, IRootState, NestedRecord } from '@/Interface';
|
|
|
|
import { IMenuItem } from 'n8n-design-system';
|
|
|
|
import { IWorkflowSettings } from 'n8n-workflow';
|
|
|
|
import { defineStore } from 'pinia';
|
|
|
|
import { useRootStore } from './n8nRootStore';
|
|
|
|
import { useNDVStore } from './ndv';
|
|
|
|
import { useSettingsStore } from './settings';
|
|
|
|
import { useUIStore } from './ui';
|
|
|
|
import { useUsersStore } from './users';
|
|
|
|
import { useWorkflowsStore } from './workflows';
|
2022-11-09 01:01:50 -08:00
|
|
|
|
|
|
|
export const useWebhooksStore = defineStore(STORES.WEBHOOKS, {
|
|
|
|
getters: {
|
|
|
|
globalRoleName(): string {
|
|
|
|
return useUsersStore().globalRoleName;
|
|
|
|
},
|
2022-12-21 07:42:07 -08:00
|
|
|
getContextBasedTranslationKeys() {
|
|
|
|
return useUIStore().contextBasedTranslationKeys;
|
2022-11-29 05:13:10 -08:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
getFakeDoorFeatures() {
|
2022-11-09 01:01:50 -08:00
|
|
|
return useUIStore().fakeDoorFeatures;
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
isUserManagementEnabled() {
|
2022-11-09 01:01:50 -08:00
|
|
|
return useSettingsStore().isUserManagementEnabled;
|
|
|
|
},
|
|
|
|
getFakeDoorItems(): IFakeDoor[] {
|
|
|
|
return useUIStore().fakeDoorFeatures;
|
|
|
|
},
|
|
|
|
n8nMetadata(): IRootState['n8nMetadata'] {
|
|
|
|
return useRootStore().n8nMetadata;
|
|
|
|
},
|
|
|
|
instanceId(): string {
|
|
|
|
return useRootStore().instanceId;
|
|
|
|
},
|
|
|
|
workflowId(): string {
|
|
|
|
return useWorkflowsStore().workflowId;
|
|
|
|
},
|
|
|
|
workflowName(): string {
|
|
|
|
return useWorkflowsStore().workflowName;
|
|
|
|
},
|
|
|
|
activeNode(): INodeUi | null {
|
|
|
|
return useNDVStore().activeNode;
|
|
|
|
},
|
|
|
|
workflowSettings(): IWorkflowSettings {
|
|
|
|
return useWorkflowsStore().workflowSettings;
|
|
|
|
},
|
|
|
|
activeExecutionId(): string {
|
|
|
|
return useWorkflowsStore().activeExecutionId || '';
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
nodeByName:
|
|
|
|
(state: IRootState) =>
|
|
|
|
(nodeName: string): INodeUi | null => {
|
|
|
|
return useWorkflowsStore().getNodeByName(nodeName);
|
|
|
|
},
|
2022-11-09 01:01:50 -08:00
|
|
|
allNodes(): INodeUi[] {
|
|
|
|
return useWorkflowsStore().allNodes;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
addSidebarMenuItems(menuItems: IMenuItem[]) {
|
|
|
|
const uiStore = useUIStore();
|
|
|
|
const updated = uiStore.sidebarMenuItems.concat(menuItems);
|
2022-12-14 01:04:10 -08:00
|
|
|
uiStore.sidebarMenuItems = updated;
|
2022-11-09 01:01:50 -08:00
|
|
|
},
|
|
|
|
setFakeDoorFeatures(fakeDoors: IFakeDoor[]): void {
|
|
|
|
useUIStore().fakeDoorFeatures = fakeDoors;
|
|
|
|
},
|
2022-12-21 07:42:07 -08:00
|
|
|
setContextBasedTranslationKeys(translations: NestedRecord<string>): void {
|
|
|
|
useUIStore().contextBasedTranslationKeys = translations;
|
2022-11-29 05:13:10 -08:00
|
|
|
},
|
2022-11-09 01:01:50 -08:00
|
|
|
},
|
|
|
|
});
|