diff --git a/frontend/app/components/modules/collection/components/details/header.vue b/frontend/app/components/modules/collection/components/details/header.vue index e1ed84b5..aa7968af 100644 --- a/frontend/app/components/modules/collection/components/details/header.vue +++ b/frontend/app/components/modules/collection/components/details/header.vue @@ -121,7 +121,7 @@ SPDX-License-Identifier: MIT /> Share + + + + + + + + Delete + + @@ -216,18 +239,34 @@ SPDX-License-Identifier: MIT + + + + + + Deleting collection... + + + + diff --git a/frontend/app/components/shared/modules/confirm/components/confirm-modal.vue b/frontend/app/components/shared/modules/confirm/components/confirm-modal.vue new file mode 100644 index 00000000..0b220a9d --- /dev/null +++ b/frontend/app/components/shared/modules/confirm/components/confirm-modal.vue @@ -0,0 +1,85 @@ + + + + + + + {{ options.title }} + + + + + + {{ options.message }} + + + + + + + + + + + + + diff --git a/frontend/app/components/shared/modules/confirm/store/confirm.store.ts b/frontend/app/components/shared/modules/confirm/store/confirm.store.ts new file mode 100644 index 00000000..9c5d7c29 --- /dev/null +++ b/frontend/app/components/shared/modules/confirm/store/confirm.store.ts @@ -0,0 +1,59 @@ +// Copyright (c) 2025 The Linux Foundation and each contributor. +// SPDX-License-Identifier: MIT +import { defineStore } from 'pinia'; +import { ref } from 'vue'; + +export interface ConfirmOptions { + title?: string; + message: string; + confirmLabel?: string; + cancelLabel?: string; +} + +const defaultOptions: ConfirmOptions = { + title: 'Confirm', + message: '', + confirmLabel: 'Ok', + cancelLabel: 'Cancel', +}; + +export const useConfirmStore = defineStore('confirm', () => { + const isConfirmModalOpen = ref(false); + const confirmOptions = ref(defaultOptions); + const resolvePromise = ref<((value: boolean) => void) | null>(null); + + const openConfirmModal = (options: ConfirmOptions): Promise => { + // Auto-cancel any pending confirm to prevent orphaned Promises + if (resolvePromise.value) { + resolvePromise.value(false); + resolvePromise.value = null; + } + + confirmOptions.value = { ...defaultOptions, ...options }; + isConfirmModalOpen.value = true; + + return new Promise((resolve) => { + resolvePromise.value = resolve; + }); + }; + + const confirm = () => { + isConfirmModalOpen.value = false; + resolvePromise.value?.(true); + resolvePromise.value = null; + }; + + const cancel = () => { + isConfirmModalOpen.value = false; + resolvePromise.value?.(false); + resolvePromise.value = null; + }; + + return { + isConfirmModalOpen, + confirmOptions, + openConfirmModal, + confirm, + cancel, + }; +}); diff --git a/frontend/app/layouts/default.vue b/frontend/app/layouts/default.vue index 04c767cd..8f623821 100644 --- a/frontend/app/layouts/default.vue +++ b/frontend/app/layouts/default.vue @@ -19,6 +19,7 @@ SPDX-License-Identifier: MIT + @@ -37,6 +38,7 @@ import LfDuplicateCollectionGlobal from '~/components/modules/collection/compone import LfxAddToCollectionGlobal from '~/components/modules/collection/components/add-to-collection-modal/add-to-collection-global.vue'; import LfxCopilotGlobal from '~/components/shared/modules/copilot/components/copilot-global.vue'; import LfxCommunityFilterGlobal from '~/components/modules/project/components/community/sections/community-filter-global.vue'; +import LfxConfirmGlobal from '~/components/shared/modules/confirm/components/confirm-global.vue'; import { useRichSchema } from '~~/composables/useRichSchema'; import { useBannerStore } from '~/components/shared/store/banner.store';
Deleting collection...
+ {{ options.message }} +