refactor: Migrate externalHooks mixin to composables (no-changelog) (#7930)

## Summary
Provide details about your pull request and what it adds, fixes, or
changes. Photos and videos are recommended.

As part of NodeView refactor, this PR migrates all externalHooks calls
to `useExternalHooks` composable.

#### How to test the change:
1. Run using env `export N8N_DEPLOYMENT_TYPE=cloud` 
2. Hooks should still run as expected


## Issues fixed
Include links to Github issue or Community forum post or **Linear
ticket**:
> Important in order to close automatically and provide context to
reviewers

https://linear.app/n8n/issue/N8N-6349/externalhooks


## Review / Merge checklist
- [x] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
- [x] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up
ticket created.
- [x] Tests included.
> A bug is not considered fixed, unless a test is added to prevent it
from happening again. A feature is not complete without tests.
  >
> *(internal)* You can use Slack commands to trigger [e2e
tests](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#a39f9e5ba64a48b58a71d81c837e8227)
or [deploy test
instance](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#f6a177d32bde4b57ae2da0b8e454bfce)
or [deploy early access version on
Cloud](https://www.notion.so/n8n/Cloudbot-3dbe779836004972b7057bc989526998?pvs=4#fef2d36ab02247e1a0f65a74f6fb534e).
This commit is contained in:
Alex Grozav
2023-12-06 17:28:09 +02:00
committed by GitHub
parent c461025f70
commit 885dba6f12
46 changed files with 287 additions and 241 deletions

View File

@@ -395,7 +395,6 @@ import TextEdit from '@/components/TextEdit.vue';
import CodeNodeEditor from '@/components/CodeNodeEditor/CodeNodeEditor.vue';
import HtmlEditor from '@/components/HtmlEditor/HtmlEditor.vue';
import SqlEditor from '@/components/SqlEditor/SqlEditor.vue';
import { externalHooks } from '@/mixins/externalHooks';
import { nodeHelpers } from '@/mixins/nodeHelpers';
import { workflowHelpers } from '@/mixins/workflowHelpers';
import { hasExpressionMapping, isValueExpression } from '@/utils/nodeTypesUtils';
@@ -421,12 +420,13 @@ import { createEventBus } from 'n8n-design-system/utils';
import { useI18n } from '@/composables/useI18n';
import type { N8nInput } from 'n8n-design-system';
import { isCredentialOnlyNodeType } from '@/utils/credentialOnlyNodes';
import { useExternalHooks } from '@/composables/useExternalHooks';
type Picker = { $emit: (arg0: string, arg1: Date) => void };
export default defineComponent({
name: 'parameter-input',
mixins: [externalHooks, nodeHelpers, workflowHelpers, debounceHelper],
mixins: [nodeHelpers, workflowHelpers, debounceHelper],
components: {
CodeNodeEditor,
HtmlEditor,
@@ -503,9 +503,11 @@ export default defineComponent({
},
},
setup() {
const externalHooks = useExternalHooks();
const i18n = useI18n();
return {
externalHooks,
i18n,
};
},
@@ -882,7 +884,7 @@ export default defineComponent({
this.updateNodeCredentialIssues(node);
}
void this.$externalHooks().run('nodeSettings.credentialSelected', { updateInformation });
void this.externalHooks.run('nodeSettings.credentialSelected', { updateInformation });
},
/**
* Check whether a param value must be skipped when collecting node param issues for validation.
@@ -1207,7 +1209,7 @@ export default defineComponent({
had_parameter: typeof prevValue === 'string' && prevValue.includes('$parameter'),
};
this.$telemetry.track('User switched parameter mode', telemetryPayload);
void this.$externalHooks().run('parameterInput.modeSwitch', telemetryPayload);
void this.externalHooks.run('parameterInput.modeSwitch', telemetryPayload);
}
},
},
@@ -1216,7 +1218,7 @@ export default defineComponent({
const remoteParameterOptions = this.$el.querySelectorAll('.remote-parameter-option');
if (remoteParameterOptions.length > 0) {
void this.$externalHooks().run('parameterInput.updated', { remoteParameterOptions });
void this.externalHooks.run('parameterInput.updated', { remoteParameterOptions });
}
},
mounted() {
@@ -1255,7 +1257,7 @@ export default defineComponent({
);
}
void this.$externalHooks().run('parameterInput.mount', {
void this.externalHooks.run('parameterInput.mount', {
parameter: this.parameter,
inputFieldRef: this.$refs.inputField as InstanceType<typeof N8nInput>,
});