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

[explore] Modal to edit chart properties #9051

Merged
merged 5 commits into from
Feb 4, 2020
Merged

Conversation

suddjian
Copy link
Member

@suddjian suddjian commented Jan 30, 2020

CATEGORY

Choose one

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

SUMMARY

Adds a menu option to Explore which opens a modal to edit the properties of the chart. This allows changing the chart properties without going to the autogenerated edit page - part of an ongoing effort to deprecate the CRUD pages.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2020-01-29 at 4 06 19 PM

Screen Shot 2020-01-29 at 4 59 02 PM

TEST PLAN

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

@suddjian suddjian changed the title [charts [charts] Modal to edit chart properties Jan 30, 2020
@suddjian suddjian changed the title [charts] Modal to edit chart properties [explore] Modal to edit chart properties Jan 30, 2020
@codecov-io
Copy link

codecov-io commented Jan 30, 2020

Codecov Report

Merging #9051 into master will decrease coverage by 0.28%.
The diff coverage is 6.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9051      +/-   ##
==========================================
- Coverage   59.43%   59.15%   -0.29%     
==========================================
  Files         369      370       +1     
  Lines       11743    11813      +70     
  Branches     2884     2899      +15     
==========================================
+ Hits         6980     6988       +8     
- Misses       4584     4646      +62     
  Partials      179      179
Impacted Files Coverage Δ
...ts/src/explore/components/ExploreActionButtons.jsx 100% <ø> (ø) ⬆️
.../assets/src/explore/components/PropertiesModal.jsx 0% <0%> (ø)
...rset/assets/src/explore/reducers/exploreReducer.js 25% <0%> (-0.93%) ⬇️
...erset/assets/src/explore/actions/exploreActions.js 34.32% <33.33%> (-0.05%) ⬇️
...sets/src/explore/components/DisplayQueryButton.jsx 51.38% <37.5%> (-1.74%) ⬇️
.../assets/src/SqlLab/components/AceEditorWrapper.jsx 54.21% <0%> (ø) ⬆️
superset/assets/src/components/TableSelector.jsx 78.35% <0%> (+0.32%) ⬆️
...uperset/assets/src/dashboard/components/Header.jsx 42.06% <0%> (+0.93%) ⬆️

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 a267446...240388f. Read the comment docs.

@suddjian suddjian mentioned this pull request Jan 30, 2020
12 tasks
Copy link
Member

@nytai nytai left a comment

Choose a reason for hiding this comment

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

Just one question, otherwise LGTM!

bsSize="sm"
value={description}
onChange={event => setDescription(event.target.value)}
style={{ maxWidth: '100%' }}
Copy link
Member

Choose a reason for hiding this comment

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

Inline styles!? Not sure the exact issue this addresses, but we can probably just slap this on all FormControl components via the theme if needed, so it needn't be repeated in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps. If you think it's worth messing around with global styles for this specific thing I'll do it. Without that line, you can grab+drag the textarea out into the right column of the modal layout.

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Snark/nits inline, but LGTM! 👍

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

Some comments, i don't think anything blocking, but would appreciate you taking a look!

superset/assets/src/explore/components/PropertiesModal.jsx Outdated Show resolved Hide resolved
}

// values of form inputs
const [name, setName] = useState(slice.slice_name || '');
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason we default to empty string here? Seems like null would make sense since that's what you're sending to the server, and then in the UI we can replace with an empty string if needed.

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 went with empty string since this is used for the state of the <input>, and input values should not be null. Empty strings are converted to null when sending, to allow users to unset fields. It's cleaner this way IMO.

superset/assets/src/explore/components/PropertiesModal.jsx Outdated Show resolved Hide resolved
superset/assets/src/explore/components/PropertiesModal.jsx Outdated Show resolved Hide resolved
superset/assets/src/explore/components/PropertiesModal.jsx Outdated Show resolved Hide resolved
bsSize="sm"
value={cacheTimeout}
onChange={event =>
setCacheTimeout(event.target.value.replace(/[^0-9]/, ''))
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 if you made the FormControl's input type "number" then you could get rid of this logic

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what I did at first, but I wasn't sure if we wanted to allow non-integers. Do you have any insight into whether that would be ok?

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 marshmallow schema on the endpoint wants an integer

Copy link
Member

Choose a reason for hiding this comment

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

I suppose that when sending the request, you could do a parseInt on the value to remove the decimal. Maybe that's sufficient then? At least we don't need to run the validator onChange then

Copy link
Member Author

Choose a reason for hiding this comment

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

parseInt can return NaN for certain inputs. An input of type="number" allows using "e" and decimal points. I'd prefer not to open the NaN door, personally.

Copy link
Member Author

@suddjian suddjian Jan 31, 2020

Choose a reason for hiding this comment

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

We could use type="number alongside the regex filter to get the extra little browser widgets that come with number inputs if you think that'd be valuable, but I think the regex does a job here that isn't offered by html.

superset/assets/src/explore/components/PropertiesModal.jsx Outdated Show resolved Hide resolved
Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

lgtm with one other naming nit. you can either add the number type for the text box or not, up to you

owners: owners.map(o => o.value),
};
try {
const res = await SupersetClient.put({
Copy link
Member

Choose a reason for hiding this comment

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

missed this before, please use complete words for variable names

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Thanks for the review!

@dpgaspar dpgaspar merged commit d4d7134 into apache:master Feb 4, 2020
@suddjian suddjian deleted the chart-edit branch February 4, 2020 17:41
@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/L 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants