MCPcopy
hub / github.com/callumalpass/tasknotes / ConfirmationModal

Class ConfirmationModal

src/modals/ConfirmationModal.ts:19–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 * Generic confirmation modal for user confirmations
18 */
19export class ConfirmationModal extends Modal {
20 private options: ConfirmationModalOptions;
21 private resolve: (confirmed: boolean) => void;
22
23 constructor(app: App, options: ConfirmationModalOptions) {
24 super(app);
25 this.options = {
26 confirmText: "Confirm",
27 cancelText: "Cancel",
28 isDestructive: false,
29 ...options,
30 };
31 }
32
33 public show(): Promise<boolean> {
34 return new Promise((resolve) => {
35 this.resolve = resolve;
36 this.open();
37 });
38 }
39
40 onOpen() {
41 const { contentEl } = this;
42 contentEl.empty();
43
44 new Setting(contentEl).setName(this.options.title).setHeading();
45
46 contentEl.createEl("p", { text: this.options.message });
47
48 const buttonContainer = contentEl.createEl("div", { cls: "modal-button-container" });
49 buttonContainer.classList.remove(
50 "tn-static-display-block-2a1b75c9",
51 "tn-static-display-flex-4d51fc62",
52 "tn-static-display-flex-8bb39979",
53 "tn-static-display-inline-block-60e32dcb",
54 "tn-static-display-inline-cccfa456",
55 "tn-static-display-inline-flex-f984c520",
56 "tn-static-display-none-6b99de8b",
57 "tn-static-min-height-800px-997b4c8c"
58 );
59 buttonContainer.classList.add("tn-static-display-flex-75816cae");
60 buttonContainer.classList.remove(
61 "tn-static-display-flex-8bb39979",
62 "tn-static-gap-0-5rem-ce2fca4d",
63 "tn-static-gap-12px-ed7b3d87",
64 "tn-static-gap-6px-f0abc1db",
65 "tn-static-gap-8px-33fcd4c3"
66 );
67 buttonContainer.classList.add("tn-static-gap-10px-f3d7ce77");
68 buttonContainer.classList.remove(
69 "tn-static-justify-content-center-03c4bb6f",
70 "tn-static-justify-content-space-between-a562f4fd"
71 );
72 buttonContainer.classList.add("tn-static-justify-content-flex-end-455f8cca");
73 buttonContainer.classList.remove(
74 "tn-static-font-size-12px-b0cc7e05",
75 "tn-static-margin-top-0-5rem-3dc98b5e",
76 "tn-static-margin-top-0-d462248a",

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected