Skip to content

Commit 7eb2755

Browse files
committed
feat(playground): add new query button
1 parent 4959834 commit 7eb2755

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

web/playground/src/workbench/Workbench.jsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class Workbench extends React.Component {
9595
this.monaco.editor.setModelMarkers(
9696
this.editor.getModel(),
9797
"prql",
98-
monacoErrors,
98+
monacoErrors
9999
);
100100
return;
101101
}
@@ -149,6 +149,27 @@ class Workbench extends React.Component {
149149
]);
150150
}
151151

152+
new_query() {
153+
let filename = prompt(`Enter a name for your new query`);
154+
if (filename) {
155+
if (!filename.endsWith(".prql")) {
156+
filename += ".prql";
157+
}
158+
159+
this.setState({
160+
filename,
161+
prql: "",
162+
output: null,
163+
outputTab: "arrow",
164+
prqlError: null,
165+
duckdbError: null,
166+
});
167+
if (this.editor) {
168+
this.editor.setValue("");
169+
}
170+
}
171+
}
172+
152173
rename() {
153174
let filename = prompt(`New name for ${this.state.filename}`);
154175
if (filename) {
@@ -175,6 +196,9 @@ class Workbench extends React.Component {
175196
<button className="action" onClick={() => this.save()}>
176197
Save
177198
</button>
199+
<button className="action" onClick={() => this.new_query()}>
200+
New Query
201+
</button>
178202
</div>
179203
<Editor
180204
height="10rem"

0 commit comments

Comments
 (0)