Skip to content

Commit

Permalink
feat(playground): add new query button
Browse files Browse the repository at this point in the history
  • Loading branch information
hulxv committed Jan 25, 2024
1 parent 4959834 commit 7eb2755
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion web/playground/src/workbench/Workbench.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Workbench extends React.Component {
this.monaco.editor.setModelMarkers(
this.editor.getModel(),
"prql",
monacoErrors,
monacoErrors
);
return;
}
Expand Down Expand Up @@ -149,6 +149,27 @@ class Workbench extends React.Component {
]);
}

new_query() {
let filename = prompt(`Enter a name for your new query`);
if (filename) {
if (!filename.endsWith(".prql")) {
filename += ".prql";
}

this.setState({
filename,
prql: "",
output: null,
outputTab: "arrow",
prqlError: null,
duckdbError: null,
});
if (this.editor) {
this.editor.setValue("");
}
}
}

rename() {
let filename = prompt(`New name for ${this.state.filename}`);
if (filename) {
Expand All @@ -175,6 +196,9 @@ class Workbench extends React.Component {
<button className="action" onClick={() => this.save()}>
Save
</button>
<button className="action" onClick={() => this.new_query()}>
New Query
</button>
</div>
<Editor
height="10rem"
Expand Down

0 comments on commit 7eb2755

Please sign in to comment.