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

[dashboard] new, bulk actions for delete & export #8979

Merged
merged 15 commits into from Jan 27, 2020

Conversation

nytai
Copy link
Member

@nytai nytai commented Jan 16, 2020

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2020-01-21 at 10 28 27 AM

Screen Shot 2020-01-21 at 10 28 45 AM

Screen Shot 2020-01-21 at 10 29 52 AM

TEST PLAN

  • unit tested
  • manual testing

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

REVIEWERS

@nytai nytai changed the title Tai/bulk actions bulk actions for dashboard list view Jan 16, 2020
@nytai nytai force-pushed the tai/bulk-actions branch 2 times, most recently from 8f4c785 to 5c960ef Compare January 18, 2020 01:52
@codecov-io
Copy link

codecov-io commented Jan 18, 2020

Codecov Report

Merging #8979 into master will increase coverage by 0.35%.
The diff coverage is 86.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8979      +/-   ##
==========================================
+ Coverage   59.16%   59.52%   +0.35%     
==========================================
  Files         367      369       +2     
  Lines       11679    11738      +59     
  Branches     2862     2880      +18     
==========================================
+ Hits         6910     6987      +77     
+ Misses       4590     4572      -18     
  Partials      179      179
Impacted Files Coverage Δ
...assets/src/components/ListView/TableCollection.tsx 92.59% <ø> (ø) ⬆️
...et/assets/src/components/IndeterminateCheckbox.jsx 100% <100%> (ø)
...perset/assets/src/components/ListView/ListView.tsx 92.1% <100%> (+0.92%) ⬆️
superset/assets/src/components/ListView/utils.ts 98.46% <100%> (+0.31%) ⬆️
...t/assets/src/views/dashboardList/DashboardList.tsx 82.4% <64.51%> (+23.46%) ⬆️
...rset/assets/src/components/ConfirmStatusChange.tsx 90% <90%> (ø)

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 7415869...2d58aa6. Read the comment docs.

describe('ConfirmStatusChange', () => {
const action = jest.fn();
const mockedProps = {
title: 'please confirm',
Copy link
Member

Choose a reason for hiding this comment

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

t('please confirm') ?

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 is just a test, so raw string should be ok.

@nytai nytai marked this pull request as ready for review January 21, 2020 23:36
@nytai nytai changed the title bulk actions for dashboard list view [dashboard] new, bulk actions for delete & export Jan 21, 2020
const defaultCallback = () => { console.error('ConfirmStatusChange invoked with the default callback, please provide a function to be called on confirm'); };
export default class ConfirmStatusChange extends React.Component<Props, State> {

public state = {
Copy link
Member

Choose a reason for hiding this comment

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

This and other methods that are only used in this class should probably not be marked public

Copy link
Member Author

Choose a reason for hiding this comment

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

good point. It was tslint --fix that added them and i should have probably done a second pass.

Copy link
Member Author

@nytai nytai Jan 22, 2020

Choose a reason for hiding this comment

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

looks like typescript is complaining about that. React.PureComponet and React.Component both expose state as a public property.

Copy link
Member

Choose a reason for hiding this comment

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

oh react

open: false,
};

public show: ShowCallback = (callback) => (event) => {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would make more sense to pass the callback as a prop to the <ConfirmStatusChange> component. The callback isn't really "state" as far as I can tell, and it could be misleading to think that you can call show multiple times, when that will actually break things.

Copy link
Member Author

Choose a reason for hiding this comment

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

The callback is held in the closure state until the event triggers at which point it's put into the components state and the modal pops up. Holding the callback in state only happens when the modal is open and we're just waiting for user confirmation before executing the original function. Show can be called multiple times with different callbacks and each callback won't be placed into the state until right before they're about to be executed/cancel (via the modal). Since only one modal can be open at a time I think this makes sense.

What isn't configurable is the message displayed to the user, so that does limit the number of confirmation prompts this can be used with. Passing the title and description to show may make sense to enable multiple confirmation messages.

Copy link
Member

@suddjian suddjian Jan 22, 2020

Choose a reason for hiding this comment

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

Oh, I see. I stand corrected. I'm still a little confused by this though. What's the advantage of a stateful setup like this instead of using a separate ConfirmStatusChange for each action that needs confirmation, and passing the callback in as a prop?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I had modal reuse in mind when I was writing it, but that kind of fell apart once I had to use it in the actions cell renderer. I'll change it, you're right, it's less confusing to pass stuff as props.

}

return (
<ConfirmStatusChange title={t('Please Confirm')} description={`${t('Are you sure you want to delete')} ${original.dashboard_title}?`}>
Copy link
Member

Choose a reason for hiding this comment

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

This <ConfirmStatusChange> could wrap just the delete button instead of the entire collection of buttons.

this.setState({
callback: () => callback(event),
callbackArgs,
Copy link
Member

Choose a reason for hiding this comment

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

If the callback args is supposed to be the DOM event, this will not work as intended. Events can't be referenced asynchronously. https://reactjs.org/docs/events.html#event-pooling

Copy link
Member

Choose a reason for hiding this comment

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

You'd need to check if the arg is an Event, and call .persist() on it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, I was cloning it before. None of my current use cases rely on the dom event, but probably best to handle that to avoid future weirdness.

@nytai nytai mentioned this pull request Jan 23, 2020
12 tasks
Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

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

LGTM

I like the hooks and good job DRYing things up!

@mistercrunch mistercrunch merged commit a0cda32 into apache:master Jan 27, 2020
@mistercrunch mistercrunch deleted the tai/bulk-actions branch January 27, 2020 18:23
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.36.0 labels Feb 28, 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 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants