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
This commit is contained in:
Csaba Tuncsik
2023-05-12 10:13:42 +02:00
committed by GitHub
parent 0666377ef8
commit b95fcd7323
75 changed files with 990 additions and 862 deletions

View File

@@ -27,7 +27,7 @@ import ExecutionsSidebar from '@/components/ExecutionsView/ExecutionsSidebar.vue
import {
MAIN_HEADER_TABS,
MODAL_CANCEL,
MODAL_CONFIRMED,
MODAL_CONFIRM,
PLACEHOLDER_EMPTY_WORKFLOW_ID,
VIEWS,
WEBHOOK_NODE_TYPE,
@@ -49,7 +49,7 @@ import type {
} from 'n8n-workflow';
import { NodeHelpers } from 'n8n-workflow';
import mixins from 'vue-typed-mixins';
import { showMessage } from '@/mixins/showMessage';
import { useToast, useMessage } from '@/composables';
import { v4 as uuid } from 'uuid';
import type { Route } from 'vue-router';
import { executionHelpers } from '@/mixins/executionsHelpers';
@@ -70,7 +70,7 @@ const MAX_LOADING_ATTEMPTS = 5;
// Number of executions fetched on each page
const LOAD_MORE_PAGE_SIZE = 100;
export default mixins(showMessage, executionHelpers, debounceHelper, workflowHelpers).extend({
export default mixins(executionHelpers, debounceHelper, workflowHelpers).extend({
name: 'executions-list',
components: {
ExecutionsSidebar,
@@ -83,6 +83,12 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
temporaryExecution: null as IExecutionsSummary | null,
};
},
setup() {
return {
...useToast(),
...useMessage(),
};
},
computed: {
...mapStores(useTagsStore, useNodeTypesStore, useSettingsStore, useUIStore, useWorkflowsStore),
hidePreview(): boolean {
@@ -132,16 +138,22 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
return;
}
if (this.uiStore.stateIsDirty) {
const confirmModal = await this.confirmModal(
const confirmModal = await this.confirm(
this.$locale.baseText('generic.unsavedWork.confirmMessage.message'),
this.$locale.baseText('generic.unsavedWork.confirmMessage.headline'),
'warning',
this.$locale.baseText('generic.unsavedWork.confirmMessage.confirmButtonText'),
this.$locale.baseText('generic.unsavedWork.confirmMessage.cancelButtonText'),
true,
{
title: this.$locale.baseText('generic.unsavedWork.confirmMessage.headline'),
type: 'warning',
confirmButtonText: this.$locale.baseText(
'generic.unsavedWork.confirmMessage.confirmButtonText',
),
cancelButtonText: this.$locale.baseText(
'generic.unsavedWork.confirmMessage.cancelButtonText',
),
showClose: true,
},
);
if (confirmModal === MODAL_CONFIRMED) {
if (confirmModal === MODAL_CONFIRM) {
const saved = await this.saveCurrentWorkflow({}, false);
if (saved) {
await this.settingsStore.fetchPromptsData();
@@ -221,7 +233,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
data = await this.workflowsStore.getPastExecutions(this.requestFilter, limit, lastId);
} catch (error) {
this.loadingMore = false;
this.$showError(error, this.$locale.baseText('executionsList.showError.loadMore.title'));
this.showError(error, this.$locale.baseText('executionsList.showError.loadMore.title'));
return;
}
@@ -276,7 +288,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
await this.setExecutions();
} catch (error) {
this.loading = false;
this.$showError(
this.showError(
error,
this.$locale.baseText('executionsList.showError.handleDeleteSelected.title'),
);
@@ -284,7 +296,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
}
this.loading = false;
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('executionsList.showMessage.handleDeleteSelected.title'),
type: 'success',
});
@@ -295,7 +307,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
try {
await this.workflowsStore.stopCurrentExecution(activeExecutionId);
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('executionsList.showMessage.stopExecution.title'),
message: this.$locale.baseText('executionsList.showMessage.stopExecution.message', {
interpolate: { activeExecutionId },
@@ -305,7 +317,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
await this.loadAutoRefresh();
} catch (error) {
this.$showError(
this.showError(
error,
this.$locale.baseText('executionsList.showError.stopExecution.title'),
);
@@ -399,7 +411,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
return await this.workflowsStore.loadCurrentWorkflowExecutions(this.requestFilter);
} catch (error) {
if (error.errorCode === NO_NETWORK_ERROR_CODE) {
this.$showMessage(
this.showMessage(
{
title: this.$locale.baseText('executionsList.showError.refreshData.title'),
message: error.message,
@@ -409,7 +421,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
false,
);
} else {
this.$showError(
this.showError(
error,
this.$locale.baseText('executionsList.showError.refreshData.title'),
);
@@ -449,7 +461,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
const existingExecution = await this.workflowsStore.fetchExecutionDataById(executionId);
if (!existingExecution) {
this.workflowsStore.activeWorkflowExecution = null;
this.$showError(
this.showError(
new Error(
this.$locale.baseText('executionView.notFound.message', {
interpolate: { executionId },
@@ -493,7 +505,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
try {
data = await this.workflowsStore.fetchWorkflow(workflowId);
} catch (error) {
this.$showError(error, this.$locale.baseText('nodeView.showError.openWorkflow.title'));
this.showError(error, this.$locale.baseText('nodeView.showError.openWorkflow.title'));
return;
}
if (data === undefined) {
@@ -642,7 +654,7 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
async onRetryExecution(payload: { execution: IExecutionsSummary; command: string }) {
const loadWorkflow = payload.command === 'current-workflow';
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('executionDetails.runningMessage'),
type: 'info',
duration: 2000,
@@ -664,18 +676,18 @@ export default mixins(showMessage, executionHelpers, debounceHelper, workflowHel
);
if (retrySuccessful === true) {
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('executionsList.showMessage.retrySuccessfulTrue.title'),
type: 'success',
});
} else {
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('executionsList.showMessage.retrySuccessfulFalse.title'),
type: 'error',
});
}
} catch (error) {
this.$showError(
this.showError(
error,
this.$locale.baseText('executionsList.showError.retryExecution.title'),
);