-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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: Create Chart onClick Functionality #20809
feat: Create Chart onClick Functionality #20809
Conversation
/testenv up |
@@ -223,7 +248,7 @@ export default class ResultSet extends React.PureComponent< | |||
// Added compute logic to stop user from being able to Save & Explore | |||
const { showSaveDatasetModal } = this.state; | |||
const { query } = this.props; | |||
|
|||
console.log('this is query', query); |
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.
remove this console.log
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.
@AAfghahi maybe it would be a good idea to get warning on console
in linter
// } | ||
this.setState({ showSaveDatasetModal: true }); | ||
}} | ||
onClick={this.createExploreResultsOnClick} |
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.
we still want to hide this feature so leave the original code in place, and add a comment saying to enable chart source to query change the onClick to onClick={this.createExploreResultsOnClick}
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.
yeah that makes sense, just did that, though will reverse it after this has gone through code review so that QA can test the new flow.
fd8fc41
to
8ea1742
Compare
@@ -213,6 +219,28 @@ export default class ResultSet extends React.PureComponent< | |||
} | |||
} | |||
|
|||
async createExploreResultsOnClick() { | |||
const { results } = this.props.query; | |||
// There is currently redux / state issue where sometimes a query will have serverId |
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.
This comment is probably no longer relevant - did you encounter this issue at all in this workflow?
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.
No I didn't, but wasn't sure so kept it in. Will delete.
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.
changed
8ea1742
to
4f878c7
Compare
4f878c7
to
9c2f323
Compare
const { results } = this.props.query; | ||
|
||
if (results.query_id) { | ||
const key = await postFormData(results.query_id, 'table', { |
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.
the type should be a query
if (results.query_id) { | ||
const key = await postFormData(results.query_id, 'table', { | ||
...EXPLORE_CHART_DEFAULT, | ||
datasource: `${results.query_id}__table`, |
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.
type should be query
Looking at the video it seems like you are registering the query as a dataset not a query |
Codecov Report
@@ Coverage Diff @@
## master #20809 +/- ##
==========================================
+ Coverage 66.28% 66.30% +0.02%
==========================================
Files 1757 1761 +4
Lines 66796 67060 +264
Branches 7052 7131 +79
==========================================
+ Hits 44276 44465 +189
- Misses 20721 20794 +73
- Partials 1799 1801 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. |
@@ -213,6 +219,28 @@ export default class ResultSet extends React.PureComponent< | |||
} | |||
} | |||
|
|||
async createExploreResultsOnClick() { |
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.
if we use arrow function syntax here, you don't have to add the .bind call on line 141,142:
async createExploreResultsOnClick = () => {
Arrow functions automatically bind this
to where the function is defined which has the same effect as calling this.createExploreResultsOnClick = this.createExploreResultsOnClick.bind(this);
I have been updating files I work in to convert to arrow functions and remove the bind calls because it removes the second step and extra code.
}); | ||
window.open(url, '_blank', 'noreferrer'); | ||
} else { | ||
this.setState({ showSaveDatasetModal: 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.
I think we can remove this this.setState({ showSaveDatasetModal: true });.
Initially I was trying to use serverId which was not always present and just defaulted to the original behavior. with use of queryId, it should always be there and if it is not we have a bug. We may to change the else to show an error toast indicating the query has no id and cannot be used to create a chart. This should never happen and provides visual indication if something is broken
const { results } = this.props.query; | ||
|
||
if (results.query_id) { | ||
const key = await postFormData(results.query_id, 'table', { |
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.
One thing I noticed with this await is that if you set your network speed in dev tools to slow 3G to represent a poor connection, the UI looks unresponsive after clicking the button. We could consider setting state before the await to trigger a re-render and show UI that indicates the user's button clicked is being processed. Not critical, and maybe a separate ticket, but these types of things often get missed in our local dev environment where responses are near instant and have no real world latency / bandwidth restrictions
@AAfghahi Container image not yet published for this PR. Please try again when build is complete. |
@AAfghahi Ephemeral environment creation failed. Please check the Actions logs for details. |
SUMMARY
This changes the functionality of the create chart button to be in line with the new feature of a query powered chart. Essentially when the create chart button is now clicked the user will have a new tab open with a table chart using all their current data.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Screen.Recording.2022-07-21.at.11.46.42.AM.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION