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

[feature][dashboard] Show/hide filter indicator on the applicable charts when filter options are open/close #8166

Merged

Conversation

graceguo-supercat
Copy link

@graceguo-supercat graceguo-supercat commented Sep 4, 2019

CATEGORY

Choose one

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

SUMMARY

This is part of dashboard filter indicator design:

AaGV6NPaiz

This PR also fixed a couple of issue after #7908 is released:

  1. To keep filter name in single line: show ellipsis for long filter name in tooltip. Still show full content for filter options values.

Screen Shot 2019-09-01 at 12 14 45 AM

  1. Show color bar when filter has a selected value(s):

M8LjqqgdJ7

  1. when user clicks filter indicator, we used to outline the filter_box. This outline will draw user attention, but after user worked on other area in the dashboard, I feel it is a little annoying with outline still on the old filter_box. So in this PR i make the outline only on about 2 seconds, and will turn off by itself.

hdcxRjNg5d

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

@kristw @etr2460 @kenchendesign

@graceguo-supercat graceguo-supercat changed the title [feature][dashboard] Show filter indicator on the applicable charts when filter is open [feature][dashboard] Show/hide filter indicator on the applicable charts when filter options are open/close Sep 4, 2019
@@ -56,12 +62,14 @@ class FilterIndicator extends React.PureComponent {
return (
<FilterTooltipWrapper tooltip={filterTooltip}>
<div
className="filter-indicator"
className={`filter-indicator ${
isFilterFieldActive ? 'isFilterFieldActive' : ''
Copy link
Member

Choose a reason for hiding this comment

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

this css class naming seems inconsistent, is there anything wrong with just adding on the class active along with filter-indicator? Or at least using dash case to match filter-indicator

Copy link
Author

Choose a reason for hiding this comment

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

now use active.

getChartAndLabelComponentIdFromPath() {
const { directPathToChild = [] } = this.props;
const result = {};
UNSAFE_componentWillReceiveProps(nextProps) {
Copy link
Member

Choose a reason for hiding this comment

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

instead of adding a new UNSAFE function, can we use one of the other recommendations here? https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops

Copy link
Author

Choose a reason for hiding this comment

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

now use getDerivedStateFromProps(props, state). Thanks!

this.setTypeCustomStartEnd();
}

// if user click outside popover, popover will hide and we will call onCloseDateFilterControl,
// but popover overlay trigger button is inside popover DOM h
Copy link
Member

Choose a reason for hiding this comment

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

looks like this comment didn't get finished?

Copy link
Author

Choose a reason for hiding this comment

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

😓 fixed, and added more comments.

@@ -53,6 +53,8 @@ export default function transformProps(chartProps) {
filtersFields,
instantFiltering,
onChange: onAddFilter,
onFilterMenuOpen: hooks.onFilterMenuOpen,
Copy link
Contributor

Choose a reason for hiding this comment

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

You could destructure these two handlers along with onAddFilter on line 30 above.

Copy link
Author

Choose a reason for hiding this comment

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

fixed.

@@ -338,7 +365,7 @@ export default class DateFilterControl extends React.Component {
});
return (
<Popover id="filter-popover" placement="top" positionTop={0}>
<div style={{ width: '250px' }}>
<div style={{ width: '250px' }} ref={(ref) => { this.popoverContainer = ref; }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

can make style constant outside of class so it won't create new object every time.

Copy link
Author

Choose a reason for hiding this comment

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

i fixed one place. there are quite a few inline css in this file and in the code base. we probably need to find a rule or consistent way to style component.

@codecov-io
Copy link

codecov-io commented Sep 7, 2019

Codecov Report

Merging #8166 into master will decrease coverage by 0.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8166      +/-   ##
==========================================
- Coverage   66.16%   66.14%   -0.02%     
==========================================
  Files         479      480       +1     
  Lines       22920    23002      +82     
  Branches     2524     2549      +25     
==========================================
+ Hits        15164    15214      +50     
- Misses       7622     7653      +31     
- Partials      134      135       +1
Impacted Files Coverage Δ
superset/assets/src/dashboard/util/propShapes.jsx 100% <ø> (ø) ⬆️
...t/assets/src/dashboard/reducers/getInitialState.js 0% <ø> (ø) ⬆️
superset/assets/src/dashboard/containers/Chart.jsx 91.66% <ø> (ø) ⬆️
superset/assets/src/chart/Chart.jsx 10.63% <0%> (-0.48%) ⬇️
superset/assets/src/chart/ChartRenderer.jsx 7.14% <0%> (-0.22%) ⬇️
...ets/src/visualizations/FilterBox/transformProps.js 0% <0%> (ø) ⬆️
.../assets/src/visualizations/FilterBox/FilterBox.jsx 5.93% <0%> (-0.68%) ⬇️
...ssets/src/dashboard/components/FilterIndicator.jsx 100% <100%> (ø) ⬆️
...et/assets/src/dashboard/reducers/dashboardState.js 76.36% <100%> (+2.89%) ⬆️
.../src/dashboard/components/FilterIndicatorGroup.jsx 100% <100%> (ø) ⬆️
... and 11 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 7546ea3...8894641. Read the comment docs.

@graceguo-supercat graceguo-supercat force-pushed the gg-showFilterIndicator branch 2 times, most recently from d0e4d38 to 4fc48e5 Compare September 7, 2019 06:55
@graceguo-supercat graceguo-supercat force-pushed the gg-showFilterIndicator branch 2 times, most recently from c1ae6d4 to eff509c Compare September 7, 2019 22:58
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.

just a couple more comments

}

handleFilterMenuClose() {
this.props.setFocusedFilterField();
Copy link
Member

Choose a reason for hiding this comment

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

not sure if this is super clear, might prefer unsetFocusedFilterField or perhaps setFocusedFilterField(null)?

Copy link
Author

Choose a reason for hiding this comment

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

the purpose of empty parameter here is to clear/unset focused filter field state. Reducer function expects to handle this case.
I thought we prefer no params than explicitly null params? I rarely see any example in our code that explicitly pass a null to function.

Copy link
Author

Choose a reason for hiding this comment

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

updated: added unsetFocusedFilterField action creator.

return (
<style>
{`.inFocus label[for=${labelName}] + .Select .Select-control {
border: 2px solid #00736a;
{`label[for=${columnName}] + .Select .Select-control {
Copy link
Member

Choose a reason for hiding this comment

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

Why is it again that we need to add inline style elements to the react element?

Copy link
Author

Choose a reason for hiding this comment

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

As an alternative, I can pass the selected filter field as prop to filter_box component. But first, it is deeply nested inside Chart component. And since it is a data visualization component, its props needs to be validated from superset-ui chart props. Overall it will be 100 times more troublesome than 2 lines of inline css. :)

by the way this is update existed inline style, not adding new.

Copy link
Member

Choose a reason for hiding this comment

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

seems legit

};
// window.clearTimeout's key is global,
// we don't want one chart clear out another's chart's timeout.
this.timer = [];
Copy link
Member

Choose a reason for hiding this comment

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

what type is timer? It's not apparent to me that this should be an array

Copy link
Author

Choose a reason for hiding this comment

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

not necessary to keep an instance variable for timer. removed.

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, thanks for addressing all the comments!

@graceguo-supercat graceguo-supercat merged commit b4a1234 into apache:master Sep 10, 2019
@graceguo-supercat graceguo-supercat deleted the gg-showFilterIndicator branch September 21, 2019 08:08
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.35.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.35.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants