fix issues with dialogs, and issue with vault rename

This commit is contained in:
Nystik
2026-03-18 19:11:13 +01:00
parent e1d484fd28
commit 2418f125f0
6 changed files with 201 additions and 32 deletions

View File

@@ -1,3 +1,9 @@
import {
showMessageDialog,
showConfirmDialog,
showPromptDialog,
} from "../../../ui/bootstrap.js";
export const dialogShim = {
async showOpenDialog(browserWindow, options) {
// TODO: implement custom modal with server-side file listing
@@ -5,21 +11,28 @@ export const dialogShim = {
return { canceled: true, filePaths: [] };
},
// TODO: replace prompt() with a styled modal (matching vault manager style)
async showSaveDialog(browserWindow, options) {
if (typeof browserWindow === "object" && !options) {
options = browserWindow;
}
const defaultName =
options?.defaultPath?.split(/[/\\]/).pop() || "download";
const name = prompt("Save as:", defaultName);
options?.defaultPath?.split(/[\/\\]/).pop() || "download";
const name = await showPromptDialog(
"Save File",
"Save as:",
"filename",
defaultName,
"Save",
);
if (!name) {
return { canceled: true, filePath: undefined };
}
return { canceled: false, filePath: "/downloads/" + name };
},
// TODO: replace alert() with a styled modal (matching vault manager style)
async showMessageBox(browserWindow, options) {
if (typeof browserWindow === "object" && !options) {
options = browserWindow;
@@ -30,21 +43,20 @@ export const dialogShim = {
const message = options.message || "";
const detail = options.detail || "";
const buttons = options.buttons || ["OK"];
const fullMessage = message + (detail ? "\n\n" + detail : "");
if (buttons.length <= 1) {
alert(message + (detail ? "\n\n" + detail : ""));
await showMessageDialog(options.title || "Message", fullMessage);
return { response: 0, checkboxChecked: false };
}
const result = confirm(
message +
(detail ? "\n\n" + detail : "") +
'\n\n[OK] = "' +
buttons[0] +
'", [Cancel] = "' +
buttons[1] +
'"',
const result = await showConfirmDialog(
options.title || "Confirm",
message,
detail,
buttons[0],
);
return {
response: result ? 0 : 1,
checkboxChecked: false,
@@ -53,6 +65,6 @@ export const dialogShim = {
showErrorBox(title, content) {
console.error("[shim:dialog] Error:", title, content);
alert(title + "\n\n" + content);
showMessageDialog(title, content);
},
};