Skip to content

Conversation

carlosms
Copy link
Contributor

Fixes #20.

Besides syntax highlighting this PR also adds autocomplete. To do that, the schema is loaded when the application starts. Also the query can be executed with ctrl+enter.

peek 2018-05-17 19-01

@carlosms carlosms self-assigned this May 17, 2018
@carlosms carlosms requested review from smacker and dpordomingo May 17, 2018 17:08
? this.schemaToCodeMirror(this.props.schema)
: {};

const options = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't really important, but I wouldn't convert schema and create options object on every render (means every key press). Consider to create the codemirror configuration in constructor and update it on componentWillReceiveProps when schema or handleSubmit are changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, fixed in d2fb518

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased, now it's fixed in ce8f1dd


.CodeMirror-empty {
color: dimgrey;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line

Copy link
Contributor

@dpordomingo dpordomingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

@carlosms carlosms changed the title Add CodeMirror editor with sql syntax and autocomplete [WiP] Add CodeMirror editor with sql syntax and autocomplete May 18, 2018
@carlosms carlosms changed the title [WiP] Add CodeMirror editor with sql syntax and autocomplete Add CodeMirror editor with sql syntax and autocomplete May 18, 2018
Code to fix CodeMirror dependencies in frontend tests
taken from
https://github.com/bblfsh/dashboard/blob/master/src/setupTests.js

Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
@carlosms carlosms merged commit 0cbce7d into src-d:master May 21, 2018
.then(res =>
Promise.all(
res.data.map(e =>
query(`DESCRIBE TABLE ${e.table}`).then(tableRes => ({
Copy link
Contributor

@bzz bzz May 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlosms sorry for digging this up, but I have just realized that we need to change this logic eventually.

Instead for

  • API call /tables
  • then, for each table call DESCRIBE TABLE from the frontend

We should have

  • API call to /tables, so that the backend returns all this information in a single call

on top of per improvements (less HTTP calls), one of the purposes of having separate API endpoint on the backend was to abstract the details of how meta-information (schema) is collected.

Current approach, for a case if it is not a DESCRIBE TABLE - would require us to change both, backend and frontend. The one suggested above would requite only the backend change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you comment. I actually though of doing it that way in this PR, but didn't want to get too ahead of myself and went for the quicker approach of doing it in the frontend.

I've created a new issue with your request: #40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants