mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Do not show success message if there is an error saving credentials (no-changelog) (#11548)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
This commit is contained in:
parent
e80f7e0a02
commit
981a852648
|
@ -36,7 +36,7 @@ import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||||
import { useSettingsStore } from '@/stores/settings.store';
|
import { useSettingsStore } from '@/stores/settings.store';
|
||||||
import { useUIStore } from '@/stores/ui.store';
|
import { useUIStore } from '@/stores/ui.store';
|
||||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||||
import type { ProjectSharingData } from '@/types/projects.types';
|
import type { Project, ProjectSharingData } from '@/types/projects.types';
|
||||||
import { assert } from '@/utils/assert';
|
import { assert } from '@/utils/assert';
|
||||||
import type { IMenuItem } from 'n8n-design-system';
|
import type { IMenuItem } from 'n8n-design-system';
|
||||||
import { createEventBus } from 'n8n-design-system/utils';
|
import { createEventBus } from 'n8n-design-system/utils';
|
||||||
|
@ -680,30 +680,7 @@ async function saveCredential(): Promise<ICredentialsResponse | null> {
|
||||||
const isNewCredential = props.mode === 'new' && !credentialId.value;
|
const isNewCredential = props.mode === 'new' && !credentialId.value;
|
||||||
|
|
||||||
if (isNewCredential) {
|
if (isNewCredential) {
|
||||||
credential = await createCredential(credentialDetails, projectsStore.currentProjectId);
|
credential = await createCredential(credentialDetails, projectsStore.currentProject);
|
||||||
|
|
||||||
let toastTitle = i18n.baseText('credentials.create.personal.toast.title');
|
|
||||||
let toastText = '';
|
|
||||||
|
|
||||||
if (!credentialDetails.sharedWithProjects) {
|
|
||||||
toastText = i18n.baseText('credentials.create.personal.toast.text');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (projectsStore.currentProject) {
|
|
||||||
toastTitle = i18n.baseText('credentials.create.project.toast.title', {
|
|
||||||
interpolate: { projectName: projectsStore.currentProject.name ?? '' },
|
|
||||||
});
|
|
||||||
|
|
||||||
toastText = i18n.baseText('credentials.create.project.toast.text', {
|
|
||||||
interpolate: { projectName: projectsStore.currentProject.name ?? '' },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toast.showMessage({
|
|
||||||
title: toastTitle,
|
|
||||||
message: toastText,
|
|
||||||
type: 'success',
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
if (settingsStore.isEnterpriseFeatureEnabled[EnterpriseEditionFeature.Sharing]) {
|
if (settingsStore.isEnterpriseFeatureEnabled[EnterpriseEditionFeature.Sharing]) {
|
||||||
credentialDetails.sharedWithProjects = credentialData.value
|
credentialDetails.sharedWithProjects = credentialData.value
|
||||||
|
@ -770,15 +747,50 @@ async function saveCredential(): Promise<ICredentialsResponse | null> {
|
||||||
return credential;
|
return credential;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const createToastMessagingForNewCredentials = (
|
||||||
|
credentialDetails: ICredentialsDecrypted,
|
||||||
|
project?: Project | null,
|
||||||
|
) => {
|
||||||
|
let toastTitle = i18n.baseText('credentials.create.personal.toast.title');
|
||||||
|
let toastText = '';
|
||||||
|
|
||||||
|
if (!credentialDetails.sharedWithProjects) {
|
||||||
|
toastText = i18n.baseText('credentials.create.personal.toast.text');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (projectsStore.currentProject) {
|
||||||
|
toastTitle = i18n.baseText('credentials.create.project.toast.title', {
|
||||||
|
interpolate: { projectName: project?.name ?? '' },
|
||||||
|
});
|
||||||
|
|
||||||
|
toastText = i18n.baseText('credentials.create.project.toast.text', {
|
||||||
|
interpolate: { projectName: project?.name ?? '' },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: toastTitle,
|
||||||
|
message: toastText,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
async function createCredential(
|
async function createCredential(
|
||||||
credentialDetails: ICredentialsDecrypted,
|
credentialDetails: ICredentialsDecrypted,
|
||||||
projectId?: string,
|
project?: Project | null,
|
||||||
): Promise<ICredentialsResponse | null> {
|
): Promise<ICredentialsResponse | null> {
|
||||||
let credential;
|
let credential;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
credential = await credentialsStore.createNewCredential(credentialDetails, projectId);
|
credential = await credentialsStore.createNewCredential(credentialDetails, project?.id);
|
||||||
hasUnsavedChanges.value = false;
|
hasUnsavedChanges.value = false;
|
||||||
|
|
||||||
|
const { title, message } = createToastMessagingForNewCredentials(credentialDetails, project);
|
||||||
|
|
||||||
|
toast.showMessage({
|
||||||
|
title,
|
||||||
|
message,
|
||||||
|
type: 'success',
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.showError(
|
toast.showError(
|
||||||
error,
|
error,
|
||||||
|
|
Loading…
Reference in a new issue