refactor(editor): Turn showMessage mixin to composable (#6081) (#6244)

* refactor(editor): Turn showMessage mixin to composable (#6081)

* refactor(editor): move $getExecutionError from showMessages mixin to pushConnection (it is used there only)

* refactor(editor): resolve showMessage mixin methods

* fix(editor): use composable instead of mixin

* fix(editor): resolve conflicts

* fix(editor): replace clearAllStickyNotifications

* fix(editor): replace confirmMessage

* fix(editor): replace confirmMessage

* fix(editor): replace confirmMessage

* fix(editor): remove last confirmMessage usage

* fix(editor): remove $prompt usage

* fix(editor): remove $show methods

* fix(editor): lint fix

* fix(editor): lint fix

* fix(editor): fixes after review

* fix(editor): Fix external hook call in App

* fix(editor): mixins & composables

* fix: add pushConnection setup composables to components as well

* fix(editor): mixins & composables

* fix(editor): mixins & composables

* fix: add void on non-await async calls

* fix: fix close without connecting confirmation

* fix: remove .only

---------

Co-authored-by: Alex Grozav <alex@grozav.com>
This commit is contained in:
Csaba Tuncsik
2023-05-15 18:41:13 +02:00
committed by GitHub
parent f1598d6fdc
commit 51fb913d37
80 changed files with 1126 additions and 978 deletions

View File

@@ -18,10 +18,10 @@
</template>
<script lang="ts">
import { WEBHOOK_NODE_TYPE, MANUAL_TRIGGER_NODE_TYPE } from '@/constants';
import { WEBHOOK_NODE_TYPE, MANUAL_TRIGGER_NODE_TYPE, MODAL_CONFIRM } from '@/constants';
import type { INodeUi } from '@/Interface';
import type { INodeTypeDescription } from 'n8n-workflow';
import mixins from 'vue-typed-mixins';
import { defineComponent } from 'vue';
import { workflowRun } from '@/mixins/workflowRun';
import { pinData } from '@/mixins/pinData';
import { dataPinningEventBus } from '@/event-bus';
@@ -29,8 +29,10 @@ import { mapStores } from 'pinia';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { useNDVStore } from '@/stores/ndv.store';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { useToast, useMessage } from '@/composables';
export default mixins(workflowRun, pinData).extend({
export default defineComponent({
mixins: [workflowRun, pinData],
props: {
nodeName: {
type: String,
@@ -56,6 +58,13 @@ export default mixins(workflowRun, pinData).extend({
type: String,
},
},
setup(props) {
return {
...useToast(),
...useMessage(),
...workflowRun.setup?.(props),
};
},
computed: {
...mapStores(useNodeTypesStore, useNDVStore, useWorkflowsStore),
node(): INodeUi | null {
@@ -173,7 +182,7 @@ export default mixins(workflowRun, pinData).extend({
try {
await this.workflowsStore.removeTestWebhook(this.workflowsStore.workflowId);
} catch (error) {
this.$showError(error, this.$locale.baseText('ndv.execute.stopWaitingForWebhook.error'));
this.showError(error, this.$locale.baseText('ndv.execute.stopWaitingForWebhook.error'));
return;
}
},
@@ -186,13 +195,15 @@ export default mixins(workflowRun, pinData).extend({
} else {
let shouldUnpinAndExecute = false;
if (this.hasPinData) {
shouldUnpinAndExecute = await this.confirmMessage(
const confirmResult = await this.confirm(
this.$locale.baseText('ndv.pinData.unpinAndExecute.description'),
this.$locale.baseText('ndv.pinData.unpinAndExecute.title'),
null,
this.$locale.baseText('ndv.pinData.unpinAndExecute.confirm'),
this.$locale.baseText('ndv.pinData.unpinAndExecute.cancel'),
{
confirmButtonText: this.$locale.baseText('ndv.pinData.unpinAndExecute.confirm'),
cancelButtonText: this.$locale.baseText('ndv.pinData.unpinAndExecute.cancel'),
},
);
shouldUnpinAndExecute = confirmResult === MODAL_CONFIRM;
if (shouldUnpinAndExecute) {
dataPinningEventBus.emit('data-unpinning', { source: 'unpin-and-execute-modal' });