mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 13:23:14 +01:00
* feat: begin upgrading deps, still very buggy * feat: progress * feat: sort all type issues * fix: sort type issues * fix: import sonner styles * fix: nuxt is the enemy * fix: try sorting issue with workflows * fix: update vitest config for dynamic import of path and defineConfig * fix: add missing import * fix: add time out to try and fix issues * fix: add ui:ci:preview task for frontend build in CI mode * fix: i was silly * feat: add go:ci:with-frontend task for CI mode and remove ui:ci:preview from e2e workflow * fix: update baseURL in Playwright config for local testing to use port 7745 * fix: update E2E_BASE_URL and remove wait for timeout in login test for smoother execution
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
import type { UseConfirmDialogReturn, UseConfirmDialogRevealResult } from "@vueuse/core";
|
|
import type { Ref } from "vue";
|
|
|
|
type Store = UseConfirmDialogReturn<any, boolean, boolean> & {
|
|
text: Ref<string>;
|
|
setup: boolean;
|
|
open: (text: string) => Promise<UseConfirmDialogRevealResult<boolean, boolean>>;
|
|
};
|
|
|
|
const store: Partial<Store> = {
|
|
text: ref("Are you sure you want to delete this item? "),
|
|
setup: false,
|
|
};
|
|
|
|
/**
|
|
* This function is used to wrap the ModalConfirmation which is a "Singleton" component
|
|
* that is used to confirm actions. It's mounded once on the root of the page and reused
|
|
* for every confirmation action that is required.
|
|
*
|
|
* This is in an experimental phase of development and may have unknown or unexpected side effects.
|
|
*/
|
|
export function useConfirm(): Store {
|
|
if (!store.setup) {
|
|
store.setup = true;
|
|
|
|
const { isRevealed, reveal, confirm, cancel } = useConfirmDialog<any, boolean, boolean>();
|
|
store.isRevealed = isRevealed;
|
|
store.reveal = reveal;
|
|
store.confirm = confirm;
|
|
store.cancel = cancel;
|
|
}
|
|
|
|
async function openDialog(msg: string): Promise<UseConfirmDialogRevealResult<boolean, boolean>> {
|
|
if (!store.reveal) {
|
|
throw new Error("reveal is not defined");
|
|
}
|
|
if (!store.text) {
|
|
throw new Error("text is not defined");
|
|
}
|
|
|
|
store.text.value = msg;
|
|
return await store.reveal();
|
|
}
|
|
|
|
return {
|
|
...(store as Store),
|
|
open: openDialog,
|
|
};
|
|
}
|