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

@@ -119,7 +119,7 @@
</div>
<div
v-if="isCustomApiCallSelected(nodeValues)"
v-if="nodeHelpers.isCustomApiCallSelected(nodeValues)"
class="parameter-item parameter-notice"
data-test-id="node-parameters-http-notice"
>
@@ -201,8 +201,6 @@ import NodeSettingsTabs from '@/components/NodeSettingsTabs.vue';
import NodeWebhooks from '@/components/NodeWebhooks.vue';
import { get, set, unset } from 'lodash-es';
import { nodeHelpers } from '@/mixins/nodeHelpers';
import NodeExecuteButton from './NodeExecuteButton.vue';
import { isCommunityPackageName } from '@/utils/nodeTypesUtils';
import { useUIStore } from '@/stores/ui.store';
@@ -215,10 +213,10 @@ import useWorkflowsEEStore from '@/stores/workflows.ee.store';
import { useCredentialsStore } from '@/stores/credentials.store';
import type { EventBus } from 'n8n-design-system';
import { useExternalHooks } from '@/composables/useExternalHooks';
import { useNodeHelpers } from '@/composables/useNodeHelpers';
export default defineComponent({
name: 'NodeSettings',
mixins: [nodeHelpers],
components: {
NodeTitle,
NodeCredentials,
@@ -228,9 +226,12 @@ export default defineComponent({
NodeExecuteButton,
},
setup() {
const nodeHelpers = useNodeHelpers();
const externalHooks = useExternalHooks();
return {
externalHooks,
nodeHelpers,
};
},
computed: {
@@ -679,7 +680,7 @@ export default defineComponent({
if (node) {
// Update the issues
this.updateNodeCredentialIssues(node);
this.nodeHelpers.updateNodeCredentialIssues(node);
}
void this.externalHooks.run('nodeSettings.credentialSelected', { updateInformation });
@@ -813,8 +814,8 @@ export default defineComponent({
this.workflowsStore.setNodeParameters(updateInformation);
this.updateNodeParameterIssuesByName(node.name);
this.updateNodeCredentialIssuesByName(node.name);
this.nodeHelpers.updateNodeParameterIssuesByName(node.name);
this.nodeHelpers.updateNodeCredentialIssuesByName(node.name);
}
} else if (parameterData.name.startsWith('parameters.')) {
// A node parameter changed
@@ -896,8 +897,8 @@ export default defineComponent({
oldNodeParameters,
});
this.updateNodeParameterIssuesByName(node.name);
this.updateNodeCredentialIssuesByName(node.name);
this.nodeHelpers.updateNodeParameterIssuesByName(node.name);
this.nodeHelpers.updateNodeCredentialIssuesByName(node.name);
this.$telemetry.trackNodeParametersValuesChange(nodeType.name, parameterData);
} else {
// A property on the node itself changed
@@ -1060,7 +1061,7 @@ export default defineComponent({
this.setNodeValues();
this.eventBus?.on('openSettings', this.openSettings);
this.updateNodeParameterIssues(this.node as INodeUi, this.nodeType);
this.nodeHelpers.updateNodeParameterIssues(this.node as INodeUi, this.nodeType);
},
beforeUnmount() {
this.eventBus?.off('openSettings', this.openSettings);