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

UIEUS-374: Add reportRelease filter #502

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* COUNTER statistics: Show the COUNTER release version for reports in an additional column ([UIEUS-368](https://folio-org.atlassian.net/browse/UIEUS-368))
* Leverage `yarn.lock` ([UIEUS-377](https://folio-org.atlassian.net/browse/UIEUS-377))
* COUNTER 5.1 Support: Harvesting configuration for usage data providers ([UIEUS-357](https://folio-org.atlassian.net/browse/UIEUS-357))
* Add filter for COUNTER report release ([UIEUS-374](https://folio-org.atlassian.net/browse/UIEUS-374))

## [9.0.0](https://github.com/folio-org/ui-erm-usage/tree/v9.0.0) (2024-04-17)
* *BREAKING* Use `multipart/form-data` to upload COUNTER reports ([UIEUS-353](https://folio-org.atlassian.net/browse/UIEUS-353))
Expand Down
107 changes: 23 additions & 84 deletions src/components/UDPFilters/UDPFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const UDPFilters = ({
tags: [],
errorCodes: [],
reportTypes: [],
reportReleases: [],
});

const isFilterDefinedLocally = filter => {
Expand Down Expand Up @@ -134,94 +135,31 @@ const UDPFilters = ({
);
};

const renderTagsFilter = () => {
const tagFilters = activeFilters.tags || [];

return (
<Accordion
closedByDefault
id="clickable-tags-filter"
displayClearButton={tagFilters.length > 0}
header={FilterAccordionHeader}
label={<FormattedMessage id="ui-erm-usage.general.tags" />}
onClearFilter={() => {
filterHandlers.clearGroup('tags');
}}
separator={false}
>
<MultiSelectionFilter
ariaLabelledBy="clickable-tags-filter"
dataOptions={filterState.tags}
id="tags-filter"
name="tags"
onChange={e => filterHandlers.state({
...activeFilters,
tags: e.values
})
}
selectedValues={tagFilters}
/>
</Accordion>
);
};

const renderErrorCodesFilter = () => {
const errorCodesFilters = activeFilters.errorCodes || [];

return (
<Accordion
closedByDefault
id="clickable-error-codes-filter"
displayClearButton={errorCodesFilters.length > 0}
header={FilterAccordionHeader}
label={<FormattedMessage id="ui-erm-usage.general.errorCodes" />}
onClearFilter={() => {
filterHandlers.clearGroup('errorCodes');
}}
separator={false}
>
<MultiSelectionFilter
ariaLabelledBy="clickable-error-codes-filter"
dataOptions={filterState.errorCodes}
id="error-codes-filter"
name="errorCodes"
onChange={e => filterHandlers.state({
...activeFilters,
errorCodes: e.values
})
}
selectedValues={errorCodesFilters}
/>
</Accordion>
);
};

const renderReportTypesFiler = () => {
const reportTypesFilters = activeFilters.reportTypes || [];
const renderMultiSelectionFilter = (key, closedByDefault = true) => {
const groupFilters = activeFilters[key] || [];

return (
<Accordion
closedByDefault
id="clickable-report-types-filter"
displayClearButton={reportTypesFilters.length > 0}
closedByDefault={closedByDefault}
displayClearButton={groupFilters.length > 0}
header={FilterAccordionHeader}
label={<FormattedMessage id="ui-erm-usage.general.reportTypes" />}
onClearFilter={() => {
filterHandlers.clearGroup('reportTypes');
}}
id={`filter-accordion-${key}`}
label={<FormattedMessage id={`ui-erm-usage.general.${key}`} />}
onClearFilter={() => { filterHandlers.clearGroup(key); }}
separator={false}
>
<MultiSelectionFilter
ariaLabelledBy="clickable-report-types-filter"
dataOptions={filterState.reportTypes}
id="report-types-filter"
name="reportTypes"
onChange={e => filterHandlers.state({
...activeFilters,
reportTypes: e.values
})
}
selectedValues={reportTypesFilters}
ariaLabelledBy={`clickable-filter-${key}`}
dataOptions={filterState[key]}
id={`filter-${key}`}
name={key}
onChange={group => {
filterHandlers.state({
...activeFilters,
[group.name]: group.values
});
}}
selectedValues={groupFilters}
/>
</Accordion>
);
Expand All @@ -232,10 +170,11 @@ const UDPFilters = ({
{renderCheckboxFilter('harvestingStatus')}
{renderCheckboxFilter('harvestVia')}
{renderCheckboxFilter('aggregators', true)}
{renderReportTypesFiler()}
{renderMultiSelectionFilter('reportTypes')}
{renderMultiSelectionFilter('reportReleases')}
{renderCheckboxFilter('hasFailedReport', true)}
{renderTagsFilter()}
{renderErrorCodesFilter()}
{renderMultiSelectionFilter('tags')}
{renderMultiSelectionFilter('errorCodes')}
</AccordionSet>
);
};
Expand Down
32 changes: 20 additions & 12 deletions src/components/views/UDPs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,28 +136,36 @@ describe('UDPs SASQ View', () => {
});

describe('check filters', () => {
it('harvesting status filter should be present', () => {
expect(document.querySelector('#filter-accordion-harvestingStatus')).toBeInTheDocument();
it('should be present the harvesting status filter', () => {
expect(screen.getByRole('button', { name: 'Harvesting status filter list' })).toBeInTheDocument();
});

it('harvestVia filter should be present', () => {
expect(document.querySelector('#filter-accordion-harvestVia')).toBeInTheDocument();
it('should be present the harvestVia filter', () => {
expect(screen.getByRole('button', { name: 'Harvest via filter list' })).toBeInTheDocument();
});

it('aggregators filter should be present', () => {
expect(document.querySelector('#filter-accordion-aggregators')).toBeInTheDocument();
it('should be present the aggregators filter', () => {
expect(screen.getByRole('button', { name: 'Aggregators filter list' })).toBeInTheDocument();
});

it('report types filter should be present', () => {
expect(document.querySelector('#clickable-report-types-filter')).toBeInTheDocument();
it('should be present the report types filter', () => {
expect(screen.getByRole('button', { name: 'Report types filter list' })).toBeInTheDocument();
});

it('has failed reports filter should be present', () => {
expect(document.querySelector('#filter-accordion-hasFailedReport')).toBeInTheDocument();
it('should be present the report releases filter', () => {
expect(screen.getByRole('button', { name: 'Report Releases filter list' })).toBeInTheDocument();
});

it('error codes filter should be present', () => {
expect(document.querySelector('#clickable-error-codes-filter')).toBeInTheDocument();
it('should be present the has failed reports filter', () => {
expect(screen.getByRole('button', { name: 'Has failed report(s) filter list' })).toBeInTheDocument();
});

it('should be present the tags filter', () => {
expect(screen.getByRole('button', { name: 'Tags filter list' })).toBeInTheDocument();
});

it('should be present the error codes filter', () => {
expect(screen.getByRole('button', { name: 'Error codes filter list' })).toBeInTheDocument();
});

it('reset all button should be present', () => {
Expand Down
8 changes: 7 additions & 1 deletion src/routes/UDPsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class UDPsRoute extends React.Component {
path: 'counter-reports/reports/types',
records: 'reportTypes'
},
reportReleases: {
type: 'okapi',
path: 'counter-reports/reports/releases',
records: 'reportReleases'
},
numFiltersLoaded: { initialValue: 1 }, // will be incremented as each filter loads
initializedFilterConfig: { initialValue: false },
query: {
Expand Down Expand Up @@ -193,7 +198,8 @@ class UDPsRoute extends React.Component {
aggregators: get(resources, 'aggregatorSettings.records', []),
tags: get(resources, 'tags.records', []),
errorCodes: get(resources, 'errorCodes.records', []),
reportTypes: get(resources, 'reportTypes.records', [])
reportTypes: get(resources, 'reportTypes.records', []),
reportReleases: get(resources, 'reportReleases.records', []),
}}
selectedRecordId={match.params.id}
onNeedMoreData={this.handleNeedMoreData}
Expand Down
7 changes: 7 additions & 0 deletions src/util/data/filterGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ const filterGroups = [
cql: 'reportTypes',
operator: '=',
values: [],
},
{
label: 'Report Releases',
name: 'reportReleases',
cql: 'reportReleases',
operator: '=',
values: [],
}
];

Expand Down
1 change: 1 addition & 0 deletions translations/ui-erm-usage/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"general.tags": "Tags",
"general.errorCodes": "Error codes",
"general.reportTypes": "Report types",
"general.reportReleases": "Report Releases",
elsenhans marked this conversation as resolved.
Show resolved Hide resolved
"general.edit": "Edit",
"general.note": "Note",
"general.year": "Year",
Expand Down