Skip to content

Commit

Permalink
'Enable Debug Menu' button on about, closes #78
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 8, 2021
1 parent 8d2c1b9 commit 79fd738
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const mkdir = util.promisify(fs.mkdir);

const RANDOM_SECRET = crypto.randomBytes(32).toString("hex");

let enableDebugMenu = !!process.env.DEBUGMENU;

function configureWindow(window) {
window.webContents.on("will-navigate", function (event, reqUrl) {
// Links to external sites should open in system browser
Expand Down Expand Up @@ -449,18 +451,26 @@ function buildMenu() {
{
label: "About Datasette",
async click() {
let buttons = ["Visit datasette.io", "OK"];
if (!enableDebugMenu) {
buttons.push("Enable Debug Menu");
}
dialog
.showMessageBox({
type: "info",
message: "About Datasette",
detail: await datasette.about(),
buttons: ["Visit datasette.io", "OK"],
buttons: buttons,
})
.then((click) => {
console.log(click);
if (click.response == 0) {
shell.openExternal("https://datasette.io/");
}
if (click.response == 2) {
enableDebugMenu = true;
Menu.setApplicationMenu(Menu.buildFromTemplate(buildMenu()));
}
});
},
},
Expand Down Expand Up @@ -661,7 +671,7 @@ function buildMenu() {
],
},
];
if (process.env.DEBUGMENU) {
if (enableDebugMenu) {
menuTemplate.push({
label: "Debug",
submenu: [
Expand Down

0 comments on commit 79fd738

Please sign in to comment.