refactor(editor): Refactor nodeHelpers mixin to composable (#7810)

- Convert `nodeHelpers` mixin into composable and fix types
- Replace usage of the mixin with the new composable
- Add missing store imports in components that were dependent on opaque
imports from nodeHelpers mixin
- Refactor the `CollectionParameter` component to the modern script
setup syntax
Github issue / Community forum post (link here to close automatically):

---------

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
oleg
2023-12-08 16:59:03 +01:00
committed by GitHub
parent e8a493f718
commit 35fbc37c8e
20 changed files with 1017 additions and 977 deletions

View File

@@ -135,10 +135,9 @@ import type {
import { NodeHelpers } from 'n8n-workflow';
import CredentialIcon from '@/components/CredentialIcon.vue';
import { nodeHelpers } from '@/mixins/nodeHelpers';
import { useMessage } from '@/composables/useMessage';
import { useToast } from '@/composables/useToast';
import { useNodeHelpers } from '@/composables/useNodeHelpers';
import { useMessage } from '@/composables/useMessage';
import CredentialConfig from '@/components/CredentialEdit/CredentialConfig.vue';
import CredentialInfo from '@/components/CredentialEdit/CredentialInfo.vue';
import CredentialSharing from '@/components/CredentialEdit/CredentialSharing.ee.vue';
@@ -157,6 +156,8 @@ import { useUsersStore } from '@/stores/users.store';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { useNDVStore } from '@/stores/ndv.store';
import { useCredentialsStore } from '@/stores/credentials.store';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import {
getNodeAuthOptions,
getNodeCredentialForSelectedAuthType,
@@ -172,7 +173,6 @@ interface NodeAccessMap {
export default defineComponent({
name: 'CredentialEdit',
mixins: [nodeHelpers],
components: {
CredentialSharing,
CredentialConfig,
@@ -197,10 +197,13 @@ export default defineComponent({
},
},
setup() {
const nodeHelpers = useNodeHelpers();
return {
externalHooks: useExternalHooks(),
...useToast(),
...useMessage(),
nodeHelpers,
};
},
data() {
@@ -296,6 +299,7 @@ export default defineComponent({
useUIStore,
useUsersStore,
useWorkflowsStore,
useNodeTypesStore,
),
activeNodeType(): INodeTypeDescription | null {
const activeNode = this.ndvStore.activeNode;
@@ -577,7 +581,12 @@ export default defineComponent({
return true;
}
return this.displayParameter(this.credentialData as INodeParameters, parameter, '', null);
return this.nodeHelpers.displayParameter(
this.credentialData as INodeParameters,
parameter,
'',
null,
);
},
getCredentialProperties(name: string): INodeProperties[] {
const credentialTypeData = this.credentialsStore.getCredentialTypeByName(name);
@@ -957,7 +966,7 @@ export default defineComponent({
// Now that the credentials changed check if any nodes use credentials
// which have now a different name
this.updateNodesCredentialsIssues();
this.nodeHelpers.updateNodesCredentialsIssues();
return credential;
},
@@ -1004,7 +1013,7 @@ export default defineComponent({
this.isDeleting = false;
// Now that the credentials were removed check if any nodes used them
this.updateNodesCredentialsIssues();
this.nodeHelpers.updateNodesCredentialsIssues();
this.credentialData = {};
this.showMessage({