-
Notifications
You must be signed in to change notification settings - Fork 14k
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
feat(native-filters): Add default first value to select filter #13726
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small remark
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #13726 +/- ##
==========================================
- Coverage 79.30% 78.91% -0.40%
==========================================
Files 939 939
Lines 47541 47561 +20
Branches 5938 5949 +11
==========================================
- Hits 37703 37531 -172
- Misses 9717 9890 +173
- Partials 121 140 +19
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simcha90 when the default checkbox is checked, user can not remove default select by clicking x.
Expected behavior: User should be able to remove default select anytime, and it clears the checkbox when value is removed. please address it before merging. thanks!
� Conflicts: � superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/DefaultValue.tsx
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
Outdated
Show resolved
Hide resolved
This reverts commit 58b9199
Ephemeral environment shutdown and build artifacts deleted. |
� Conflicts: � superset-frontend/package-lock.json � superset-frontend/package.json � superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment about readability, other than that LGTM
const handleChange = (value?: SelectValue | number | string) => { | ||
let selectValue: (number | string)[]; | ||
if (value === FIRST_VALUE) { | ||
selectValue = forceFirstValue ? [] : firstItem; | ||
} else { | ||
selectValue = ensureIsArray<number | string>(value); | ||
} | ||
setValues(selectValue); | ||
|
||
const emptyFilter = | ||
enableEmptyFilter && !inverseSelection && resultValue?.length === 0; | ||
enableEmptyFilter && !inverseSelection && selectValue?.length === 0; | ||
|
||
// Set currentState value for a case of non-`defaultToFirstItem` | ||
const stateValue = selectValue.length ? selectValue : null; | ||
|
||
const dataMask = { | ||
extraFormData: getSelectExtraFormData( | ||
col, | ||
resultValue, | ||
selectValue, | ||
emptyFilter, | ||
inverseSelection, | ||
), | ||
currentState: { | ||
value: resultValue.length ? resultValue : null, | ||
// We need to save in state `FIRST_VALUE` as some const and not as REAL value, | ||
// because when FiltersBar check if all filters initialized it compares `defaultValue` with this value | ||
// and because REAL value can be unpredictable for users that have different data for same dashboard we use `FIRST_VALUE` | ||
value: value === FIRST_VALUE ? FIRST_VALUE : stateValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new logic this section is becoming slightly difficult to follow and could potentially be simplified. There's a few value === FIRST_VALUE
checks, and the names value
, selectValue
, stateValue
make it not obvious to the casual reader what these mean. I propose making these more explicit, e.g. renaming value
to selectedValue
(=what's the current selection) and constructing stateValue
(=what goes in currentState
) earlier on so we don't need to do a
currentState: { value: value === FIRST_VALUE ? FIRST_VALUE : stateValue }
later on. It would be nice if stateValue
would already be fully ready by the time we arrive at that point, making the final currentState
look more like this:
currentState: { value: stateValue }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified logic can you look please one more time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* master: fix: unable to apply logging format (#14074) refactor: Bootstrap to AntD - Slider (#13989) chore(spa refactor): refactoring dashboard to use api's instead of bootstrapdata (#13306) fix(listview): update listview feature flag (#13906) Add docs for configuring Docker Compose setup (#13961) feat: invalid password error message (Postgres) (#14038) fix: flacky test in test_update_dataset_item_w_override_columns (#14082) feat: Implement Celery SoftTimeLimit handling (#13740) feat: only send alert error emails to owners of the alert (#13862) feat: add descriptions to report emails (#13827) Make chart exclude itself from cross filtering (#14046) fix: fix bug when remove chart not removing it's related cross filter data (#14081) feat(native-filters): Add default first value to select filter (#13726) feat: Make async query JWT cookie domain configurable (#14007) fix: add exception to catch session not having JWT (#14036) # Conflicts: # superset-frontend/src/dashboard/actions/hydrate.js # superset/views/core.py
* master: (53 commits) test: Adds tests to the UndoRedoKeyListeners component (#13919) chore: Adds dataMask reducer to reducerIndex (#13951) test: Tests audit for the Dashboard FilterBar (#13916) fix: unable to apply logging format (#14074) refactor: Bootstrap to AntD - Slider (#13989) chore(spa refactor): refactoring dashboard to use api's instead of bootstrapdata (#13306) fix(listview): update listview feature flag (#13906) Add docs for configuring Docker Compose setup (#13961) feat: invalid password error message (Postgres) (#14038) fix: flacky test in test_update_dataset_item_w_override_columns (#14082) feat: Implement Celery SoftTimeLimit handling (#13740) feat: only send alert error emails to owners of the alert (#13862) feat: add descriptions to report emails (#13827) Make chart exclude itself from cross filtering (#14046) fix: fix bug when remove chart not removing it's related cross filter data (#14081) feat(native-filters): Add default first value to select filter (#13726) feat: Make async query JWT cookie domain configurable (#14007) fix: add exception to catch session not having JWT (#14036) Use consistent chart value (#14031) fix: Use superset generic db to catch external_metadata queries (#13974) ...
…e#13726) * feat: native filters first default value * fix: fix CR notes * feat: add support for `Place` type * refactor: sync with master * feat: add first value to Select filters * refactor: fix CR notes * refactor: updates usage of `ownFilters` to `ownState` * Revert "refactor: updates usage of `ownFilters` to `ownState`" This reverts commit 58b9199 * fix: revert mocks * fix: fix CR notes * chore: update package json * chore: update package json * chore: update package json * test: fix tests * fix: fix BE empty metrics * lint: fix lint * fix: fix BE empty metrics * refactor: fix Cr notes
…e#13726) * feat: native filters first default value * fix: fix CR notes * feat: add support for `Place` type * refactor: sync with master * feat: add first value to Select filters * refactor: fix CR notes * refactor: updates usage of `ownFilters` to `ownState` * Revert "refactor: updates usage of `ownFilters` to `ownState`" This reverts commit 58b9199 * fix: revert mocks * fix: fix CR notes * chore: update package json * chore: update package json * chore: update package json * test: fix tests * fix: fix BE empty metrics * lint: fix lint * fix: fix BE empty metrics * refactor: fix Cr notes
SUMMARY
This PR add option to choose by default first value for select filter plugin. This feature has more priority then default value, so if this feature enabled it will used instead of default value
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Screen.Recording.2021-03-22.at.10.57.00.mov
TEST PLAN
ADDITIONAL INFORMATION