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

refactor: typing for explore Control and messageToasts #11416

Merged
merged 6 commits into from Oct 25, 2020

Conversation

ktmud
Copy link
Member

@ktmud ktmud commented Oct 24, 2020

SUMMARY

Needed to do some refactor with chart controls. Finally adding typing to this very important component so to make future changes safer.

Updated typing for messageToasts actions, too, because it's a dependency of exploreActions.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TEST PLAN

CI and manually testing to make sure controls still work.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@codecov-io
Copy link

codecov-io commented Oct 24, 2020

Codecov Report

Merging #11416 into master will decrease coverage by 4.18%.
The diff coverage is 69.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11416      +/-   ##
==========================================
- Coverage   66.49%   62.31%   -4.19%     
==========================================
  Files         860      860              
  Lines       40869    40871       +2     
  Branches     3686     3694       +8     
==========================================
- Hits        27176    25467    -1709     
- Misses      13592    15224    +1632     
- Partials      101      180      +79     
Flag Coverage Δ
#cypress ?
#javascript 62.96% <69.51%> (+0.03%) ⬆️
#python 61.93% <ø> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
superset-frontend/src/chart/Chart.jsx 10.90% <ø> (-47.28%) ⬇️
...erset-frontend/src/datasource/DatasourceEditor.jsx 63.63% <ø> (-7.73%) ⬇️
.../src/explore/components/ControlPanelsContainer.jsx 81.81% <ø> (-10.61%) ⬇️
...et-frontend/src/explore/reducers/exploreReducer.js 32.72% <ø> (-18.13%) ⬇️
...set-frontend/src/explore/actions/exploreActions.ts 35.93% <22.22%> (ø)
...perset-frontend/src/explore/components/Control.tsx 76.19% <57.14%> (ø)
...rontend/src/explore/components/PropertiesModal.tsx 55.55% <70.00%> (-3.60%) ⬇️
...et-frontend/src/messageToasts/components/Toast.tsx 88.88% <80.00%> (-11.12%) ⬇️
...perset-frontend/src/messageToasts/actions/index.ts 87.50% <85.71%> (ø)
...nd/src/messageToasts/components/ToastPresenter.tsx 100.00% <100.00%> (ø)
... and 185 more

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 efdda8b...1fe19f9. Read the comment docs.

owners: PropTypes.arrayOf(PropTypes.string),
owners: PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
),
Copy link
Member Author

Choose a reason for hiding this comment

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

By catch: suppress a propTypes warning. Chart's ProprtiesModal loads owners via usernames, but when updating, it updates to numeric IDs.

export const UPDATE_EXPLORE_ENDPOINTS = 'UPDATE_EXPLORE_ENDPOINTS';
export function updateExploreEndpoints(jsonUrl, csvUrl, standaloneUrl) {
return { type: UPDATE_EXPLORE_ENDPOINTS, jsonUrl, csvUrl, standaloneUrl };
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This action is added in a 4 yo PR but doesn't seem to have been used anywhere (even in the original PR).

sliceUpdated,
};

export type ExploreActions = typeof exploreActions;
Copy link
Member Author

Choose a reason for hiding this comment

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

Explore and enumerate all action functions so it can be used in external typing.

@ktmud ktmud marked this pull request as ready for review October 24, 2020 07:49
Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

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

LGTM

};

const thunk = handleComponentDrop(dropResult);
thunk(dispatch, getState);
expect(dispatch.getCall(0).args[0].type).toEqual(
addWarningToast('').type,
);
Copy link
Member Author

@ktmud ktmud Oct 24, 2020

Choose a reason for hiding this comment

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

Bycatch: this was an invalid test. The invalid input above didn't actually test the case it was supposed to test ("drop overflows the destination").

Previously this test passes because both dispatch.getCall(0).args[0].type and addWarningToast('').type were undefined, when they both should be ADD_TOAST. This error was surfaced because I removed the dispatch wrapper for toast actions.

cc @graceguo-supercat @williaster

@ktmud ktmud merged commit 8aecffd into apache:master Oct 25, 2020
@ktmud ktmud deleted the typing-Control branch October 25, 2020 04:40
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.0 labels Mar 12, 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/L 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants