-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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(dashboard): Add divider component in native filters #17410
feat(dashboard): Add divider component in native filters #17410
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17410 +/- ##
==========================================
+ Coverage 76.78% 76.98% +0.19%
==========================================
Files 1048 1045 -3
Lines 56516 56464 -52
Branches 7805 7825 +20
==========================================
+ Hits 43396 43469 +73
+ Misses 12866 12741 -125
Partials 254 254
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
/testenv up FEATURE_DASHBOARD_NATIVE_FILTERS=true FEATURE_DASHBOARD_CROSS_FILTERS=true FEATURE_DASHBOARD_NATIVE_FILTERS_SET=true FEATURE_DASHBOARD_FILTERS_EXPERIMENTAL=true |
@geido Ephemeral environment spinning up at http://34.212.219.226:8080. Credentials are |
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.
Hey @m-ajay some comments:
-
Can we make the tooltip appear on the left side? Also, when you go over the two actions, there is no hover style. It would be great to add a little bit of style so it feels less plain.
-
I was able to save the Divider with an empty title by adding an empty char. Not as important, but white spaces are allowed in the description too.
-
Can we differentiate the filters from the dividers in the modal in some ways? For example, we might add a border to the dividers or separate them with additional spacing.
-
What do you think of using a tooltip for the description of the divider consistently with the filters? I am not sure if that was a conscious design decision but it feels like having a long description placed in the filter sidebar might occupy unjustified space
tab={t( | ||
`All Filters (${ | ||
filterValues.filter( | ||
filterValue => | ||
filterValue.type === NativeFilterType.NATIVE_FILTER, | ||
).length | ||
})`, | ||
)} |
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.
Can we move the filtering part in a const outside for the sake of readability? Also, the naming convention we adopted is All filters
, it would be great to fix it here. Finally, I think the length itself should be outside of the localization function as it is a non-translatable value.
test('add divider', async () => { | ||
defaultRender(); | ||
const addButton = screen.getByText('Add')!; | ||
fireEvent.mouseOver(addButton); | ||
const addFilterButton = await screen.findByText('Divider'); | ||
await act(async () => { | ||
fireEvent( | ||
addFilterButton, | ||
new MouseEvent('click', { | ||
bubbles: true, | ||
cancelable: true, | ||
}), | ||
); | ||
}); | ||
expect(defaultProps.onAdd).toHaveBeenCalledWith('DIVIDER'); | ||
}); |
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.
Is it possible to use the userEvent
methods instead of fireEvent
?
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.
a few comments
if (filter.type === NativeFilterType.DIVIDER) { | ||
return ( | ||
<div> | ||
<h3>{(filter as Divider).title}</h3> |
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'm very sad that the if statement above didn't guarantee that the typing is correct :( perhaps it's safer to do 'title' in filter && filter.title
here instead?
removedFilters: Record<string, FilterRemoval>; | ||
currentFilterId: string; | ||
filterGroups: string[][]; | ||
erroredFilters: string[]; | ||
} | ||
|
||
const StyledI = styled.div` |
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.
Can we have a better name for this? not sure what an I
is
</Container> | ||
); | ||
|
||
export default SectionConfigForm; |
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.
should this be called DividerConfigForm
? Let's be consistent throughout
id: string; | ||
title: string; | ||
description: string; | ||
type: NativeFilterType; |
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 think if you set type: typeof NativeFilterType.DIVIDER
(or something like that, maybe even just type: 'DIVIDER'
) then you won't need to do type coercion above anymore
@geido Thanks for the comments. |
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 more comment, otherwise lgtm!
@@ -320,7 +323,7 @@ const FilterBar: React.FC<FiltersBarProps> = ({ | |||
activeKey={editFilterSetId ? TabIds.AllFilters : undefined} | |||
> | |||
<Tabs.TabPane | |||
tab={t(`All Filters (${filterValues.length})`)} | |||
tab={`${t('All filters')} (${numberOfFilters})`} |
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 know you didn't add this (and instead are just touching it to update the casing of the string), but this translation string isn't correct. you need something like:
t('All filters (%(numberOfFilters))', numberOfFilters)
see here for more details: https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-core/src/translation#api
you'll also want to change the one on line 346
Ephemeral environment shutdown and build artifacts deleted. |
* Tests are working, type errors are fixed * Fix filterset * add license header to the new file * fix test * PR comments * Linting * test fix * small fix
SUMMARY
Let users create divider component to give more context to the native filters
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
DASHBOARD_NATIVE_FILTERS
ADDITIONAL INFORMATION