-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodals.ts
More file actions
45 lines (36 loc) · 1.08 KB
/
modals.ts
File metadata and controls
45 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { App, Modal } from "obsidian";
import { t } from "./i18n";
export class RevertConfirmModal extends Modal {
private files: string[];
private onConfirm: () => void;
constructor(app: App, files: string[], onConfirm: () => void) {
super(app);
this.files = files;
this.onConfirm = onConfirm;
}
onOpen() {
const i18n = t();
const { contentEl } = this;
this.setTitle(i18n.revertConfirmTitle);
contentEl.createEl("p", { text: i18n.revertConfirmDesc });
const listEl = contentEl.createEl("ul", { cls: "revert-file-list" });
this.files.forEach((file) => {
listEl.createEl("li", { text: file });
});
const buttonContainer = contentEl.createDiv({ cls: "modal-button-container" });
buttonContainer.createEl("button", { text: i18n.revertCancelButton }).addEventListener("click", () => {
this.close();
});
const confirmBtn = buttonContainer.createEl("button", {
text: i18n.revertConfirmButton,
cls: "mod-warning",
});
confirmBtn.addEventListener("click", () => {
this.close();
this.onConfirm();
});
}
onClose() {
this.contentEl.empty();
}
}