mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(editor): Migrate part of the vuex store to pinia (#4484)
* ✨ Added pinia support. Migrated community nodes module. * ✨ Added ui pinia store, moved some data from root store to it, updated modals to work with pinia stores * ✨ Added ui pinia store and migrated a part of the root store * ✨ Migrated `settings` store to pinia * ✨ Removing vuex store refs from router * ✨ Migrated `users` module to pinia store * ⚡ Fixing errors after sync with master * ⚡ One more error after merge * ⚡ Created `workflows` pinia store. Moved large part of root store to it. Started updating references. * ✨ Finished migrating workflows store to pinia * ⚡ Renaming some getters and actions to make more sense * ✨ Finished migrating the root store to pinia * ✨ Migrated ndv store to pinia * ⚡ Renaming main panel dimensions getter so it doesn't clash with data prop name * ✔️ Fixing lint errors * ✨ Migrated `templates` store to pinia * ✨ Migrated the `nodeTypes`store * ⚡ Removed unused pieces of code and oold vuex modules * ✨ Adding vuex calls to pinia store, fi xing wrong references * 💄 Removing leftover $store refs * ⚡ Added legacy getters and mutations to store to support webhooks * ⚡ Added missing front-end hooks, updated vuex state subscriptions to pinia * ✔️ Fixing linting errors * ⚡ Removing vue composition api plugin * ⚡ Fixing main sidebar state when loading node view * 🐛 Fixing an error when activating workflows * 🐛 Fixing isses with workflow settings and executions auto-refresh * 🐛 Removing duplicate listeners which cause import error * 🐛 Fixing route authentication * ⚡ Updating freshly pulled $store refs * Adding deleted const * ⚡ Updating store references in ee features. Reseting NodeView credentials update flag when resetting workspace * ⚡ Adding return type to email submission modal * ⚡ Making NodeView only react to paste event when active * 🐛 Fixing signup view errors * 👌 Addressing PR review comments * 👌 Addressing new PR comments * 👌 Updating invite id logic in signup view
This commit is contained in:
committed by
GitHub
parent
c2c7927414
commit
40e413d958
@@ -141,6 +141,11 @@ import {
|
||||
import { workflowActivate } from './mixins/workflowActivate';
|
||||
import { pinData } from "@/components/mixins/pinData";
|
||||
import { dataPinningEventBus } from '@/event-bus/data-pinning-event-bus';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useWorkflowsStore } from '@/stores/workflows';
|
||||
import { useNDVStore } from '@/stores/ndv';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes';
|
||||
import { useUIStore } from '@/stores/ui';
|
||||
|
||||
export default mixins(
|
||||
externalHooks,
|
||||
@@ -182,8 +187,7 @@ export default mixins(
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$store.commit('ndv/setNDVSessionId');
|
||||
|
||||
this.ndvStore.setNDVSessionId;
|
||||
dataPinningEventBus.$on('data-pinning-discovery', ({ isTooltipVisible }: { isTooltipVisible: boolean }) => {
|
||||
this.pinDataDiscoveryTooltipVisible = isTooltipVisible;
|
||||
});
|
||||
@@ -192,12 +196,17 @@ export default mixins(
|
||||
dataPinningEventBus.$off('data-pinning-discovery');
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['executionWaitingForWebhook']),
|
||||
...mapStores(
|
||||
useNodeTypesStore,
|
||||
useNDVStore,
|
||||
useUIStore,
|
||||
useWorkflowsStore,
|
||||
),
|
||||
sessionId(): string {
|
||||
return this.$store.getters['ndv/ndvSessionId'];
|
||||
return this.ndvStore.sessionId;
|
||||
},
|
||||
workflowRunning(): boolean {
|
||||
return this.$store.getters.isActionActive('workflowRunning');
|
||||
return this.uiStore.isActionActive('workflowRunning');
|
||||
},
|
||||
showTriggerWaitingWarning(): boolean {
|
||||
return (
|
||||
@@ -205,25 +214,25 @@ export default mixins(
|
||||
!!this.activeNodeType &&
|
||||
!this.activeNodeType.group.includes('trigger') &&
|
||||
this.workflowRunning &&
|
||||
this.executionWaitingForWebhook
|
||||
this.workflowsStore.executionWaitingForWebhook
|
||||
);
|
||||
},
|
||||
activeNode(): INodeUi | null {
|
||||
return this.$store.getters['ndv/activeNode'];
|
||||
return this.ndvStore.activeNode;
|
||||
},
|
||||
inputNodeName(): string | undefined {
|
||||
return this.selectedInput || this.parentNode;
|
||||
},
|
||||
inputNode(): INodeUi | null {
|
||||
if (this.inputNodeName) {
|
||||
return this.$store.getters.getNodeByName(this.inputNodeName);
|
||||
return this.workflowsStore.getNodeByName(this.inputNodeName);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
activeNodeType(): INodeTypeDescription | null {
|
||||
if (this.activeNode) {
|
||||
return this.$store.getters['nodeTypes/getNodeType'](this.activeNode.type, this.activeNode.typeVersion);
|
||||
return this.nodeTypesStore.getNodeType(this.activeNode.type, this.activeNode.typeVersion);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -257,11 +266,11 @@ export default mixins(
|
||||
},
|
||||
isActiveStickyNode(): boolean {
|
||||
return (
|
||||
!!this.$store.getters['ndv/activeNode'] && this.$store.getters['ndv/activeNode'].type === STICKY_NODE_TYPE
|
||||
!!this.ndvStore.activeNode && this.ndvStore.activeNode .type === STICKY_NODE_TYPE
|
||||
);
|
||||
},
|
||||
workflowExecution(): IExecutionResponse | null {
|
||||
return this.$store.getters.getWorkflowExecution;
|
||||
return this.workflowsStore.getWorkflowExecution;
|
||||
},
|
||||
workflowRunData(): IRunData | null {
|
||||
if (this.workflowExecution === null) {
|
||||
@@ -340,13 +349,13 @@ export default mixins(
|
||||
return `${BASE_NODE_SURVEY_URL}${this.activeNodeType.name}`;
|
||||
},
|
||||
outputPanelEditMode(): { enabled: boolean; value: string; } {
|
||||
return this.$store.getters['ndv/outputPanelEditMode'];
|
||||
return this.ndvStore.outputPanelEditMode;
|
||||
},
|
||||
isWorkflowRunning(): boolean {
|
||||
return this.$store.getters.isActionActive('workflowRunning');
|
||||
return this.uiStore.isActionActive('workflowRunning');
|
||||
},
|
||||
isExecutionWaitingForWebhook(): boolean {
|
||||
return this.$store.getters.executionWaitingForWebhook;
|
||||
return this.workflowsStore.executionWaitingForWebhook;
|
||||
},
|
||||
blockUi(): boolean {
|
||||
return this.isWorkflowRunning || this.isExecutionWaitingForWebhook;
|
||||
@@ -364,7 +373,7 @@ export default mixins(
|
||||
this.avgInputRowHeight = 0;
|
||||
|
||||
setTimeout(() => {
|
||||
this.$store.commit('ndv/setNDVSessionId');
|
||||
this.ndvStore.setNDVSessionId;
|
||||
}, 0);
|
||||
this.$externalHooks().run('dataDisplay.nodeTypeChanged', {
|
||||
nodeSubtitle: this.getNodeSubtitle(node, this.activeNodeType, this.getCurrentWorkflow()),
|
||||
@@ -374,24 +383,24 @@ export default mixins(
|
||||
|
||||
setTimeout(() => {
|
||||
if (this.activeNode) {
|
||||
const outogingConnections = this.$store.getters.outgoingConnectionsByNodeName(
|
||||
const outgoingConnections = this.workflowsStore.outgoingConnectionsByNodeName(
|
||||
this.activeNode.name,
|
||||
) as INodeConnections;
|
||||
|
||||
this.$telemetry.track('User opened node modal', {
|
||||
node_type: this.activeNodeType ? this.activeNodeType.name : '',
|
||||
workflow_id: this.$store.getters.workflowId,
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
session_id: this.sessionId,
|
||||
parameters_pane_position: this.mainPanelPosition,
|
||||
input_first_connector_runs: this.maxInputRun,
|
||||
output_first_connector_runs: this.maxOutputRun,
|
||||
selected_view_inputs: this.isTriggerNode
|
||||
? 'trigger'
|
||||
: this.$store.getters['ndv/inputPanelDisplayMode'],
|
||||
selected_view_outputs: this.$store.getters['ndv/outputPanelDisplayMode'],
|
||||
: this.ndvStore.inputPanelDisplayMode,
|
||||
selected_view_outputs: this.ndvStore.outputPanelDisplayMode,
|
||||
input_connectors: this.parentNodes.length,
|
||||
output_connectors:
|
||||
outogingConnections && outogingConnections.main && outogingConnections.main.length,
|
||||
outgoingConnections && outgoingConnections.main && outgoingConnections.main.length,
|
||||
input_displayed_run_index: this.inputRun,
|
||||
output_displayed_run_index: this.outputRun,
|
||||
data_pinning_tooltip_presented: this.pinDataDiscoveryTooltipVisible,
|
||||
@@ -413,12 +422,12 @@ export default mixins(
|
||||
},
|
||||
inputNodeName(nodeName: string | undefined) {
|
||||
setTimeout(() => {
|
||||
this.$store.commit('ndv/setInputNodeName', nodeName);
|
||||
this.ndvStore.setInputNodeName(nodeName);
|
||||
}, 0);
|
||||
},
|
||||
inputRun() {
|
||||
setTimeout(() => {
|
||||
this.$store.commit('ndv/setInputRunIndex', this.inputRun);
|
||||
this.ndvStore.setInputRunIndex(this.inputRun);
|
||||
}, 0);
|
||||
},
|
||||
},
|
||||
@@ -428,7 +437,7 @@ export default mixins(
|
||||
return;
|
||||
}
|
||||
if (e === null) {
|
||||
this.$store.commit('ndv/setHoveringItem', null);
|
||||
this.ndvStore.setHoveringItem(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -438,11 +447,11 @@ export default mixins(
|
||||
outputIndex: e.outputIndex,
|
||||
itemIndex: e.itemIndex,
|
||||
};
|
||||
this.$store.commit('ndv/setHoveringItem', item);
|
||||
this.ndvStore.setHoveringItem(item);
|
||||
},
|
||||
onOutputItemHover(e: {itemIndex: number, outputIndex: number} | null) {
|
||||
if (e === null || !this.activeNode) {
|
||||
this.$store.commit('ndv/setHoveringItem', null);
|
||||
this.ndvStore.setHoveringItem(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -452,7 +461,7 @@ export default mixins(
|
||||
outputIndex: e.outputIndex,
|
||||
itemIndex: e.itemIndex,
|
||||
};
|
||||
this.$store.commit('ndv/setHoveringItem', item);
|
||||
this.ndvStore.setHoveringItem(item);
|
||||
},
|
||||
onInputTableMounted(e: { avgRowHeight: number }) {
|
||||
this.avgInputRowHeight = e.avgRowHeight;
|
||||
@@ -461,7 +470,7 @@ export default mixins(
|
||||
this.avgOutputRowHeight = e.avgRowHeight;
|
||||
},
|
||||
onWorkflowActivate() {
|
||||
this.$store.commit('ndv/setActiveNodeName', null);
|
||||
this.ndvStore.activeNodeName = null;
|
||||
setTimeout(() => {
|
||||
this.activateCurrentWorkflow('ndv');
|
||||
}, 1000);
|
||||
@@ -471,7 +480,7 @@ export default mixins(
|
||||
if (this.activeNode) {
|
||||
this.$telemetry.track('User clicked ndv link', {
|
||||
node_type: this.activeNode.type,
|
||||
workflow_id: this.$store.getters.workflowId,
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
session_id: this.sessionId,
|
||||
pane: 'main',
|
||||
type: 'i-wish-this-node-would',
|
||||
@@ -493,7 +502,7 @@ export default mixins(
|
||||
end_position: e.position,
|
||||
node_type: this.activeNodeType ? this.activeNodeType.name : '',
|
||||
session_id: this.sessionId,
|
||||
workflow_id: this.$store.getters.workflowId,
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
});
|
||||
this.mainPanelPosition = e.position;
|
||||
},
|
||||
@@ -567,21 +576,23 @@ export default mixins(
|
||||
return;
|
||||
}
|
||||
|
||||
this.$store.commit('pinData', { node: this.activeNode, data: jsonParse(value) });
|
||||
if (this.activeNode) {
|
||||
this.workflowsStore.pinData({ node: this.activeNode, data: jsonParse(value) });
|
||||
}
|
||||
}
|
||||
|
||||
this.$store.commit('ndv/setOutputPanelEditModeEnabled', false);
|
||||
this.ndvStore.setOutputPanelEditModeEnabled(false);
|
||||
}
|
||||
|
||||
this.$externalHooks().run('dataDisplay.nodeEditingFinished');
|
||||
this.$telemetry.track('User closed node modal', {
|
||||
node_type: this.activeNodeType ? this.activeNodeType.name : '',
|
||||
session_id: this.sessionId,
|
||||
workflow_id: this.$store.getters.workflowId,
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
});
|
||||
this.triggerWaitingWarningEnabled = false;
|
||||
this.$store.commit('ndv/setActiveNodeName', null);
|
||||
this.$store.commit('ndv/resetNDVSessionId');
|
||||
this.ndvStore.activeNodeName = null;
|
||||
this.ndvStore.resetNDVSessionId();
|
||||
},
|
||||
onRunOutputIndexChange(run: number) {
|
||||
this.runOutputIndex = run;
|
||||
@@ -610,7 +621,7 @@ export default mixins(
|
||||
this.$telemetry.track('User changed ndv input dropdown', {
|
||||
node_type: this.activeNode ? this.activeNode.type : '',
|
||||
session_id: this.sessionId,
|
||||
workflow_id: this.$store.getters.workflowId,
|
||||
workflow_id: this.workflowsStore.workflowId,
|
||||
selection_value: index,
|
||||
input_node_type: this.inputNode ? this.inputNode.type : '',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user