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: Implement new filters panel #18449

Merged
merged 11 commits into from
May 21, 2024
Merged

feat: Implement new filters panel #18449

merged 11 commits into from
May 21, 2024

Conversation

vsgoulart
Copy link
Contributor

Description

Creates feature flagged side panel with new filters UI

Related issues

related #17714

@vsgoulart vsgoulart requested review from volodymyr-melnykc and a team May 13, 2024 08:35
@github-actions github-actions bot added the component/tasklist Related to the Tasklist component/team label May 13, 2024
@vsgoulart
Copy link
Contributor Author

@volodymyr-melnykc Could you take a look into this locally?
I can show you how to enable the feature flag

currentParams.entries(),
);
const values: Record<string, string> =
(sortBy === 'completion' && !['custom', 'completed'].includes(sortBy)) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be simplified to sortBy === 'completion'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, there's a bug. It should be (sortBy === 'completion' && !['custom', 'completed'].includes(filter))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll actually use you suggestion, it will make it more complicated than it needs to be if do what I originally wanted to do

if (filter === 'custom') {
const customFilters = getStateLocally('customFilters')?.custom;
const customFiltersParams =
filter === 'custom' && customFilters !== undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

filter === 'custom' always evaluates to true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it was a copy and paste mistake

Comment on lines 60 to 69
Object.keys(customFiltersParams).length > 0
? new URLSearchParams({
...convertedParams,
...values,
...customFiltersParams,
})
: new URLSearchParams({
...convertedParams,
...values,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be simplified to

new URLSearchParams({
  ...convertedParams,
  ...values,
  ...customFiltersParams
})

The key length check seems redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there were some type issues before on the old implementation but on this one I do some manipulation before so it's not really necessary anymore

sortBy === undefined
? {filter}
: {filter, sortBy};
if (filter === 'custom') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would extract this as a function which returns an object with the values to update. That way you don't have to repeat the params to delete.

const {filter, userId, currentParams} = options;
const {sortBy, ...convertedParams} = Object.fromEntries( currentParams.entries() );
const customFilterParams = filter === 'custom' ? getCustomFilterParams( userId ) : {};

const updatedParams = new URLSearchParams({
  filter,
  ...convertedParams,
  ...values,
  ...customFilterParams,
});

if (sortBy !== undefined && sortBy !== 'completion') {
  updatedParams.set('sortBy', sortBy);
}
if (filter === 'completed') {
  updatedParams.set('sortBy', 'completion');
}

difference(
  CUSTOM_FILTERS_PARAMS,
  Object.keys(customFiltersParams),
).forEach((param) => {
  updatedParams.delete(param);
});

return updatedParams.toString();

Comment on lines 156 to 160
activeParam={{
key: 'filter',
value: 'all-open',
}}
isActiveOnEmpty
Copy link
Contributor

Choose a reason for hiding this comment

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

What are your thoughts on having a isActive prop? This is the only instance that uses isActiveOnEmpty.

isActive={filter === 'all-open' || filter === null}

Just seems like you're passing a lot of data to do this comparison in the Link component rather than here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, this is better

@vsgoulart
Copy link
Contributor Author

@douglasbouttell-camunda Should be ready for review again

Copy link
Contributor

@douglasbouttell-camunda douglasbouttell-camunda left a comment

Choose a reason for hiding this comment

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

Looks good. Some things to think about as you progress.

return updatedParams.toString();
}

const CollapsiblePanel: React.FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you're trying to build a collapsible menu here. I would start with markup that looks like:

<nav>
  <ul>
    <li>
     <a aria-owns="filters-menu" aria-expanded="false">Filters <Icon/></a>
     <ul role="group" id="filters-menu">
      <li>...</li>
     </ul>
    <li>
    <li>
     <a aria-owns="custom-filters-menu" aria-expanded="false">Custom Filters <Icon/></a>
     <ul role="group" id="custom-filters-menu">
      <li>...</li>
     </ul>
    <li>
  </ul>
</nav>

The rest is styles.

I'm fine to keep it like this for now but we should make a proper menu component in the near future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@douglasbouttell-camunda I can do that, but this menu will only have one group for the foreseeable future

&.twoColumns {
grid-template-columns:
layout.to-rem(312px)
1fr !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the !important necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just wanted to make sure it wouldn't break the layout with the flag disabled, but this feature flag won't live for long so I'll just remove for now

@vsgoulart vsgoulart enabled auto-merge May 17, 2024 12:41
@vsgoulart vsgoulart added this pull request to the merge queue May 17, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 17, 2024
@vsgoulart vsgoulart added this pull request to the merge queue May 21, 2024
Merged via the queue into main with commit 4694aa0 May 21, 2024
28 checks passed
@vsgoulart vsgoulart deleted the fe-17714-filters branch May 21, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tasklist Related to the Tasklist component/team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants