-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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: SQL preview modal for Query History #11634
Conversation
c031e49
to
1b67dfa
Compare
Codecov Report
@@ Coverage Diff @@
## master #11634 +/- ##
==========================================
+ Coverage 62.86% 63.14% +0.28%
==========================================
Files 889 900 +11
Lines 43055 43563 +508
Branches 4017 4199 +182
==========================================
+ Hits 27065 27509 +444
- Misses 15811 15874 +63
- Partials 179 180 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
f0a19a5
to
83b1561
Compare
43a6bf7
to
1eaa405
Compare
top: 40px; | ||
left: 512px; | ||
visibility: hidden; | ||
margin: -4px; |
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.
small nit, but do you need the negative margin if you have the top and left relative positions?
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.
That negative margin gets rid of the space that would be occupied by the element if it were not relative positioned. If we were using absolute positioning we wouldn't need it.
} | ||
const syntaxHighlighterProps = { ...props }; | ||
delete syntaxHighlighterProps.addDangerToast; | ||
delete syntaxHighlighterProps.addSuccessToast; |
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.
would this work for you?
const { addDangerToast, addSuccessToast, ...syntaxHighlighterProps } = props;
do you need to remove 'props.children' from the syntaxHighlighterProps as well?
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.
👏 why didn't I think of that!
|
||
function checkIndex() { | ||
if (currentIndex === 0) { | ||
setDisbalePrevious(true); |
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.
typo?
if (currentIndex === 0) { | ||
setDisbalePrevious(true); | ||
} else { | ||
setDisbalePrevious(false); |
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.
could this be shortened to checkDisablePrevious(currentIndex === 0)
} | ||
|
||
if (currentIndex === queries.length - 1) { | ||
setDisbaleNext(true); |
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.
setDisableNext(currentIndex === queries.length - 1)
?
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.
👍 just a couple questions!
import { ToastProps } from 'src/messageToasts/enhancers/withToasts'; | ||
import Icon from 'src/components/Icon'; | ||
|
||
SyntaxHighlighter.registerLanguage('sql', sql); |
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.
Would it make sense to add a language prop so we can use this component with json
/css
/etc.?
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.
I added 'sql' | 'markdown' | 'html' | 'json'
which is all I could find in the code base. Adding more, as needed, should be pretty simple.
data-test={`open-sql-preview-${id}`} | ||
onClick={() => setQueryCurrentlyPreviewing(original)} | ||
> | ||
<StyledSyntaxHighlighter language="sql" style={github}> |
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.
What's the difference between setting the language
prop here and calling SyntaxHighlighter.registerLanguage
above? Does the latter just load in the highlighting logic for while former explicitly sets it?
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.
I think the SyntaxHighlighter ships with a few languages, and probably an interface to create your own. I think the registerLanguage
step is to slim down the component and not include a bunch of unnecessary code that won't be used. I'll scan the codebase for other languages we use with SyntaxHighlighter and include those too.
type BaseQueryObject = { | ||
id: number; | ||
}; | ||
export function useQueryPreviewState<D extends BaseQueryObject = any>({ |
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 👌
setupFilesAfterEnv: [ | ||
'<rootDir>/node_modules/jest-enzyme/lib/index.js', | ||
'<rootDir>/spec/helpers/shim.ts', | ||
], |
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.
@nytai any reason for this change?
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.
I was having issues with shim.ts
not loading when I was running tests in vscode -- mainly type errors. I was digging through some docs and most of them were using absolute paths. Is it causing issues?
SUMMARY
Building off of #11574 this PR adds a preview/inspect modal to the Query History list view with a toggle for User inputted SQL and db executed SQL.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
before:
![Screen Shot 2020-11-10 at 9 57 48 AM](https://user-images.githubusercontent.com/10255196/98726981-515ca200-233b-11eb-9493-c05060e886e1.png)
After:
![Screen Shot 2020-11-09 at 5 35 32 PM](https://user-images.githubusercontent.com/10255196/98624515-14989880-22b2-11eb-9a5c-0d3cada5c6dc.png)
![Screen Shot 2020-11-09 at 5 35 39 PM](https://user-images.githubusercontent.com/10255196/98624518-195d4c80-22b2-11eb-818d-0716e42d39f5.png)
Also, added copy query button to Saved Query preview modal
![Screen Shot 2020-11-09 at 5 35 18 PM](https://user-images.githubusercontent.com/10255196/98624577-3560ee00-22b2-11eb-82ad-abf8443302ee.png)
TEST PLAN
ADDITIONAL INFORMATION
SIP_34_QUERY_SEARCH_UI
)