Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add showCancel prop for dialog component #4302

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion console/packages/components/src/components/dialog/Dialog.vue
Expand Up @@ -19,6 +19,7 @@ const props = withDefaults(
description?: string;
confirmText?: string;
confirmType?: ButtonType;
showCancel?: boolean;
cancelText?: string;
visible?: boolean;
onConfirm?: () => void;
Expand All @@ -30,6 +31,7 @@ const props = withDefaults(
description: "",
confirmText: "确定",
confirmType: "primary",
showCancel: true,
cancelText: "取消",
visible: false,
onConfirm: () => {
Expand Down Expand Up @@ -126,7 +128,9 @@ const handleClose = () => {
<VButton :loading="loading" :type="confirmType" @click="handleConfirm">
{{ confirmText }}
</VButton>
<VButton @click="handleCancel">{{ cancelText }}</VButton>
<VButton v-if="showCancel" @click="handleCancel">
{{ cancelText }}
</VButton>
</div>
</template>
</VModal>
Expand Down
18 changes: 6 additions & 12 deletions console/packages/components/src/components/dialog/interface.ts
Expand Up @@ -2,28 +2,22 @@ export type Type = "success" | "info" | "warning" | "error";
export const DialogProviderProvideKey = "DIALOG_PROVIDER_PROVIDE_KEY";
import type { Type as ButtonType } from "../button/interface";

export interface useDialogOptions {
type?: Type;
visible: boolean;
title: string;
description?: string;
confirmType?: ButtonType;
confirmText?: string;
cancelText?: string;
onConfirm?: () => void;
onCancel?: () => void;
}

export interface DialogProps {
type?: Type;
visible?: boolean;
title?: string;
description?: string;
confirmType?: ButtonType;
showCancel?: boolean;
confirmText?: string;
cancelText?: string;
onConfirm?: () => void;
onCancel?: () => void;
}

type useDialogOptions = Omit<DialogProps, "visible" | "title"> & {
visible: boolean;
title: string;
};

export type useDialogUserOptions = Omit<useDialogOptions, "type" | "visible">;
5 changes: 1 addition & 4 deletions console/src/modules/contents/pages/SinglePageEditor.vue
Expand Up @@ -257,13 +257,10 @@ const handleFetchContent = async () => {
raw_type: data.rawType,
}),
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
showCancel: false,
onConfirm: () => {
router.back();
},
onCancel: () => {
router.back();
},
});
}
await nextTick();
Expand Down
5 changes: 1 addition & 4 deletions console/src/modules/contents/posts/PostEditor.vue
Expand Up @@ -269,13 +269,10 @@ const handleFetchContent = async () => {
raw_type: data.rawType,
}),
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
showCancel: false,
onConfirm: () => {
router.back();
},
onCancel: () => {
router.back();
},
});
}

Expand Down
5 changes: 1 addition & 4 deletions console/src/modules/system/backup/tabs/Restore.vue
Expand Up @@ -16,13 +16,10 @@ const onUploaded = () => {
title: t("core.backup.operations.restore.title"),
description: t("core.backup.operations.restore.description"),
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
showCancel: false,
async onConfirm() {
await handleShutdown();
},
async onCancel() {
await handleShutdown();
},
});
};

Expand Down