Files
ignis/shims/electron/remote/dialog.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

2026-03-07 14:38:51 +01:00
export const dialogShim = {
async showOpenDialog(browserWindow, options) {
2026-03-11 22:08:30 +01:00
// TODO: implement custom modal with server-side file listing
console.log("[shim:dialog] showOpenDialog (stub):", options);
2026-03-07 14:38:51 +01:00
return { canceled: true, filePaths: [] };
},
2026-03-13 19:57:37 +01:00
// TODO: replace prompt() with a styled modal (matching vault manager style)
2026-03-07 14:38:51 +01:00
async showSaveDialog(browserWindow, options) {
2026-03-13 19:57:37 +01:00
if (typeof browserWindow === "object" && !options) {
options = browserWindow;
}
const defaultName =
options?.defaultPath?.split(/[/\\]/).pop() || "download";
const name = prompt("Save as:", defaultName);
if (!name) {
return { canceled: true, filePath: undefined };
}
return { canceled: false, filePath: "/downloads/" + name };
2026-03-07 14:38:51 +01:00
},
2026-03-17 12:38:30 +01:00
// TODO: replace alert() with a styled modal (matching vault manager style)
2026-03-07 14:38:51 +01:00
async showMessageBox(browserWindow, options) {
2026-03-11 22:08:30 +01:00
if (typeof browserWindow === "object" && !options) {
2026-03-07 14:38:51 +01:00
options = browserWindow;
}
2026-03-17 12:38:30 +01:00
2026-03-11 22:08:30 +01:00
console.log("[shim:dialog] showMessageBox:", options);
2026-03-07 14:38:51 +01:00
2026-03-11 22:08:30 +01:00
const message = options.message || "";
const detail = options.detail || "";
const buttons = options.buttons || ["OK"];
2026-03-07 14:38:51 +01:00
if (buttons.length <= 1) {
2026-03-11 22:08:30 +01:00
alert(message + (detail ? "\n\n" + detail : ""));
2026-03-07 14:38:51 +01:00
return { response: 0, checkboxChecked: false };
}
2026-03-11 22:08:30 +01:00
const result = confirm(
message +
(detail ? "\n\n" + detail : "") +
'\n\n[OK] = "' +
buttons[0] +
'", [Cancel] = "' +
buttons[1] +
'"',
);
2026-03-07 14:38:51 +01:00
return {
response: result ? 0 : 1,
checkboxChecked: false,
};
},
showErrorBox(title, content) {
2026-03-11 22:08:30 +01:00
console.error("[shim:dialog] Error:", title, content);
alert(title + "\n\n" + content);
2026-03-07 14:38:51 +01:00
},
};