Skip to content
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

chore: refactor ChartHolder to typescript + tests #20910

Merged

Conversation

diegomedina248
Copy link
Contributor

SUMMARY

This PR refactors the ChartHolder into a functional component with typescript.
It also adds more test coverage.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

--

TESTING INSTRUCTIONS

--

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Jul 29, 2022

Codecov Report

Merging #20910 (d63f0de) into master (756ed0e) will increase coverage by 0.05%.
The diff coverage is 91.75%.

@@            Coverage Diff             @@
##           master   #20910      +/-   ##
==========================================
+ Coverage   66.29%   66.34%   +0.05%     
==========================================
  Files        1773     1774       +1     
  Lines       67680    67686       +6     
  Branches     7214     7215       +1     
==========================================
+ Hits        44866    44907      +41     
+ Misses      20971    20946      -25     
+ Partials     1843     1833      -10     
Flag Coverage Δ
javascript 52.21% <91.75%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...tend/src/dashboard/components/AnchorLink/index.tsx 93.75% <ø> (+12.50%) ⬆️
...ashboard/components/gridComponents/ChartHolder.tsx 88.88% <88.88%> (ø)
...end/src/dashboard/components/dnd/DragDroppable.jsx 76.92% <100.00%> (ø)
...rc/dashboard/util/useFilterFocusHighlightStyles.ts 100.00% <100.00%> (ø)
...-frontend/src/dashboard/reducers/dashboardState.js 76.59% <0.00%> (+2.12%) ⬆️
...hboard/components/resizable/ResizableContainer.jsx 61.70% <0.00%> (+4.25%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@yousoph
Copy link
Member

yousoph commented Jul 29, 2022

/testenv up

@yousoph yousoph added the need:qa-review Requires QA review label Jul 29, 2022
@yousoph
Copy link
Member

yousoph commented Jul 29, 2022

🏷️ Preset-Patch

@github-actions
Copy link
Contributor

@yousoph Ephemeral environment spinning up at http://54.202.171.173:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

);

const infoFromPath = useMemo(
() => getChartAndLabelComponentIdFromPath(directPathToChild) as any,
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to not use any here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but we'd need to change the file that contains that function to typescript, and there's a couple of types around the filters that are not well defined.
Plus, changing that file should follow with tests as well, and I didn't want to make this PR bigger, since it can be addressed as a follow up

const [currentDirectPathLastUpdated, setCurrentDirectPathLastUpdated] =
useState(0);

const directPathToChild = useMemo(

Choose a reason for hiding this comment

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

I might be mistaken, but since we are not computing an expensive function, just accessing a property inside the dashboardState object, could we get rid of useMemo? Or there is some performance implication if we remove it, that I'm not seeing. Same with directPathLastUpdated below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two are used in other hooks/callbacks below, so need to memoize those to avoid recomputing everything (even if it's just a string/etc)

@EugeneTorap
Copy link
Contributor

@diegomedina248 Thank you for this PR! I have a SqlEditor refactoring into FC, can I share the code with you?
@michael-s-molina @kgabryje Can we merge the PR?

@diegomedina248
Copy link
Contributor Author

@diegomedina248 Thank you for this PR! I have a SqlEditor refactoring into FC, can I share the code with you? @michael-s-molina @kgabryje Can we merge the PR?

@EugeneTorap sure thing!

@jinghua-qa
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@jinghua-qa Ephemeral environment spinning up at http://54.214.218.74:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

1 similar comment
@github-actions
Copy link
Contributor

@jinghua-qa Ephemeral environment spinning up at http://54.214.218.74:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@jinghua-qa
Copy link
Member

jinghua-qa commented Aug 18, 2022

I found some issues in this PR:
1, if user click on the filter indicator when chart is in fullscreen view, user will bring out to the normal view and the 3 dot menu on charts are not open. I test on superset master it seems like on master click on the filter indicator in enlarge chart view did not bring user to fullscreen view.

2, for numerical filter, it looks like the filter bar is not shown correctly when user select filter range:
Screen Shot 2022-08-18 at 11 13 27 AM

@diegomedina248 diegomedina248 force-pushed the chore/refactor-chart-holder-to-ts branch from efe387e to d63f0de Compare August 22, 2022 11:51
@diegomedina248
Copy link
Contributor Author

I found some issues in this PR: 1, if user click on the filter indicator when chart is in fullscreen view, user will bring out to the normal view and the 3 dot menu on charts are not open. I test on superset master it seems like on master click on the filter indicator in enlarge chart view did not bring user to fullscreen view.

Screen.Recording.2022-08-18.at.11.06.53.AM.mov
2, for numerical filter, it looks like the filter bar is not shown correctly when user select filter range: Screen Shot 2022-08-18 at 11 13 27 AM

mm, I actually couldn't reproduce those.
I did rebase from master, to have the branch up to date, and couldn't reproduce either that way.

Here's what I'm doing:

test.mov

@jinghua-qa
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@jinghua-qa Ephemeral environment spinning up at http://34.221.79.198:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@jinghua-qa
Copy link
Member

Test again in the new ephemeral env and verified the reported issue is fixed. Regression test for dashboard LGTM

@EugeneTorap
Copy link
Contributor

EugeneTorap commented Aug 29, 2022

@michael-s-molina @kgabryje @geido Can you review the PR and then merge it?

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

LGTM!
@diegomedina248 A suggestion/tip for future refactors like this one - if you use git mv to change filename, git diff will recognise the file as modified instead of 1 file deleted and 1 file created (like ChartHolder.jsx -> ChartHolder.tsx), which makes reviewing easier

@kgabryje kgabryje merged commit b71182f into apache:master Sep 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2022

Ephemeral environment shutdown and build artifacts deleted.

@mistercrunch mistercrunch added the 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels need:qa-review Requires QA review size/XXL 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants