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

UIIN-2533: Show facet options, if they exist, after clicking the +More button. #2309

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change history for ui-inventory

## [10.0.1](IN PROGRESS)
* Show facet options, if they exist, after clicking the +More button. Refs UIIN-2533.

Copy link
Member

Choose a reason for hiding this comment

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

Generally, our practice is to target all changes to the master branch and then to cherry-pick fixes onto patch branches. If somebody else's PR hits master before yours lands, you'll have to do this anyway, so I just plan for things to work out this way. I would do it like this:

  1. Bump the version on master in package.json to 10.1.0. You'll save a PR later if you do it in a separate PR now, but it's up to you. Either way it's two PRs in the end, so 🤷 .
  2. Merge this PR.
  3. Split a release branch named b10.0 from the commit where master was tagged and push it up so others can also pick bug fixes onto : (get checkout master; git checkout -b b10.0 v10.0.0; git push -u origin head).
  4. If you bumped the version in step 1 in a separate PR, you can just pick the commit from this PR onto your release branch: git cherry-pick -x SOME_HASH; git push, you're done! If you bumped the version in step 1 in this PR, you'll need to split a branch from b10.0, pick this fix onto it, fix the version in package.json, push the branch and open a PR with a target of b10.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zburke I'll wait until this #2310 PR with an update to version 10.1.0 in package.json is merged.

## [10.0.0](https://github.com/folio-org/ui-inventory/tree/v10.0.0) (2023-10-13)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v9.4.12...v10.0.0)

Expand Down
36 changes: 19 additions & 17 deletions src/components/CheckboxFacet/CheckboxFacetList.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,25 @@ function CheckboxFacetList({
<FormattedMessage id="ui-inventory.noMatchingOptions" />
}

{!isPending && dataOptions.map(({ count, value, label, disabled, readOnly }) => {
const name = typeof label === 'string' ? label : value;
return (
<Checkbox
id={`clickable-filter-${fieldName}-${kebabCase(name)}`}
data-test-checkbox-filter-data-option={value}
key={value}
label={label}
labelInfo={count}
name={name}
disabled={disabled}
readOnly={readOnly}
checked={selectedValues.includes(value)}
onChange={onChange(value)}
/>
);
})}
{!isPending && dataOptions
.filter(({ isDeleted }) => !isDeleted)
.map(({ count, value, label, disabled, readOnly }) => {
const name = typeof label === 'string' ? label : value;
return (
<Checkbox
id={`clickable-filter-${fieldName}-${kebabCase(name)}`}
data-test-checkbox-filter-data-option={value}
key={value}
label={label}
labelInfo={count}
name={name}
disabled={disabled}
readOnly={readOnly}
checked={selectedValues.includes(value)}
onChange={onChange(value)}
/>
);
})}
</div>

{!isPending && showMore && (
Expand Down
21 changes: 21 additions & 0 deletions src/components/CheckboxFacet/CheckboxFacetList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const dataOptions = [
label: 'Check Box 2',
value: 'checkBox2',
},
{ id: 'fakeId', isDeleted: true },
];
const selectedValues = ['checkBox1'];
const fieldName = 'testFacet';
Expand Down Expand Up @@ -123,4 +124,24 @@ describe('CheckboxFacetList', () => {
const checkBoxs = screen.findAllByRole('checkbox');
expect(checkBoxs).toMatchObject({});
});

it('should not render deleted options', () => {
render(
<CheckboxFacetList
dataOptions={dataOptions}
selectedValues={selectedValues}
showMore={showMore}
showSearch={showSearch}
onMoreClick={onMoreClick}
onSearch={onSearch}
onChange={onChange}
fieldName={fieldName}
isPending={isPending}
/>,
);

const allOptions = screen.getAllByRole('checkbox').length;

expect(allOptions).toBe(2);
});
});
3 changes: 3 additions & 0 deletions src/components/InstanceFilters/InstanceFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ const InstanceFilters = props => {
selectedValues={activeFilters[FACETS.STATUS]}
isPending={getIsPending(FACETS.STATUS)}
onChange={onChange}
isFilterable
onSearch={handleFilterSearch}
onFetch={handleFetchFacets}
/>
</Accordion>
<Accordion
Expand Down
5 changes: 5 additions & 0 deletions src/facetUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export const getFacetOptions = (selectedFiltersId, entries, facetData, key, pars
if (facet) {
const option = parse(facetDataMap.get(entry.id), entry.totalRecords);
accum.push(option);
} else {
accum.push({
id: entry.id,
isDeleted: true,
});
}
return accum;
}, []);
Expand Down
1 change: 1 addition & 0 deletions src/facetUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('getFacetOptions', () => {
const key = 'id';
const expectedOptions = [
{ label: 'Filter 1', value: 'filter1', count: 2 },
{ id: 'invalid', isDeleted: true },
{ label: 'Filter 2', value: 'filter2', count: 0 },
];
expect(getFacetOptions(selectedFiltersId, entries, facetData, key)).toEqual(expectedOptions);
Expand Down
Loading