Skip to content

Commit

Permalink
New Empty Database... menu option, closes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 3, 2021
1 parent 8963bd1 commit 471f462
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,32 @@ function createWindow() {
postConfigure(newWindow);
},
},
{ type: "separator" },
{
label: "New Empty Database…",
accelerator: "CommandOrControl+Shift+N",
click: async () => {
const filepath = dialog.showSaveDialogSync({defaultPath: "database.db", title: "Create Empty Database"})
const response = await request(
`http://localhost:${port}/-/new-empty-database-file`,
{
method: "POST",
body: JSON.stringify({ path: filepath }),
}
);
const responseJson = await response.json();
if (!responseJson.ok) {
console.log(responseJson);
dialog.showMessageBox({
type: "error",
title: "Datasette",
message: responseJson.error
});
} else {
datasette.openPath(responseJson.path);
}
},
},
{
label: "Open CSV…",
accelerator: "CommandOrControl+O",
Expand Down

0 comments on commit 471f462

Please sign in to comment.