mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 20:29:08 +00:00
fix(editor): Fix delete variable dialog actions (no-changelog) (#6935)
* fix: fix delete variable dialog actions * fix: small code changes * fix: fix linting issue
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import type { ElMessageBoxOptions } from 'element-plus';
|
import type { ElMessageBoxOptions } from 'element-plus';
|
||||||
import { ElMessageBox as MessageBox } from 'element-plus';
|
import { ElMessageBox as MessageBox } from 'element-plus';
|
||||||
|
|
||||||
|
export type MessageBoxConfirmResult = 'confirm' | 'cancel';
|
||||||
|
|
||||||
export function useMessage() {
|
export function useMessage() {
|
||||||
const handleCancelOrClose = (e: unknown) => {
|
const handleCancelOrClose = (e: unknown) => {
|
||||||
if (e instanceof Error) throw e;
|
if (e instanceof Error) throw e;
|
||||||
@@ -28,7 +30,7 @@ export function useMessage() {
|
|||||||
message: string,
|
message: string,
|
||||||
configOrTitle?: string | ElMessageBoxOptions,
|
configOrTitle?: string | ElMessageBoxOptions,
|
||||||
config?: ElMessageBoxOptions,
|
config?: ElMessageBoxOptions,
|
||||||
) {
|
): Promise<MessageBoxConfirmResult> {
|
||||||
const resolvedConfig = {
|
const resolvedConfig = {
|
||||||
...(config || (typeof configOrTitle === 'object' ? configOrTitle : {})),
|
...(config || (typeof configOrTitle === 'object' ? configOrTitle : {})),
|
||||||
cancelButtonClass: 'btn--cancel',
|
cancelButtonClass: 'btn--cancel',
|
||||||
@@ -39,9 +41,13 @@ export function useMessage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (typeof configOrTitle === 'string') {
|
if (typeof configOrTitle === 'string') {
|
||||||
return MessageBox.confirm(message, configOrTitle, resolvedConfig).catch(handleCancelOrClose);
|
return MessageBox.confirm(message, configOrTitle, resolvedConfig).catch(
|
||||||
|
handleCancelOrClose,
|
||||||
|
) as unknown as Promise<MessageBoxConfirmResult>;
|
||||||
}
|
}
|
||||||
return MessageBox.confirm(message, resolvedConfig).catch(handleCancelOrClose);
|
return MessageBox.confirm(message, resolvedConfig).catch(
|
||||||
|
handleCancelOrClose,
|
||||||
|
) as unknown as Promise<MessageBoxConfirmResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function prompt(
|
async function prompt(
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { useI18n, useTelemetry, useToast, useMessage } from '@/composables';
|
|||||||
import ResourcesListLayout from '@/components/layouts/ResourcesListLayout.vue';
|
import ResourcesListLayout from '@/components/layouts/ResourcesListLayout.vue';
|
||||||
import VariablesRow from '@/components/VariablesRow.vue';
|
import VariablesRow from '@/components/VariablesRow.vue';
|
||||||
|
|
||||||
import { EnterpriseEditionFeature } from '@/constants';
|
import { EnterpriseEditionFeature, MODAL_CONFIRM } from '@/constants';
|
||||||
import type {
|
import type {
|
||||||
DatatableColumn,
|
DatatableColumn,
|
||||||
EnvironmentVariable,
|
EnvironmentVariable,
|
||||||
@@ -183,7 +183,7 @@ function cancelEditing(data: EnvironmentVariable | TemporaryEnvironmentVariable)
|
|||||||
|
|
||||||
async function deleteVariable(data: EnvironmentVariable) {
|
async function deleteVariable(data: EnvironmentVariable) {
|
||||||
try {
|
try {
|
||||||
await message.confirm(
|
const confirmed = await message.confirm(
|
||||||
i18n.baseText('variables.modals.deleteConfirm.message', { interpolate: { name: data.key } }),
|
i18n.baseText('variables.modals.deleteConfirm.message', { interpolate: { name: data.key } }),
|
||||||
i18n.baseText('variables.modals.deleteConfirm.title'),
|
i18n.baseText('variables.modals.deleteConfirm.title'),
|
||||||
{
|
{
|
||||||
@@ -191,11 +191,11 @@ async function deleteVariable(data: EnvironmentVariable) {
|
|||||||
cancelButtonText: i18n.baseText('variables.modals.deleteConfirm.cancelButton'),
|
cancelButtonText: i18n.baseText('variables.modals.deleteConfirm.cancelButton'),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
if (confirmed !== MODAL_CONFIRM) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await environmentsStore.deleteVariable(data);
|
await environmentsStore.deleteVariable(data);
|
||||||
allVariables.value = allVariables.value.filter((variable) => variable.id !== data.id);
|
allVariables.value = allVariables.value.filter((variable) => variable.id !== data.id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user