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

feat(dashboard): Add divider component in native filters #17410

Merged
merged 13 commits into from
Nov 24, 2021

Conversation

m-ajay
Copy link
Contributor

@m-ajay m-ajay commented Nov 11, 2021

SUMMARY

Let users create divider component to give more context to the native filters

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

divider-component (1)

TESTING INSTRUCTIONS

  1. Enable feature flag DASHBOARD_NATIVE_FILTERS
  2. Go to any dashboard, and click edit (✏️) near filters.
  3. Hover over Add button on the lower left of the pop-up and select divider.
  4. Fill in title and description and hit save
  5. See the divider in the Filter bar

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: DASHBOARD_NATIVE_FILTERS
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@m-ajay m-ajay changed the title Feat/add filter description component feat(dashboard): Add divider component in native filters Nov 11, 2021
@m-ajay m-ajay marked this pull request as ready for review November 11, 2021 20:08
@codecov
Copy link

codecov bot commented Nov 11, 2021

Codecov Report

Merging #17410 (c9135ec) into master (c216565) will increase coverage by 0.20%.
The diff coverage is 79.86%.

Impacted file tree graph

@@            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              
Flag Coverage Δ
javascript 71.09% <79.86%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...components/DashboardBuilder/DashboardContainer.tsx 82.69% <33.33%> (-3.03%) ⬇️
...nd/src/dashboard/components/nativeFilters/state.ts 70.49% <47.36%> (-4.06%) ⬇️
...mponents/nativeFilters/FiltersConfigModal/utils.ts 65.24% <61.90%> (+0.32%) ⬆️
...veFilters/FiltersConfigModal/DividerConfigForm.tsx 66.66% <66.66%> (ø)
...ilters/FilterBar/FilterControls/FilterControls.tsx 82.69% <85.71%> (+1.84%) ⬆️
...tiveFilters/FiltersConfigModal/FilterTitlePane.tsx 92.85% <87.50%> (+0.85%) ⬆️
...eFilters/FiltersConfigModal/FiltersConfigModal.tsx 87.11% <93.33%> (-0.61%) ⬇️
...src/dashboard/components/FiltersBadge/selectors.ts 79.72% <100.00%> (+0.27%) ⬆️
...ts/nativeFilters/FilterBar/FilterControls/utils.ts 77.77% <100.00%> (+6.34%) ⬆️
...tiveFilters/FilterBar/FilterSets/FiltersHeader.tsx 89.36% <100.00%> (+0.47%) ⬆️
... and 35 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 c216565...c9135ec. Read the comment docs.

@junlincc junlincc requested review from simcha90, kgabryje, amitmiran137 and riahk and removed request for simcha90 November 11, 2021 23:15
@geido
Copy link
Member

geido commented Nov 15, 2021

/testenv up FEATURE_DASHBOARD_NATIVE_FILTERS=true FEATURE_DASHBOARD_CROSS_FILTERS=true FEATURE_DASHBOARD_NATIVE_FILTERS_SET=true FEATURE_DASHBOARD_FILTERS_EXPERIMENTAL=true

@github-actions
Copy link
Contributor

@geido Ephemeral environment spinning up at http://34.212.219.226:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

Copy link
Member

@geido geido left a 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:

  1. 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.
    Screen Shot 2021-11-15 at 15 54 39

  2. 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.

Screen Shot 2021-11-15 at 15 57 16

  1. 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.

  2. 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
    Screen Shot 2021-11-15 at 16 03 17

Comment on lines 326 to 333
tab={t(
`All Filters (${
filterValues.filter(
filterValue =>
filterValue.type === NativeFilterType.NATIVE_FILTER,
).length
})`,
)}
Copy link
Member

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.

Comment on lines +119 to 134
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');
});
Copy link
Member

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?

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.

a few comments

if (filter.type === NativeFilterType.DIVIDER) {
return (
<div>
<h3>{(filter as Divider).title}</h3>
Copy link
Member

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`
Copy link
Member

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;
Copy link
Member

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;
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 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

@m-ajay
Copy link
Contributor Author

m-ajay commented Nov 18, 2021

@geido Thanks for the comments.
For comment 3, do you have any mockup? I tried to add some spacing in the modal, but, due to limited space, it did not look good.
About comment 4 - I'm not sure if we need a tool tip. I feel like user should be responsible for adding the content in a way that it doesn't break the filter bar. Even if we are adding a tooltip, we will have to truncate the content in an arbitrary length. I'm not sure if we should do that.

@m-ajay m-ajay requested review from etr2460 and geido November 18, 2021 21:47
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.

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})`}
Copy link
Member

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

@etr2460 etr2460 merged commit 9576478 into apache:master Nov 24, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

AAfghahi pushed a commit that referenced this pull request Jan 10, 2022
* 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
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 labels Mar 13, 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/XL 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants