mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import { Modal, ButtonComponent } from 'obsidian';
|
|
import type FolderNotesPlugin from 'src/main';
|
|
|
|
export default class BackupWarningModal extends Modal {
|
|
plugin: FolderNotesPlugin;
|
|
title: string;
|
|
desc: string;
|
|
callback: (oldMethod: string) => void;
|
|
args: [string];
|
|
|
|
constructor(
|
|
plugin: FolderNotesPlugin,
|
|
title: string,
|
|
description: string,
|
|
callback: (oldMethod: string) => void,
|
|
args: [string],
|
|
) {
|
|
super(plugin.app);
|
|
this.plugin = plugin;
|
|
this.title = title;
|
|
this.callback = callback;
|
|
this.args = args;
|
|
this.desc = description;
|
|
}
|
|
|
|
onOpen(): void {
|
|
this.modalEl.addClass('fn-backup-warning-modal');
|
|
const { contentEl } = this;
|
|
|
|
contentEl.createEl('h2', { text: this.title });
|
|
|
|
contentEl.createEl('p', { text: this.desc });
|
|
|
|
// eslint-disable-next-line max-len
|
|
contentEl.createEl('p', { text: 'Make sure to backup your vault before using this feature.' }).addClass('fn-warning-text');
|
|
|
|
const buttonContainer = contentEl.createDiv({ cls: 'fn-modal-button-container' });
|
|
const confirmButton = new ButtonComponent(buttonContainer);
|
|
confirmButton.setButtonText('Confirm')
|
|
.setCta()
|
|
.onClick(() => {
|
|
this.callback(...this.args);
|
|
this.close();
|
|
});
|
|
|
|
const cancelButton = new ButtonComponent(buttonContainer);
|
|
cancelButton.setButtonText('Cancel')
|
|
.onClick(() => {
|
|
this.close();
|
|
});
|
|
}
|
|
|
|
onClose(): void {
|
|
const { contentEl } = this;
|
|
contentEl.empty();
|
|
}
|
|
}
|