Skip to content

Commit 2dffe6c

Browse files
committed
feat(playground): Show editable files hint
1 parent 1c20838 commit 2dffe6c

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

packages/cubejs-playground/src/SchemaPage.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,15 @@ class SchemaPage extends Component {
125125
}
126126

127127
selectedFileContent() {
128+
const file = this.selectedFile();
129+
return file && file.content;
130+
}
131+
132+
selectedFile() {
128133
const {
129134
files, selectedFile
130135
} = this.state;
131-
const file = files.find(f => f.fileName === selectedFile);
132-
return file && file.content;
136+
return files.find(f => f.fileName === selectedFile);
133137
}
134138

135139
renderFilesMenu() {
@@ -228,6 +232,20 @@ class SchemaPage extends Component {
228232
</Tabs>
229233
</Sider>
230234
<Content style={{ minHeight: 280 }}>
235+
{
236+
selectedFile && (
237+
<Alert
238+
message={(
239+
<span>
240+
This file is available for edit at&nbsp;
241+
<b>{this.selectedFile().absPath}</b>
242+
</span>
243+
)}
244+
type="info"
245+
style={{ paddingTop: 10, paddingBottom: 11 }}
246+
/>
247+
)
248+
}
231249
{selectedFile
232250
? <PrismCode code={this.selectedFileContent()} style={{ padding: 12 }}/>
233251
: <h2 style={{ padding: 24, textAlign: 'center' }}>Select tables to generate Cube.js schema</h2>

packages/cubejs-server-core/core/DevServer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ class DevServer {
6969
app.get('/playground/files', catchErrors(async (req, res) => {
7070
this.cubejsServer.event('Dev Server Files Load');
7171
const files = await this.cubejsServer.repository.dataSchemaFiles();
72-
res.json({ files });
72+
res.json({
73+
files: files.map(f => ({
74+
...f,
75+
absPath: path.resolve(path.join(this.cubejsServer.repository.localPath(), f.fileName))
76+
}))
77+
});
7378
}));
7479

7580
app.post('/playground/generate-schema', catchErrors(async (req, res) => {

0 commit comments

Comments
 (0)