Skip to content

Commit

Permalink
UIBULKED-538 Add translation and filtering logic for new status (foll…
Browse files Browse the repository at this point in the history
…ow up) (#646)

(cherry picked from commit 7b4c54e)
  • Loading branch information
vashjs committed Nov 15, 2024
1 parent 6894038 commit 5adfb49
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { clone, setWith } from 'lodash';
import {
CAPABILITIES,
EDIT_CAPABILITIES_OPTIONS,
JOB_STATUSES,
LOGS_FILTERS,
} from '../constants';

Expand Down Expand Up @@ -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;
Expand Down
16 changes: 15 additions & 1 deletion src/utils/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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');
});
});
1 change: 1 addition & 0 deletions translations/ui-bulk-edit/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5adfb49

Please sign in to comment.