mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08: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:
parent
9687410374
commit
775e73e0c3
|
@ -1,6 +1,8 @@
|
|||
import type { ElMessageBoxOptions } from 'element-plus';
|
||||
import { ElMessageBox as MessageBox } from 'element-plus';
|
||||
|
||||
export type MessageBoxConfirmResult = 'confirm' | 'cancel';
|
||||
|
||||
export function useMessage() {
|
||||
const handleCancelOrClose = (e: unknown) => {
|
||||
if (e instanceof Error) throw e;
|
||||
|
@ -28,7 +30,7 @@ export function useMessage() {
|
|||
message: string,
|
||||
configOrTitle?: string | ElMessageBoxOptions,
|
||||
config?: ElMessageBoxOptions,
|
||||
) {
|
||||
): Promise<MessageBoxConfirmResult> {
|
||||
const resolvedConfig = {
|
||||
...(config || (typeof configOrTitle === 'object' ? configOrTitle : {})),
|
||||
cancelButtonClass: 'btn--cancel',
|
||||
|
@ -39,9 +41,13 @@ export function useMessage() {
|
|||
};
|
||||
|
||||
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(
|
||||
|
|
|
@ -12,7 +12,7 @@ import { useI18n, useTelemetry, useToast, useMessage } from '@/composables';
|
|||
import ResourcesListLayout from '@/components/layouts/ResourcesListLayout.vue';
|
||||
import VariablesRow from '@/components/VariablesRow.vue';
|
||||
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
import { EnterpriseEditionFeature, MODAL_CONFIRM } from '@/constants';
|
||||
import type {
|
||||
DatatableColumn,
|
||||
EnvironmentVariable,
|
||||
|
@ -183,7 +183,7 @@ function cancelEditing(data: EnvironmentVariable | TemporaryEnvironmentVariable)
|
|||
|
||||
async function deleteVariable(data: EnvironmentVariable) {
|
||||
try {
|
||||
await message.confirm(
|
||||
const confirmed = await message.confirm(
|
||||
i18n.baseText('variables.modals.deleteConfirm.message', { interpolate: { name: data.key } }),
|
||||
i18n.baseText('variables.modals.deleteConfirm.title'),
|
||||
{
|
||||
|
@ -191,11 +191,11 @@ async function deleteVariable(data: EnvironmentVariable) {
|
|||
cancelButtonText: i18n.baseText('variables.modals.deleteConfirm.cancelButton'),
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (confirmed !== MODAL_CONFIRM) {
|
||||
return;
|
||||
}
|
||||
|
||||
await environmentsStore.deleteVariable(data);
|
||||
allVariables.value = allVariables.value.filter((variable) => variable.id !== data.id);
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in a new issue