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
@@ -152,6 +152,11 @@ import { nodeHelpers } from '@/components/mixins/nodeHelpers';
|
||||
import mixins from 'vue-typed-mixins';
|
||||
import NodeExecuteButton from './NodeExecuteButton.vue';
|
||||
import { isCommunityPackageName } from './helpers';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useUIStore } from '@/stores/ui';
|
||||
import { useWorkflowsStore } from '@/stores/workflows';
|
||||
import { useNDVStore } from '@/stores/ndv';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes';
|
||||
|
||||
export default mixins(externalHooks, nodeHelpers).extend({
|
||||
name: 'NodeSettings',
|
||||
@@ -165,8 +170,14 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
NodeExecuteButton,
|
||||
},
|
||||
computed: {
|
||||
isCurlImportModalOpen() {
|
||||
return this.$store.getters['ui/isModalOpen'](IMPORT_CURL_MODAL_KEY);
|
||||
...mapStores(
|
||||
useNodeTypesStore,
|
||||
useNDVStore,
|
||||
useUIStore,
|
||||
useWorkflowsStore,
|
||||
),
|
||||
isCurlImportModalOpen(): boolean {
|
||||
return this.uiStore.isModalOpen(IMPORT_CURL_MODAL_KEY);
|
||||
},
|
||||
nodeTypeName(): string {
|
||||
if (this.nodeType) {
|
||||
@@ -201,8 +212,8 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
'background-color': this.node.color,
|
||||
};
|
||||
},
|
||||
node(): INodeUi {
|
||||
return this.$store.getters['ndv/activeNode'];
|
||||
node(): INodeUi | null {
|
||||
return this.ndvStore.activeNode;
|
||||
},
|
||||
parametersSetting(): INodeProperties[] {
|
||||
return this.parameters.filter((item) => {
|
||||
@@ -222,13 +233,13 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
return this.nodeType.properties;
|
||||
},
|
||||
outputPanelEditMode(): { enabled: boolean; value: string } {
|
||||
return this.$store.getters['ndv/outputPanelEditMode'];
|
||||
return this.ndvStore.outputPanelEditMode;
|
||||
},
|
||||
isCommunityNode(): boolean {
|
||||
return isCommunityPackageName(this.node.type);
|
||||
},
|
||||
isTriggerNode(): boolean {
|
||||
return this.$store.getters['nodeTypes/isTriggerNode'](this.node.type);
|
||||
return this.nodeTypesStore.isTriggerNode(this.node.type);
|
||||
},
|
||||
},
|
||||
props: {
|
||||
@@ -366,7 +377,7 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
},
|
||||
isCurlImportModalOpen(newValue, oldValue) {
|
||||
if (newValue === false) {
|
||||
let parameters = this.$store.getters['ui/getHttpNodeParameters'];
|
||||
let parameters = this.uiStore.getHttpNodeParameters || '';
|
||||
|
||||
if (!parameters) return;
|
||||
|
||||
@@ -382,7 +393,7 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
value: parameters,
|
||||
});
|
||||
|
||||
this.$store.dispatch('ui/setHttpNodeParameters', { parameters: '' });
|
||||
this.uiStore.setHttpNodeParameters({ name: IMPORT_CURL_MODAL_KEY, parameters: '' });
|
||||
} catch (_) {}
|
||||
}
|
||||
},
|
||||
@@ -452,12 +463,14 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
},
|
||||
credentialSelected(updateInformation: INodeUpdatePropertiesInformation) {
|
||||
// Update the values on the node
|
||||
this.$store.commit('updateNodeProperties', updateInformation);
|
||||
this.workflowsStore.updateNodeProperties(updateInformation);
|
||||
|
||||
const node = this.$store.getters.getNodeByName(updateInformation.name);
|
||||
const node = this.workflowsStore.getNodeByName(updateInformation.name);
|
||||
|
||||
// Update the issues
|
||||
this.updateNodeCredentialIssues(node);
|
||||
if (node) {
|
||||
// Update the issues
|
||||
this.updateNodeCredentialIssues(node);
|
||||
}
|
||||
|
||||
this.$externalHooks().run('nodeSettings.credentialSelected', { updateInformation });
|
||||
},
|
||||
@@ -481,7 +494,12 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
// Save the node name before we commit the change because
|
||||
// we need the old name to rename the node properly
|
||||
const nodeNameBefore = parameterData.node || this.node.name;
|
||||
const node = this.$store.getters.getNodeByName(nodeNameBefore);
|
||||
const node = this.workflowsStore.getNodeByName(nodeNameBefore);
|
||||
|
||||
if (node === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parameterData.name === 'name') {
|
||||
// Name of node changed so we have to set also the new node name as active
|
||||
|
||||
@@ -494,10 +512,7 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
this.$emit('valueChanged', sendData);
|
||||
} else if (parameterData.name === 'parameters') {
|
||||
|
||||
const nodeType = this.$store.getters['nodeTypes/getNodeType'](
|
||||
node.type,
|
||||
node.typeVersion,
|
||||
) as INodeTypeDescription | null;
|
||||
const nodeType = this.nodeTypesStore.getNodeType(node.type, node.typeVersion);
|
||||
if (!nodeType) {
|
||||
return;
|
||||
}
|
||||
@@ -573,23 +588,21 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
}
|
||||
}
|
||||
|
||||
// Update the data in vuex
|
||||
const updateInformation = {
|
||||
name: node.name,
|
||||
value: nodeParameters,
|
||||
};
|
||||
if (nodeParameters) {
|
||||
const updateInformation: IUpdateInformation = {
|
||||
name: node.name,
|
||||
value: nodeParameters,
|
||||
};
|
||||
|
||||
this.$store.commit('setNodeParameters', updateInformation);
|
||||
this.workflowsStore.setNodeParameters(updateInformation);
|
||||
|
||||
this.updateNodeParameterIssues(node, nodeType);
|
||||
this.updateNodeCredentialIssues(node);
|
||||
this.updateNodeParameterIssues(node, nodeType);
|
||||
this.updateNodeCredentialIssues(node);
|
||||
}
|
||||
} else if (parameterData.name.startsWith('parameters.')) {
|
||||
// A node parameter changed
|
||||
|
||||
const nodeType = this.$store.getters['nodeTypes/getNodeType'](
|
||||
node.type,
|
||||
node.typeVersion,
|
||||
) as INodeTypeDescription | null;
|
||||
const nodeType = this.nodeTypesStore.getNodeType(node.type, node.typeVersion);
|
||||
if (!nodeType) {
|
||||
return;
|
||||
}
|
||||
@@ -657,7 +670,7 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
value: nodeParameters,
|
||||
};
|
||||
|
||||
this.$store.commit('setNodeParameters', updateInformation);
|
||||
this.workflowsStore.setNodeParameters(updateInformation);
|
||||
|
||||
this.$externalHooks().run('nodeSettings.valueChanged', {
|
||||
parameterPath,
|
||||
@@ -680,7 +693,8 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
key: parameterData.name,
|
||||
value: newValue,
|
||||
};
|
||||
this.$store.commit('setNodeValue', updateInformation);
|
||||
|
||||
this.workflowsStore.setNodeValue(updateInformation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user