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

@@ -9,20 +9,25 @@
</template>
<script lang="ts">
import AuthView from './AuthView.vue';
import { showMessage } from '@/mixins/showMessage';
import AuthView from '@/views/AuthView.vue';
import { useToast } from '@/composables';
import mixins from 'vue-typed-mixins';
import { defineComponent } from 'vue';
import type { IFormBoxConfig } from '@/Interface';
import { VIEWS } from '@/constants';
import { mapStores } from 'pinia';
import { useUsersStore } from '@/stores/users.store';
export default mixins(showMessage).extend({
export default defineComponent({
name: 'ChangePasswordView',
components: {
AuthView,
},
setup() {
return {
...useToast(),
};
},
data() {
return {
password: '',
@@ -88,7 +93,7 @@ export default mixins(showMessage).extend({
await this.usersStore.validatePasswordToken({ token, userId });
} catch (e) {
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('auth.changePassword.tokenValidationError'),
type: 'error',
});
@@ -128,7 +133,7 @@ export default mixins(showMessage).extend({
if (token && userId) {
await this.usersStore.changePassword({ token, userId, password: this.password });
this.$showMessage({
this.showMessage({
type: 'success',
title: this.$locale.baseText('auth.changePassword.passwordUpdated'),
message: this.$locale.baseText('auth.changePassword.passwordUpdatedMessage'),
@@ -136,13 +141,13 @@ export default mixins(showMessage).extend({
await this.$router.push({ name: VIEWS.SIGNIN });
} else {
this.$showError(
this.showError(
new Error(this.$locale.baseText('auth.validation.missingParameters')),
this.$locale.baseText('auth.changePassword.error'),
);
}
} catch (error) {
this.$showError(error, this.$locale.baseText('auth.changePassword.error'));
this.showError(error, this.$locale.baseText('auth.changePassword.error'));
}
this.loading = false;
},

View File

@@ -44,20 +44,12 @@
</template>
<script lang="ts">
import { showMessage } from '@/mixins/showMessage';
import type { ICredentialsResponse, ICredentialTypeMap } from '@/Interface';
import mixins from 'vue-typed-mixins';
import { defineComponent } from 'vue';
import SettingsView from './SettingsView.vue';
import ResourcesListLayout from '@/components/layouts/ResourcesListLayout.vue';
import PageViewLayout from '@/components/layouts/PageViewLayout.vue';
import PageViewLayoutList from '@/components/layouts/PageViewLayoutList.vue';
import CredentialCard from '@/components/CredentialCard.vue';
import type { ICredentialType } from 'n8n-workflow';
import TemplateCard from '@/components/TemplateCard.vue';
import { debounceHelper } from '@/mixins/debounce';
import ResourceOwnershipSelect from '@/components/forms/ResourceOwnershipSelect.ee.vue';
import ResourceFiltersDropdown from '@/components/forms/ResourceFiltersDropdown.vue';
import { CREDENTIAL_SELECT_MODAL_KEY } from '@/constants';
import type Vue from 'vue';
import { mapStores } from 'pinia';
@@ -68,17 +60,11 @@ import { useCredentialsStore } from '@/stores/credentials.store';
type IResourcesListLayoutInstance = Vue & { sendFiltersTelemetry: (source: string) => void };
export default mixins(showMessage, debounceHelper).extend({
export default defineComponent({
name: 'SettingsPersonalView',
components: {
ResourcesListLayout,
TemplateCard,
PageViewLayout,
PageViewLayoutList,
SettingsView,
CredentialCard,
ResourceOwnershipSelect,
ResourceFiltersDropdown,
},
data() {
return {

View File

@@ -4,19 +4,24 @@
<script lang="ts">
import AuthView from './AuthView.vue';
import { showMessage } from '@/mixins/showMessage';
import { useToast } from '@/composables';
import mixins from 'vue-typed-mixins';
import { defineComponent } from 'vue';
import type { IFormBoxConfig } from '@/Interface';
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/settings.store';
import { useUsersStore } from '@/stores/users.store';
export default mixins(showMessage).extend({
export default defineComponent({
name: 'ForgotMyPasswordView',
components: {
AuthView,
},
setup() {
return {
...useToast(),
};
},
data() {
return {
loading: false,
@@ -74,7 +79,7 @@ export default mixins(showMessage).extend({
this.loading = true;
await this.usersStore.sendForgotPasswordEmail(values);
this.$showMessage({
this.showMessage({
type: 'success',
title: this.$locale.baseText('forgotPassword.recoveryEmailSent'),
message: this.$locale.baseText('forgotPassword.emailSentIfExists', {
@@ -86,7 +91,7 @@ export default mixins(showMessage).extend({
if (error.httpStatusCode === 422) {
message = this.$locale.baseText(error.message);
}
this.$showMessage({
this.showMessage({
type: 'error',
title: this.$locale.baseText('forgotPassword.sendingEmailError'),
message,

View File

@@ -186,7 +186,7 @@ import {
MAIN_HEADER_TABS,
MODAL_CANCEL,
MODAL_CLOSE,
MODAL_CONFIRMED,
MODAL_CONFIRM,
NODE_OUTPUT_DEFAULT_KEY,
ONBOARDING_CALL_SIGNUP_MODAL_KEY,
ONBOARDING_PROMPT_TIMEBOX,
@@ -206,13 +206,15 @@ import { copyPaste } from '@/mixins/copyPaste';
import { externalHooks } from '@/mixins/externalHooks';
import { genericHelpers } from '@/mixins/genericHelpers';
import { moveNodeWorkflow } from '@/mixins/moveNodeWorkflow';
import useGlobalLinkActions from '@/composables/useGlobalLinkActions';
import useCanvasMouseSelect from '@/composables/useCanvasMouseSelect';
import { showMessage } from '@/mixins/showMessage';
import { useTitleChange } from '@/composables/useTitleChange';
import {
useGlobalLinkActions,
useCanvasMouseSelect,
useMessage,
useToast,
useTitleChange,
} from '@/composables';
import { useUniqueNodeName } from '@/composables/useUniqueNodeName';
import { useI18n } from '@/composables/useI18n';
import { workflowHelpers } from '@/mixins/workflowHelpers';
import { workflowRun } from '@/mixins/workflowRun';
@@ -322,7 +324,6 @@ export default mixins(
externalHooks,
genericHelpers,
moveNodeWorkflow,
showMessage,
workflowHelpers,
workflowRun,
debounceHelper,
@@ -343,6 +344,8 @@ export default mixins(
...useCanvasMouseSelect(),
...useGlobalLinkActions(),
...useTitleChange(),
...useToast(),
...useMessage(),
...useUniqueNodeName(),
...useI18n(),
};
@@ -415,15 +418,21 @@ export default mixins(
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) {
// Make sure workflow id is empty when leaving the editor
this.workflowsStore.setWorkflowId(PLACEHOLDER_EMPTY_WORKFLOW_ID);
const saved = await this.saveCurrentWorkflow({}, false);
@@ -660,7 +669,7 @@ export default mixins(
this.registerCustomAction('showNodeCreator', () =>
this.showTriggerCreator(NODE_CREATOR_OPEN_SOURCES.NO_TRIGGER_EXECUTION_TOOLTIP),
);
const notice = this.$showMessage({
const notice = this.showMessage({
type: 'info',
title: this.$locale.baseText('nodeView.cantExecuteNoTrigger'),
message,
@@ -688,7 +697,7 @@ export default mixins(
saved = true;
}
if (saved) {
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('generic.workflowSaved'),
type: 'success',
});
@@ -708,7 +717,7 @@ export default mixins(
try {
data = await this.workflowsStore.getExecution(executionId);
} catch (error) {
this.$showError(error, this.$locale.baseText('nodeView.showError.openExecution.title'));
this.showError(error, this.$locale.baseText('nodeView.showError.openExecution.title'));
return;
}
if (data === undefined) {
@@ -766,7 +775,7 @@ export default mixins(
}
}
if ((data as IExecutionsSummary).waitTill) {
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('nodeView.thisExecutionHasntFinishedYet'),
message: `<a data-action="reload">${this.$locale.baseText(
'nodeView.refresh',
@@ -819,7 +828,7 @@ export default mixins(
);
}
} catch (error) {
this.$showError(error, this.$locale.baseText('nodeView.couldntImportWorkflow'));
this.showError(error, this.$locale.baseText('nodeView.couldntImportWorkflow'));
void this.$router.replace({ name: VIEWS.NEW_WORKFLOW });
return;
}
@@ -1030,7 +1039,7 @@ export default mixins(
void this.$router.push({ name: VIEWS.NEW_WORKFLOW });
}
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('nodeView.showMessage.keyDown.title'),
type: 'success',
});
@@ -1305,7 +1314,7 @@ export default mixins(
this.copyToClipboard(nodeData);
if (data.nodes.length > 0) {
if (!isCut) {
this.$showMessage({
this.showMessage({
title: 'Copied!',
message: '',
type: 'success',
@@ -1327,7 +1336,7 @@ export default mixins(
try {
this.stopExecutionInProgress = true;
await this.workflowsStore.stopCurrentExecution(executionId);
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('nodeView.showMessage.stopExecutionTry.title'),
type: 'success',
});
@@ -1346,7 +1355,7 @@ export default mixins(
this.uiStore.removeActiveAction('workflowRunning');
this.titleSet(this.workflowsStore.workflowName, 'IDLE');
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('nodeView.showMessage.stopExecutionCatch.unsaved.title'),
message: this.$locale.baseText(
'nodeView.showMessage.stopExecutionCatch.unsaved.message',
@@ -1373,13 +1382,13 @@ export default mixins(
this.workflowsStore.executingNode = null;
this.workflowsStore.setWorkflowExecutionData(executedData as IExecutionResponse);
this.uiStore.removeActiveAction('workflowRunning');
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('nodeView.showMessage.stopExecutionCatch.title'),
message: this.$locale.baseText('nodeView.showMessage.stopExecutionCatch.message'),
type: 'success',
});
} else {
this.$showError(error, this.$locale.baseText('nodeView.showError.stopExecution.title'));
this.showError(error, this.$locale.baseText('nodeView.showError.stopExecution.title'));
}
}
this.stopExecutionInProgress = false;
@@ -1401,7 +1410,7 @@ export default mixins(
try {
await this.workflowsStore.removeTestWebhook(this.workflowsStore.workflowId);
} catch (error) {
this.$showError(
this.showError(
error,
this.$locale.baseText('nodeView.showError.stopWaitingForWebhook.title'),
);
@@ -1426,19 +1435,23 @@ export default mixins(
return;
}
const importConfirm = await this.confirmMessage(
const importConfirm = await this.confirm(
this.$locale.baseText('nodeView.confirmMessage.receivedCopyPasteData.message', {
interpolate: { plainTextData },
}),
this.$locale.baseText('nodeView.confirmMessage.receivedCopyPasteData.headline'),
'warning',
this.$locale.baseText(
'nodeView.confirmMessage.receivedCopyPasteData.confirmButtonText',
),
this.$locale.baseText('nodeView.confirmMessage.receivedCopyPasteData.cancelButtonText'),
{
type: 'warning',
confirmButtonText: this.$locale.baseText(
'nodeView.confirmMessage.receivedCopyPasteData.confirmButtonText',
),
cancelButtonText: this.$locale.baseText(
'nodeView.confirmMessage.receivedCopyPasteData.cancelButtonText',
),
},
);
if (!importConfirm) {
if (importConfirm !== MODAL_CONFIRM) {
return;
}
@@ -1475,7 +1488,7 @@ export default mixins(
workflowData = await this.workflowsStore.getWorkflowFromUrl(url);
} catch (error) {
this.stopLoading();
this.$showError(
this.showError(
error,
this.$locale.baseText('nodeView.showError.getWorkflowDataFromUrl.title'),
);
@@ -1593,10 +1606,7 @@ export default mixins(
this.workflowsStore.addWorkflowTagIds(tagIds);
}
} catch (error) {
this.$showError(
error,
this.$locale.baseText('nodeView.showError.importWorkflowData.title'),
);
this.showError(error, this.$locale.baseText('nodeView.showError.importWorkflowData.title'));
}
},
onDragOver(event: DragEvent) {
@@ -1660,7 +1670,7 @@ export default mixins(
},
showMaxNodeTypeError(nodeTypeData: INodeTypeDescription) {
const maxNodes = nodeTypeData.maxNodes;
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('nodeView.showMessage.showMaxNodeTypeError.title'),
message: this.$locale.baseText('nodeView.showMessage.showMaxNodeTypeError.message', {
adjustToNumber: maxNodes,
@@ -1770,7 +1780,7 @@ export default mixins(
this.nodeTypesStore.getNodeType(nodeTypeName);
if (nodeTypeData === null) {
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('nodeView.showMessage.addNodeButton.title'),
message: this.$locale.baseText('nodeView.showMessage.addNodeButton.message', {
interpolate: { nodeTypeName },
@@ -2490,15 +2500,21 @@ export default mixins(
} else {
const result = this.uiStore.stateIsDirty;
if (result) {
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();
if (saved) await this.settingsStore.fetchPromptsData();
} else if (confirmModal === MODAL_CLOSE) {
@@ -2515,7 +2531,7 @@ export default mixins(
try {
workflow = await this.workflowsStore.fetchWorkflow(workflowId);
} catch (error) {
this.$showError(error, this.$locale.baseText('openWorkflow.workflowNotFoundError'));
this.showError(error, this.$locale.baseText('openWorkflow.workflowNotFoundError'));
void this.$router.push({
name: VIEWS.NEW_WORKFLOW,
@@ -2999,7 +3015,7 @@ export default mixins(
},
async renameNodePrompt(currentName: string) {
try {
const promptResponsePromise = this.$prompt(
const promptResponsePromise = this.prompt(
this.$locale.baseText('nodeView.prompt.newName') + ':',
this.$locale.baseText('nodeView.prompt.renameNode') + `: ${currentName}`,
{
@@ -3557,7 +3573,7 @@ export default mixins(
'*',
);
}
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('openWorkflow.workflowImportError'),
message: (e as Error).message,
type: 'error',
@@ -3581,7 +3597,7 @@ export default mixins(
'*',
);
}
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('nodeView.showError.openExecution.title'),
message: (e as Error).message,
type: 'error',
@@ -3780,7 +3796,7 @@ export default mixins(
try {
await Promise.all(loadPromises);
} catch (error) {
this.$showError(
this.showError(
error,
this.$locale.baseText('nodeView.showError.mounted1.title'),
this.$locale.baseText('nodeView.showError.mounted1.message') + ':',
@@ -3800,7 +3816,7 @@ export default mixins(
);
}
} catch (error) {
this.$showError(
this.showError(
error,
this.$locale.baseText('nodeView.showError.mounted2.title'),
this.$locale.baseText('nodeView.showError.mounted2.message') + ':',
@@ -3831,7 +3847,7 @@ export default mixins(
if (onboardingResponse.title && onboardingResponse.description) {
setTimeout(async () => {
this.$showToast({
this.showToast({
type: 'info',
title: onboardingResponse.title,
message: onboardingResponse.description,

View File

@@ -75,22 +75,28 @@
</template>
<script lang="ts">
import { showMessage } from '@/mixins/showMessage';
import { defineComponent } from 'vue';
import type { IUser } from '@/Interface';
import mixins from 'vue-typed-mixins';
import { useToast, useMessage } from '@/composables';
import CopyInput from '@/components/CopyInput.vue';
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/settings.store';
import { useRootStore } from '@/stores/n8nRoot.store';
import { useUsersStore } from '@/stores/users.store';
import { DOCS_DOMAIN } from '@/constants';
import { DOCS_DOMAIN, MODAL_CONFIRM } from '@/constants';
export default mixins(showMessage).extend({
export default defineComponent({
name: 'SettingsApiView',
components: {
CopyInput,
},
setup() {
return {
...useToast(),
...useMessage(),
};
},
data() {
return {
loading: false,
@@ -118,14 +124,15 @@ export default mixins(showMessage).extend({
},
methods: {
async showDeleteModal() {
const confirmed = await this.confirmMessage(
const confirmed = await this.confirm(
this.$locale.baseText('settings.api.delete.description'),
this.$locale.baseText('settings.api.delete.title'),
null,
this.$locale.baseText('settings.api.delete.button'),
this.$locale.baseText('generic.cancel'),
{
confirmButtonText: this.$locale.baseText('settings.api.delete.button'),
cancelButtonText: this.$locale.baseText('generic.cancel'),
},
);
if (confirmed) {
if (confirmed === MODAL_CONFIRM) {
await this.deleteApiKey();
}
},
@@ -133,7 +140,7 @@ export default mixins(showMessage).extend({
try {
this.apiKey = (await this.settingsStore.getApiKey()) || '';
} catch (error) {
this.$showError(error, this.$locale.baseText('settings.api.view.error'));
this.showError(error, this.$locale.baseText('settings.api.view.error'));
} finally {
this.mounted = true;
}
@@ -144,7 +151,7 @@ export default mixins(showMessage).extend({
try {
this.apiKey = (await this.settingsStore.createApiKey()) || '';
} catch (error) {
this.$showError(error, this.$locale.baseText('settings.api.create.error'));
this.showError(error, this.$locale.baseText('settings.api.create.error'));
} finally {
this.loading = false;
this.$telemetry.track('User clicked create API key button');
@@ -153,13 +160,13 @@ export default mixins(showMessage).extend({
async deleteApiKey() {
try {
await this.settingsStore.deleteApiKey();
this.$showMessage({
this.showMessage({
title: this.$locale.baseText('settings.api.delete.toast'),
type: 'success',
});
this.apiKey = '';
} catch (error) {
this.$showError(error, this.$locale.baseText('settings.api.delete.error'));
this.showError(error, this.$locale.baseText('settings.api.delete.error'));
} finally {
this.$telemetry.track('User clicked delete API key button');
}

View File

@@ -58,7 +58,7 @@ import {
COMMUNITY_NODES_NPM_INSTALLATION_URL,
} from '@/constants';
import CommunityPackageCard from '@/components/CommunityPackageCard.vue';
import { showMessage } from '@/mixins/showMessage';
import { useToast } from '@/composables';
import { pushConnection } from '@/mixins/pushConnection';
import mixins from 'vue-typed-mixins';
import type { PublicInstalledPackage } from 'n8n-workflow';
@@ -70,11 +70,16 @@ import { useSettingsStore } from '@/stores/settings.store';
const PACKAGE_COUNT_THRESHOLD = 31;
export default mixins(showMessage, pushConnection).extend({
export default mixins(pushConnection).extend({
name: 'SettingsCommunityNodesView',
components: {
CommunityPackageCard,
},
setup() {
return {
...useToast(),
};
},
data() {
return {
loading: false,
@@ -113,7 +118,7 @@ export default mixins(showMessage, pushConnection).extend({
number_of_updates_available: packagesToUpdate.length,
});
} catch (error) {
this.$showError(
this.showError(
error,
this.$locale.baseText('settings.communityNodes.fetchError.title'),
this.$locale.baseText('settings.communityNodes.fetchError.message'),

View File

@@ -143,8 +143,9 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { convertToDisplayDate } from '@/utils';
import { showMessage } from '@/mixins/showMessage';
import { useToast, useMessage } from '@/composables';
import type {
ILdapConfig,
ILdapSyncData,
@@ -153,7 +154,7 @@ import type {
IFormInputs,
IUser,
} from '@/Interface';
import mixins from 'vue-typed-mixins';
import { MODAL_CONFIRM } from '@/constants';
import humanizeDuration from 'humanize-duration';
import type { rowCallbackParams, cellCallbackParams } from 'element-ui/types/table';
@@ -180,11 +181,17 @@ type rowType = rowCallbackParams & tableRow;
type cellType = cellCallbackParams & { property: keyof tableRow };
export default mixins(showMessage).extend({
export default defineComponent({
name: 'SettingsLdapView',
components: {
InfiniteLoading,
},
setup() {
return {
...useToast(),
...useMessage(),
};
},
data() {
return {
dataTable: [] as ILdapSyncTable[],
@@ -301,13 +308,20 @@ export default mixins(showMessage).extend({
try {
if (this.adConfig.loginEnabled === true && newConfiguration.loginEnabled === false) {
saveForm = await this.confirmMessage(
const confirmAction = await this.confirm(
this.$locale.baseText('settings.ldap.confirmMessage.beforeSaveForm.message'),
this.$locale.baseText('settings.ldap.confirmMessage.beforeSaveForm.headline'),
null,
this.$locale.baseText('settings.ldap.confirmMessage.beforeSaveForm.cancelButtonText'),
this.$locale.baseText('settings.ldap.confirmMessage.beforeSaveForm.confirmButtonText'),
{
cancelButtonText: this.$locale.baseText(
'settings.ldap.confirmMessage.beforeSaveForm.cancelButtonText',
),
confirmButtonText: this.$locale.baseText(
'settings.ldap.confirmMessage.beforeSaveForm.confirmButtonText',
),
},
);
saveForm = confirmAction === MODAL_CONFIRM;
}
if (!saveForm) {
@@ -315,13 +329,13 @@ export default mixins(showMessage).extend({
}
this.adConfig = await this.settingsStore.updateLdapConfig(newConfiguration);
this.$showToast({
this.showToast({
title: this.$locale.baseText('settings.ldap.updateConfiguration'),
message: '',
type: 'success',
});
} catch (error) {
this.$showError(error, this.$locale.baseText('settings.ldap.configurationError'));
this.showError(error, this.$locale.baseText('settings.ldap.configurationError'));
} finally {
if (saveForm) {
this.hasAnyChanges = false;
@@ -335,13 +349,13 @@ export default mixins(showMessage).extend({
this.loadingTestConnection = true;
try {
await this.settingsStore.testLdapConnection();
this.$showToast({
this.showToast({
title: this.$locale.baseText('settings.ldap.connectionTest'),
message: this.$locale.baseText('settings.ldap.toast.connection.success'),
type: 'success',
});
} catch (error) {
this.$showToast({
this.showToast({
title: this.$locale.baseText('settings.ldap.connectionTestError'),
message: error.message,
type: 'error',
@@ -354,13 +368,13 @@ export default mixins(showMessage).extend({
this.loadingDryRun = true;
try {
await this.settingsStore.runLdapSync({ type: 'dry' });
this.$showToast({
this.showToast({
title: this.$locale.baseText('settings.ldap.runSync.title'),
message: this.$locale.baseText('settings.ldap.toast.sync.success'),
type: 'success',
});
} catch (error) {
this.$showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
this.showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
} finally {
this.loadingDryRun = false;
await this.reloadLdapSynchronizations();
@@ -370,13 +384,13 @@ export default mixins(showMessage).extend({
this.loadingLiveRun = true;
try {
await this.settingsStore.runLdapSync({ type: 'live' });
this.$showToast({
this.showToast({
title: this.$locale.baseText('settings.ldap.runSync.title'),
message: this.$locale.baseText('settings.ldap.toast.sync.success'),
type: 'success',
});
} catch (error) {
this.$showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
this.showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
} finally {
this.loadingLiveRun = false;
await this.reloadLdapSynchronizations();
@@ -669,7 +683,7 @@ export default mixins(showMessage).extend({
},
];
} catch (error) {
this.$showError(error, this.$locale.baseText('settings.ldap.configurationError'));
this.showError(error, this.$locale.baseText('settings.ldap.configurationError'));
}
},
async getLdapSynchronizations(state: any) {
@@ -688,7 +702,7 @@ export default mixins(showMessage).extend({
}
this.loadingTable = false;
} catch (error) {
this.$showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
this.showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
}
},
async reloadLdapSynchronizations() {
@@ -697,7 +711,7 @@ export default mixins(showMessage).extend({
this.tableKey += 1;
this.dataTable = [];
} catch (error) {
this.$showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
this.showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
}
},
},

View File

@@ -58,18 +58,23 @@
</template>
<script lang="ts">
import { showMessage } from '@/mixins/showMessage';
import { useToast } from '@/composables';
import { CHANGE_PASSWORD_MODAL_KEY } from '@/constants';
import type { IFormInputs, IUser } from '@/Interface';
import { useUIStore } from '@/stores/ui.store';
import { useUsersStore } from '@/stores/users.store';
import { useSettingsStore } from '@/stores/settings.store';
import { mapStores } from 'pinia';
import mixins from 'vue-typed-mixins';
import { defineComponent } from 'vue';
import { createEventBus } from '@/event-bus';
export default mixins(showMessage).extend({
export default defineComponent({
name: 'SettingsPersonalView',
setup() {
return {
...useToast(),
};
},
data() {
return {
hasAnyChanges: false,
@@ -154,14 +159,14 @@ export default mixins(showMessage).extend({
lastName: form.lastName,
email: form.email,
});
this.$showToast({
this.showToast({
title: this.$locale.baseText('settings.personal.personalSettingsUpdated'),
message: '',
type: 'success',
});
this.hasAnyChanges = false;
} catch (e) {
this.$showError(e, this.$locale.baseText('settings.personal.personalSettingsUpdatedError'));
this.showError(e, this.$locale.baseText('settings.personal.personalSettingsUpdatedError'));
}
},
onSaveClick() {

View File

@@ -61,10 +61,10 @@
<script lang="ts">
import { EnterpriseEditionFeature, INVITE_USER_MODAL_KEY, VIEWS } from '@/constants';
import PageAlert from '../components/PageAlert.vue';
import PageAlert from '@/components/PageAlert.vue';
import type { IUser, IUserListAction } from '@/Interface';
import mixins from 'vue-typed-mixins';
import { showMessage } from '@/mixins/showMessage';
import { useToast } from '@/composables';
import { copyPaste } from '@/mixins/copyPaste';
import { mapStores } from 'pinia';
import { useUIStore } from '@/stores/ui.store';
@@ -73,11 +73,16 @@ import { useUsersStore } from '@/stores/users.store';
import { useUsageStore } from '@/stores/usage.store';
import { useSSOStore } from '@/stores/sso.store';
export default mixins(showMessage, copyPaste).extend({
export default mixins(copyPaste).extend({
name: 'SettingsUsersView',
components: {
PageAlert,
},
setup() {
return {
...useToast(),
};
},
async mounted() {
if (!this.usersStore.showUMSetupWarning) {
await this.usersStore.fetchUsers();
@@ -126,7 +131,7 @@ export default mixins(showMessage, copyPaste).extend({
try {
await this.usersStore.reinviteUser({ id: user.id });
this.$showToast({
this.showToast({
type: 'success',
title: this.$locale.baseText('settings.users.inviteResent'),
message: this.$locale.baseText('settings.users.emailSentTo', {
@@ -134,7 +139,7 @@ export default mixins(showMessage, copyPaste).extend({
}),
});
} catch (e) {
this.$showError(e, this.$locale.baseText('settings.users.userReinviteError'));
this.showError(e, this.$locale.baseText('settings.users.userReinviteError'));
}
}
},
@@ -143,7 +148,7 @@ export default mixins(showMessage, copyPaste).extend({
if (user?.inviteAcceptUrl) {
this.copyToClipboard(user.inviteAcceptUrl);
this.$showToast({
this.showToast({
type: 'success',
title: this.$locale.baseText('settings.users.inviteUrlCreated'),
message: this.$locale.baseText('settings.users.inviteUrlCreated.message'),

View File

@@ -10,22 +10,28 @@
<script lang="ts">
import AuthView from './AuthView.vue';
import { showMessage } from '@/mixins/showMessage';
import { defineComponent } from 'vue';
import mixins from 'vue-typed-mixins';
import { useToast, useMessage } from '@/composables';
import type { IFormBoxConfig } from '@/Interface';
import { VIEWS } from '@/constants';
import { MODAL_CONFIRM, VIEWS } from '@/constants';
import { mapStores } from 'pinia';
import { useUIStore } from '@/stores/ui.store';
import { useSettingsStore } from '@/stores/settings.store';
import { useUsersStore } from '@/stores/users.store';
import { useCredentialsStore } from '@/stores/credentials.store';
export default mixins(showMessage).extend({
export default defineComponent({
name: 'SetupView',
components: {
AuthView,
},
setup() {
return {
...useToast(),
...useMessage(),
};
},
async mounted() {
const { credentials, workflows } = await this.usersStore.preOwnerSetup();
this.credentialsCount = credentials;
@@ -126,17 +132,20 @@ export default mixins(showMessage).extend({
interpolate: { workflows, credentials },
})
: workflows || credentials;
return this.confirmMessage(
const confirm = await this.confirm(
this.$locale.baseText('auth.setup.confirmOwnerSetupMessage', {
interpolate: {
entities,
},
}),
this.$locale.baseText('auth.setup.confirmOwnerSetup'),
null,
this.$locale.baseText('auth.setup.createAccount'),
this.$locale.baseText('auth.setup.goBack'),
{
confirmButtonText: this.$locale.baseText('auth.setup.createAccount'),
cancelButtonText: this.$locale.baseText('auth.setup.goBack'),
},
);
return confirm === MODAL_CONFIRM;
},
async onSubmit(values: { [key: string]: string | boolean }) {
try {
@@ -163,19 +172,20 @@ export default mixins(showMessage).extend({
await this.$router.push({ name: VIEWS.USERS_SETTINGS });
}
} catch (error) {
this.$showError(error, this.$locale.baseText('auth.setup.settingUpOwnerError'));
this.showError(error, this.$locale.baseText('auth.setup.settingUpOwnerError'));
}
this.loading = false;
},
async showSkipConfirmation() {
const skip = await this.confirmMessage(
const skip = await this.confirm(
this.$locale.baseText('auth.setup.ownerAccountBenefits'),
this.$locale.baseText('auth.setup.skipOwnerSetupQuestion'),
null,
this.$locale.baseText('auth.setup.skipSetup'),
this.$locale.baseText('auth.setup.goBack'),
{
confirmButtonText: this.$locale.baseText('auth.setup.skipSetup'),
cancelButtonText: this.$locale.baseText('auth.setup.goBack'),
},
);
if (skip) {
if (skip === MODAL_CONFIRM) {
this.onSkip();
}
},

View File

@@ -9,21 +9,26 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import AuthView from './AuthView.vue';
import { showMessage } from '@/mixins/showMessage';
import { useToast } from '@/composables';
import mixins from 'vue-typed-mixins';
import type { IFormBoxConfig } from '@/Interface';
import { VIEWS } from '@/constants';
import { mapStores } from 'pinia';
import { useUsersStore } from '@/stores/users.store';
import { useSettingsStore } from '@/stores/settings.store';
export default mixins(showMessage).extend({
export default defineComponent({
name: 'SigninView',
components: {
AuthView,
},
setup() {
return {
...useToast(),
};
},
data() {
return {
FORM_CONFIG: {} as IFormBoxConfig,
@@ -97,7 +102,7 @@ export default mixins(showMessage).extend({
await this.$router.push({ name: VIEWS.HOMEPAGE });
} catch (error) {
this.$showError(error, this.$locale.baseText('auth.signin.error'));
this.showError(error, this.$locale.baseText('auth.signin.error'));
this.loading = false;
}
},

View File

@@ -2,11 +2,16 @@
import { VIEWS } from '@/constants';
import { mapStores } from 'pinia';
import { useUsersStore } from '@/stores/users.store';
import mixins from 'vue-typed-mixins';
import { showMessage } from '@/mixins/showMessage';
import { defineComponent } from 'vue';
import { useToast } from '@/composables';
export default mixins(showMessage).extend({
export default defineComponent({
name: 'SignoutView',
setup() {
return {
...useToast(),
};
},
computed: {
...mapStores(useUsersStore),
},
@@ -16,7 +21,7 @@ export default mixins(showMessage).extend({
await this.usersStore.logout();
void this.$router.replace({ name: VIEWS.SIGNIN });
} catch (e) {
this.$showError(e, this.$locale.baseText('auth.signout.error'));
this.showError(e, this.$locale.baseText('auth.signout.error'));
}
},
},

View File

@@ -8,21 +8,26 @@
</template>
<script lang="ts">
import AuthView from './AuthView.vue';
import { showMessage } from '@/mixins/showMessage';
import AuthView from '@/views/AuthView.vue';
import { useToast } from '@/composables';
import mixins from 'vue-typed-mixins';
import { defineComponent } from 'vue';
import type { IFormBoxConfig } from '@/Interface';
import { VIEWS } from '@/constants';
import { mapStores } from 'pinia';
import { useUIStore } from '@/stores/ui.store';
import { useUsersStore } from '@/stores/users.store';
export default mixins(showMessage).extend({
export default defineComponent({
name: 'SignupView',
components: {
AuthView,
},
setup() {
return {
...useToast(),
};
},
data() {
const FORM_CONFIG: IFormBoxConfig = {
title: this.$locale.baseText('auth.signup.setupYourAccount'),
@@ -96,7 +101,7 @@ export default mixins(showMessage).extend({
const invite = await this.usersStore.validateSignupToken({ inviteeId, inviterId });
this.inviter = invite.inviter as { firstName: string; lastName: string };
} catch (e) {
this.$showError(e, this.$locale.baseText('auth.signup.tokenValidationError'));
this.showError(e, this.$locale.baseText('auth.signup.tokenValidationError'));
void this.$router.replace({ name: VIEWS.SIGNIN });
}
},
@@ -115,7 +120,7 @@ export default mixins(showMessage).extend({
methods: {
async onSubmit(values: { [key: string]: string | boolean }) {
if (!this.inviterId || !this.inviteeId) {
this.$showError(
this.showError(
new Error(this.$locale.baseText('auth.changePassword.tokenValidationError')),
this.$locale.baseText('auth.signup.setupYourAccountError'),
);
@@ -144,7 +149,7 @@ export default mixins(showMessage).extend({
await this.$router.push({ name: VIEWS.NEW_WORKFLOW });
} catch (error) {
this.$showError(error, this.$locale.baseText('auth.signup.setupYourAccountError'));
this.showError(error, this.$locale.baseText('auth.signup.setupYourAccountError'));
}
this.loading = false;
},

View File

@@ -78,7 +78,7 @@
import CollectionsCarousel from '@/components/CollectionsCarousel.vue';
import TemplateFilters from '@/components/TemplateFilters.vue';
import TemplateList from '@/components/TemplateList.vue';
import TemplatesView from './TemplatesView.vue';
import TemplatesView from '@/views/TemplatesView.vue';
import { genericHelpers } from '@/mixins/genericHelpers';
import type {
@@ -97,6 +97,7 @@ import { useSettingsStore } from '@/stores/settings.store';
import { useUsersStore } from '@/stores/users.store';
import { useTemplatesStore } from '@/stores/templates.store';
import { useUIStore } from '@/stores/ui.store';
import { useToast } from '@/composables';
interface ISearchEvent {
search_string: string;
@@ -114,6 +115,11 @@ export default mixins(genericHelpers, debounceHelper).extend({
TemplateList,
TemplatesView,
},
setup() {
return {
...useToast(),
};
},
data() {
return {
areCategoriesPrepopulated: false,
@@ -287,7 +293,7 @@ export default mixins(genericHelpers, debounceHelper).extend({
search: this.search,
});
} catch (e) {
this.$showMessage({
this.showMessage({
title: 'Error',
message: 'Could not load more workflows',
type: 'error',

View File

@@ -89,17 +89,10 @@
</template>
<script lang="ts">
import { showMessage } from '@/mixins/showMessage';
import mixins from 'vue-typed-mixins';
import SettingsView from './SettingsView.vue';
import { defineComponent } from 'vue';
import ResourcesListLayout from '@/components/layouts/ResourcesListLayout.vue';
import PageViewLayout from '@/components/layouts/PageViewLayout.vue';
import PageViewLayoutList from '@/components/layouts/PageViewLayoutList.vue';
import WorkflowCard from '@/components/WorkflowCard.vue';
import TemplateCard from '@/components/TemplateCard.vue';
import { EnterpriseEditionFeature, VIEWS } from '@/constants';
import { debounceHelper } from '@/mixins/debounce';
import type Vue from 'vue';
import type { ITag, IUser, IWorkflowDb } from '@/Interface';
import TagsDropdown from '@/components/TagsDropdown.vue';
@@ -118,14 +111,10 @@ const StatusFilter = {
ALL: '',
};
const WorkflowsView = mixins(showMessage, debounceHelper).extend({
const WorkflowsView = defineComponent({
name: 'WorkflowsView',
components: {
ResourcesListLayout,
TemplateCard,
PageViewLayout,
PageViewLayoutList,
SettingsView,
WorkflowCard,
TagsDropdown,
},
@@ -157,9 +146,6 @@ const WorkflowsView = mixins(showMessage, debounceHelper).extend({
isShareable(): boolean {
return this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Sharing);
},
hasActiveWorkflows(): boolean {
return !!this.workflowsStore.activeWorkflows.length;
},
statusFilterOptions(): Array<{ label: string; value: string | boolean }> {
return [
{