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 deck.gl plugins to Typescript #24933

Merged
merged 6 commits into from
Aug 28, 2023

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Aug 9, 2023

SUMMARY

This PR refactors all javascript files under legacy-preset-chart-deckgl directory to Typescript.
deck.gl library is bumped from 8.5.2 to 8.8.27 as 8.8 is the first version that exposes type declarations.
The goal is to make deck.gl plugins easier to maintain and catch up with the code quality standards of the newer plugins

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

No visual changes

TESTING INSTRUCTIONS

All deck.gl plugins should work as before.

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

@kgabryje
Copy link
Member Author

kgabryje commented Aug 9, 2023

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2023

@kgabryje Container image not yet published for this PR. Please try again when build is complete.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2023

@kgabryje Ephemeral environment creation failed. Please check the Actions logs for details.

@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #24933 (7865b60) into master (ec9e9a4) will increase coverage by 0.17%.
The diff coverage is 1.26%.

❗ Current head 7865b60 differs from pull request most recent head 5d3ba71. Consider uploading reports for the commit 5d3ba71 to get more accurate results

@@            Coverage Diff             @@
##           master   #24933      +/-   ##
==========================================
+ Coverage   69.00%   69.17%   +0.17%     
==========================================
  Files        1906     1900       -6     
  Lines       74133    73931     -202     
  Branches     8208     8224      +16     
==========================================
- Hits        51153    51144       -9     
+ Misses      20857    20663     -194     
- Partials     2123     2124       +1     
Flag Coverage Δ
javascript 56.11% <1.26%> (+0.26%) ⬆️

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

Files Changed Coverage Δ
...d/packages/superset-ui-chart-controls/src/types.ts 100.00% <ø> (ø)
...et-chart-deckgl/src/CategoricalDeckGLContainer.tsx 0.00% <0.00%> (ø)
...legacy-preset-chart-deckgl/src/DeckGLContainer.tsx 0.00% <0.00%> (ø)
...ins/legacy-preset-chart-deckgl/src/Multi/Multi.tsx 0.00% <0.00%> (ø)
...gacy-preset-chart-deckgl/src/Multi/controlPanel.ts 0.00% <0.00%> (ø)
...gins/legacy-preset-chart-deckgl/src/Multi/index.ts 66.66% <ø> (ø)
...gins/legacy-preset-chart-deckgl/src/TooltipRow.tsx 0.00% <ø> (ø)
...gacy-preset-chart-deckgl/src/components/Legend.tsx 0.00% <0.00%> (ø)
...acy-preset-chart-deckgl/src/components/Tooltip.tsx 0.00% <ø> (ø)
...plugins/legacy-preset-chart-deckgl/src/factory.tsx 0.00% <0.00%> (ø)
... and 32 more

... and 1 file with indirect coverage changes

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

@kgabryje
Copy link
Member Author

kgabryje commented Aug 9, 2023

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2023

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

@@ -31,8 +31,7 @@
"d3-array": "^1.2.4",
"d3-color": "^1.4.1",
"d3-scale": "^3.0.0",
"deck.gl": "8.5.2",
"jquery": "^3.4.1",
Copy link
Member

Choose a reason for hiding this comment

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

that's nice. :)

@@ -73,7 +73,7 @@ export interface Dataset {
main_dttm_col: string;
// eg. ['["ds", true]', 'ds [asc]']
order_by_choices?: [string, string][] | null;
time_grain_sqla?: string;
time_grain_sqla?: [string, string][];
Copy link
Member

@michael-s-molina michael-s-molina Aug 23, 2023

Choose a reason for hiding this comment

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

I think this change is incorrect. If you search for time_grain_sqla in the codebase you'll see it's a string in many places outside the DeckGL plugin.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that in the context of Dataset it actually should be an array. It doesn't really make sense for a dataset to have a single value for time grain, it should rather be a list of supported time grains. Also, if you look at Redux, that's what time_grain_sqla is.

image

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I think you're right! I was thinking about form_data but that makes sense in the context of the Dataset. That's the problem with bad naming.

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @kgabryje.

I think there's a problem with the time_grain_sqla definition.

bottomMargin: 0,

export type DeckGLContainerState = {
lastUpdate?: number | null;
Copy link
Member

Choose a reason for hiding this comment

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

Can optional be sufficient here or null has a different meaning than undefined?

Copy link
Member Author

Choose a reason for hiding this comment

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

It could be undefined because it wasn't defined in the initial state, and only later it was set to a number or null.
It was confusing so now lastUpdate is initialised with null and the type is lastUpdate: number | null;. Thanks for catching that!

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for the improvement @kgabryje!

@kgabryje kgabryje merged commit 4c4fedc into apache:master Aug 28, 2023
26 checks passed
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 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 size/XXL 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants