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

@@ -328,7 +328,7 @@ import Vue from 'vue';
import { externalHooks } from '@/mixins/externalHooks';
import { genericHelpers } from '@/mixins/genericHelpers';
import { showMessage } from '@/mixins/showMessage';
import { useToast } from '@/composables';
import type {
ITimeoutHMS,
IUser,
@@ -337,12 +337,12 @@ import type {
IWorkflowSettings,
IWorkflowShortResponse,
} from '@/Interface';
import Modal from './Modal.vue';
import Modal from '@/components/Modal.vue';
import {
EnterpriseEditionFeature,
PLACEHOLDER_EMPTY_WORKFLOW_ID,
WORKFLOW_SETTINGS_MODAL_KEY,
} from '../constants';
} from '@/constants';
import mixins from 'vue-typed-mixins';
@@ -356,11 +356,16 @@ import useWorkflowsEEStore from '@/stores/workflows.ee.store';
import { useUsersStore } from '@/stores/users.store';
import { createEventBus } from '@/event-bus';
export default mixins(externalHooks, genericHelpers, showMessage).extend({
export default mixins(externalHooks, genericHelpers).extend({
name: 'WorkflowSettings',
components: {
Modal,
},
setup() {
return {
...useToast(),
};
},
data() {
return {
isLoading: true,
@@ -448,7 +453,7 @@ export default mixins(externalHooks, genericHelpers, showMessage).extend({
this.maxExecutionTimeout = this.rootStore.maxExecutionTimeout;
if (!this.workflowId || this.workflowId === PLACEHOLDER_EMPTY_WORKFLOW_ID) {
this.$showMessage({
this.showMessage({
title: 'No workflow active',
message: 'No workflow active to display settings of.',
type: 'error',
@@ -477,7 +482,7 @@ export default mixins(externalHooks, genericHelpers, showMessage).extend({
try {
await Promise.all(promises);
} catch (error) {
this.$showError(
this.showError(
error,
'Problem loading settings',
'The following error occurred loading the data:',
@@ -516,7 +521,9 @@ export default mixins(externalHooks, genericHelpers, showMessage).extend({
this.timeoutHMS = this.convertToHMS(workflowSettings.executionTimeout);
this.isLoading = false;
this.$externalHooks().run('workflowSettings.dialogVisibleChanged', { dialogVisible: true });
void this.$externalHooks().run('workflowSettings.dialogVisibleChanged', {
dialogVisible: true,
});
this.$telemetry.track('User opened workflow settings', {
workflow_id: this.workflowsStore.workflowId,
});
@@ -529,7 +536,9 @@ export default mixins(externalHooks, genericHelpers, showMessage).extend({
},
closeDialog() {
this.modalBus.emit('close');
this.$externalHooks().run('workflowSettings.dialogVisibleChanged', { dialogVisible: false });
void this.$externalHooks().run('workflowSettings.dialogVisibleChanged', {
dialogVisible: false,
});
},
setTimeout(key: string, value: string) {
const time = value ? parseInt(value, 10) : 0;
@@ -754,7 +763,7 @@ export default mixins(externalHooks, genericHelpers, showMessage).extend({
data.settings!.executionTimeout !== -1 ? hours * 3600 + minutes * 60 + seconds : -1;
if (data.settings!.executionTimeout === 0) {
this.$showError(
this.showError(
new Error(this.$locale.baseText('workflowSettings.showError.saveSettings1.errorMessage')),
this.$locale.baseText('workflowSettings.showError.saveSettings1.title'),
this.$locale.baseText('workflowSettings.showError.saveSettings1.message') + ':',
@@ -767,7 +776,7 @@ export default mixins(externalHooks, genericHelpers, showMessage).extend({
const { hours, minutes, seconds } = this.convertToHMS(
this.workflowSettings.maxExecutionTimeout as number,
);
this.$showError(
this.showError(
new Error(
this.$locale.baseText('workflowSettings.showError.saveSettings2.errorMessage', {
interpolate: {
@@ -791,7 +800,7 @@ export default mixins(externalHooks, genericHelpers, showMessage).extend({
const workflow = await this.workflowsStore.updateWorkflow(this.$route.params.name, data);
this.workflowsStore.setWorkflowVersionId(workflow.versionId);
} catch (error) {
this.$showError(
this.showError(
error,
this.$locale.baseText('workflowSettings.showError.saveSettings3.title'),
);
@@ -813,14 +822,14 @@ export default mixins(externalHooks, genericHelpers, showMessage).extend({
this.isLoading = false;
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('workflowSettings.showMessage.saveSettings.title'),
type: 'success',
});
this.closeDialog();
this.$externalHooks().run('workflowSettings.saveSettings', { oldSettings });
void this.$externalHooks().run('workflowSettings.saveSettings', { oldSettings });
this.$telemetry.track('User updated workflow settings', {
workflow_id: this.workflowsStore.workflowId,
});