diff --git a/src/utils/helpers.js b/src/utils/helpers.js index eaf24bc8..4781b2de 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -2,6 +2,7 @@ import { clone, setWith } from 'lodash'; import { CAPABILITIES, EDIT_CAPABILITIES_OPTIONS, + JOB_STATUSES, LOGS_FILTERS, } from '../constants'; @@ -161,10 +162,18 @@ export const filterByIds = (items, ids) => { }; export const getTransformedLogsFilterValue = (name, values) => { + const getWithDependentValue = (triggerValue, dependentValue) => { + return values.includes(triggerValue) + ? [...new Set([...values, dependentValue])] + : values.filter(value => value !== dependentValue); + }; + if (name === LOGS_FILTERS.CAPABILITY) { - return values.includes(CAPABILITIES.INSTANCE) - ? [...new Set([...values, CAPABILITIES.INSTANCE_MARC])] - : values.filter(value => value !== CAPABILITIES.INSTANCE_MARC); + return getWithDependentValue(CAPABILITIES.INSTANCE, CAPABILITIES.INSTANCE_MARC); + } + + if (name === LOGS_FILTERS.STATUS) { + return getWithDependentValue(JOB_STATUSES.REVIEW_CHANGES, JOB_STATUSES.REVIEWED_NO_MARC_RECORDS); } return values; diff --git a/src/utils/helpers.test.js b/src/utils/helpers.test.js index 37c9b7c3..1f4d7ba2 100644 --- a/src/utils/helpers.test.js +++ b/src/utils/helpers.test.js @@ -4,7 +4,7 @@ import { getTransformedLogsFilterValue, removeDuplicatesByValue } from './helpers'; -import { CAPABILITIES, LOGS_FILTERS } from '../constants'; +import { CAPABILITIES, JOB_STATUSES, LOGS_FILTERS } from '../constants'; describe('customFilter', () => { const dataOptions = [ @@ -265,4 +265,18 @@ describe('getTransformedLogsFilterValue', () => { expect(values).not.toContain(CAPABILITIES.INSTANCE_MARC); expect(result).toContain('userID'); }); + + it('should add REVIEWED_NO_MARC_RECORDS to the array if REVIEW_CHANGES is present', () => { + const values = [JOB_STATUSES.REVIEW_CHANGES]; + const result = getTransformedLogsFilterValue(LOGS_FILTERS.STATUS, values); + expect(result).toContain(JOB_STATUSES.REVIEW_CHANGES); + expect(result).toContain(JOB_STATUSES.REVIEWED_NO_MARC_RECORDS); + }); + + it('should remove REVIEWED_NO_MARC_RECORDS from the array if REVIEW_CHANGES is not present', () => { + const values = ['other_value']; + const result = getTransformedLogsFilterValue(LOGS_FILTERS.STATUS, values); + expect(result).not.toContain(JOB_STATUSES.REVIEWED_NO_MARC_RECORDS); + expect(result).toContain('other_value'); + }); }); diff --git a/translations/ui-bulk-edit/en.json b/translations/ui-bulk-edit/en.json index e1f8d9f2..37f3efb4 100644 --- a/translations/ui-bulk-edit/en.json +++ b/translations/ui-bulk-edit/en.json @@ -471,6 +471,7 @@ "logs.status.SAVING_RECORDS_LOCALLY": "Saving records", "logs.status.DATA_MODIFICATION": "Data modification", "logs.status.REVIEW_CHANGES": "Reviewing changes", + "logs.status.REVIEWED_NO_MARC_RECORDS": "Reviewing changes", "logs.status.COMPLETED": "Completed", "logs.status.COMPLETED_WITH_ERRORS": "Completed with errors", "logs.status.FAILED": "Failed",