Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

feat: add NoResultsComponent to charts #305

Merged
merged 1 commit into from
Mar 3, 2020
Merged

Conversation

etr2460
Copy link
Contributor

@etr2460 etr2460 commented Mar 3, 2020

🏆 Enhancements
Introduces new behavior for when no queryData is passed to a Superset Chart. Currently this never happens because Superset renders it's own error message, but this will be used in the future once we allow the backend to return empty query data as valid data.

Test plan:
Add new storybook examples and unit tests

Message on a small chart:
Screen Shot 2020-03-03 at 11 32 21 AM

Message on a large chart:
Screen Shot 2020-03-03 at 11 32 13 AM

@etr2460 etr2460 requested a review from a team as a code owner March 3, 2020 18:14
@codecov
Copy link

codecov bot commented Mar 3, 2020

Codecov Report

Merging #305 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #305   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         102    103    +1     
  Lines        1212   1223   +11     
  Branches      298    300    +2     
=====================================
+ Hits         1212   1223   +11
Impacted Files Coverage Δ
...es/superset-ui-chart/src/components/SuperChart.tsx 100% <100%> (ø) ⬆️
...set-ui-chart/src/components/NoResultsComponent.tsx 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 624f066...2886d69. Read the comment docs.

@netlify
Copy link

netlify bot commented Mar 3, 2020

Deploy preview for superset-ui ready!

Built with commit 2886d69

https://deploy-preview-305--superset-ui.netlify.com

@etr2460 etr2460 changed the title feat: add NoDataComponent to charts feat: add NoResultsComponent to charts Mar 3, 2020
@etr2460 etr2460 force-pushed the erik-ritter--no-data branch from 677e806 to 9d0e2d6 Compare March 3, 2020 19:34

const NoResultsComponent = ({ height, width }: Props) => (
<div style={generateContainerStyles(height, width)}>
<div style={{ maxWidth: 800 }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please extract the style constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

};

const NoResultsComponent = ({ height, width }: Props) => (
<div style={generateContainerStyles(height, width)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use useMemo hook for this to avoid creating new style object every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -1,3 +1,5 @@
import 'core-js/stable';
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, my bad. that must've gotten carried along from when i was trying to get the storybook to work

queryData.data === null ||
(Array.isArray(queryData.data) && queryData.data.length === 0)
) {
chart = <NoResultsComponent height={height} width={width} />;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it should take id and className as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, added

@etr2460 etr2460 force-pushed the erik-ritter--no-data branch from 9d0e2d6 to 2886d69 Compare March 3, 2020 22:36
@kristw kristw merged commit 42060a0 into master Mar 3, 2020
@delete-merged-branch delete-merged-branch bot deleted the erik-ritter--no-data branch March 3, 2020 22:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants