-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sqllab): SQLEditor Extension #24205
feat(sqllab): SQLEditor Extension #24205
Conversation
Codecov Report
@@ Coverage Diff @@
## master #24205 +/- ##
==========================================
- Coverage 68.22% 66.69% -1.54%
==========================================
Files 1957 1957
Lines 75594 75600 +6
Branches 8224 8223 -1
==========================================
- Hits 51572 50418 -1154
- Misses 21914 23074 +1160
Partials 2108 2108
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 93 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
tables: TTables[]; | ||
queryEditor: TQueryEditor; | ||
database: TDatabase; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Antonio-RiveroMartnez
Not all custom extension requires all these properties such like tables
and database
Therefore, I think it's not a good idea passing these specified properties because you can access these values from redux. (you can also access the queryEditor object by useQueryEditor hook)
Only thing you need to pass is queryEditorId
and then each custom extension component should use a hook to retrieve the properties that needed.
tables: TTables[]; | |
queryEditor: TQueryEditor; | |
database: TDatabase; | |
queryEditorId: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @justinpark ! Good call, I will change this. I am working a bit more on this extension feature so I'll move this PR to be a DRAFT until I get everything in place and final props etc are figured out. ILYK. Thanks for the input as always 👏
@Antonio-RiveroMartnez could you help me review #24214 and rebase your PR on top of that one? |
Oh nice! Yes I will do so. |
15217e8
to
08403b3
Compare
- Add a new extension so our SQLEditor can make use of it if provided extend SQLLab. - Add tests for the new extension
- Rebase using the refactored branch
- Use queryEditor Id instead of passing tables and database and add two additional props needed for triggering queries
e4a1741
to
b51fe1f
Compare
{SqlFormExtension && ( | ||
<SqlFormExtension | ||
queryEditorId={queryEditor.id} | ||
setQueryEditorAndSaveSqlWithDebounce={ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Antonio-RiveroMartnez I am thinking if we need to pass setQueryEditorAndSaveSqlWithDebounce
and startQuery
or if those can be implemented by hooking into the state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @geido good call! I understand we want to keep the extension with as little props/dependencies as possible, but for example in the case of startQuery
, it needs to dispatch two actions in the main component, so, right now I don't see a clearer way than passing the whole callback, like we do on other extensions like SSHTunneling, etc. But If anyone has an idea on how this might work, I'm more than happy to discuss. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geido @Antonio-RiveroMartnez similar to the previous comment, this action props doesn't make sense since your custom component only needs these actions. You can hook up these actions in your custom component by combining of existing action helpers
For example you can build startQuery in your component by combining of runQueryFromSqlEditor and setActiveSouthPaneTab
dispatch(
runQueryFromSqlEditor(
database,
queryEditor,
defaultQueryLimit,
ctasArg ? ctas : '',
ctasArg,
ctas_method,
),
);
dispatch(setActiveSouthPaneTab('Results'));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @justinpark sure, I can recreate all those with the helpers, but since we are not changing how they work, just invoking them, I treated them like other props our existing extensions are using. IMHO I see no major benefit by forcing a duplication of code in the extension. However, if you truly see this like an scenario we should force such duplication, I can work on it in a follow up PR. Thanks as always for the input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
SUMMARY
In order to extend capabilities in our SQLEditor we need to provide an extension. This PR is adding such extension and adding tests for it.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION