From 7cf030e53cc6335ddd7d73ee7118c96d919d391c Mon Sep 17 00:00:00 2001 From: vashjs Date: Mon, 2 Dec 2024 21:32:21 +0100 Subject: [PATCH 1/2] UIBULKED-585 Adding missing translation and filters --- .../BulkEditListSidebar/LogsTab/LogsTab.js | 2 +- src/constants/core.js | 6 +++++ src/utils/helpers.js | 26 +++++++++---------- src/utils/helpers.test.js | 18 ++++++------- translations/ui-bulk-edit/en.json | 1 + 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/components/BulkEditPane/BulkEditListSidebar/LogsTab/LogsTab.js b/src/components/BulkEditPane/BulkEditListSidebar/LogsTab/LogsTab.js index 44f56535..673b0bd6 100644 --- a/src/components/BulkEditPane/BulkEditListSidebar/LogsTab/LogsTab.js +++ b/src/components/BulkEditPane/BulkEditListSidebar/LogsTab/LogsTab.js @@ -61,7 +61,7 @@ export const LogsTab = () => { }); const adaptedApplyFilters = useCallback(({ name, values }) => { - return applyFilters(name, getTransformedLogsFilterValue(name, values)); + return applyFilters(name, getTransformedLogsFilterValue(values)); }, [applyFilters]); const { logsQueryParams } = useLogsQueryParams({ search: location.search }); diff --git a/src/constants/core.js b/src/constants/core.js index d25570b0..512ea260 100644 --- a/src/constants/core.js +++ b/src/constants/core.js @@ -123,6 +123,12 @@ export const LOGS_FILTERS = { USER: 'userId', }; +export const LOGS_FILTER_DEPENDENCY_MAP = { + [CAPABILITIES.INSTANCE]: CAPABILITIES.INSTANCE_MARC, + [JOB_STATUSES.REVIEW_CHANGES]: JOB_STATUSES.REVIEWED_NO_MARC_RECORDS, + [JOB_STATUSES.DATA_MODIFICATION]: JOB_STATUSES.DATA_MODIFICATION_IN_PROGRESS, +}; + export const MANUAL_UPLOAD_STEPS = { UPLOAD: 'UPLOAD', CONFIRM: 'CONFIRM', diff --git a/src/utils/helpers.js b/src/utils/helpers.js index 4781b2de..6f988857 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -2,8 +2,7 @@ import { clone, setWith } from 'lodash'; import { CAPABILITIES, EDIT_CAPABILITIES_OPTIONS, - JOB_STATUSES, - LOGS_FILTERS, + LOGS_FILTER_DEPENDENCY_MAP, } from '../constants'; export const isCapabilityDisabled = (capabilityValue, view, perms = {}) => { @@ -161,20 +160,19 @@ export const filterByIds = (items, ids) => { return items.filter(item => ids.includes(item.id)); }; -export const getTransformedLogsFilterValue = (name, values) => { - const getWithDependentValue = (triggerValue, dependentValue) => { - return values.includes(triggerValue) - ? [...new Set([...values, dependentValue])] - : values.filter(value => value !== dependentValue); - }; +export const getTransformedLogsFilterValue = (values) => { + // ignore case when values is not an array (ex. user ID filter) + if (!Array.isArray(values)) return values; - if (name === LOGS_FILTERS.CAPABILITY) { - return getWithDependentValue(CAPABILITIES.INSTANCE, CAPABILITIES.INSTANCE_MARC); - } + const result = new Set(values); - if (name === LOGS_FILTERS.STATUS) { - return getWithDependentValue(JOB_STATUSES.REVIEW_CHANGES, JOB_STATUSES.REVIEWED_NO_MARC_RECORDS); + for (const [value, dependentValue] of Object.entries(LOGS_FILTER_DEPENDENCY_MAP)) { + if (result.has(value)) { + result.add(dependentValue); + } else { + result.delete(dependentValue); + } } - return values; + return Array.from(result); }; diff --git a/src/utils/helpers.test.js b/src/utils/helpers.test.js index 1f4d7ba2..ec94aa94 100644 --- a/src/utils/helpers.test.js +++ b/src/utils/helpers.test.js @@ -4,7 +4,7 @@ import { getTransformedLogsFilterValue, removeDuplicatesByValue } from './helpers'; -import { CAPABILITIES, JOB_STATUSES, LOGS_FILTERS } from '../constants'; +import { CAPABILITIES, JOB_STATUSES } from '../constants'; describe('customFilter', () => { const dataOptions = [ @@ -226,14 +226,14 @@ describe('getTenantsById', () => { describe('getTransformedLogsFilterValue', () => { it('should add INSTANCE_MARC to the array if INSTANCE is present', () => { const values = [CAPABILITIES.INSTANCE]; - const result = getTransformedLogsFilterValue(LOGS_FILTERS.CAPABILITY, values); + const result = getTransformedLogsFilterValue(values); expect(result).toContain(CAPABILITIES.INSTANCE); expect(result).toContain(CAPABILITIES.INSTANCE_MARC); }); it('should not add INSTANCE_MARC if it is already present', () => { const values = [CAPABILITIES.INSTANCE, CAPABILITIES.INSTANCE_MARC]; - const result = getTransformedLogsFilterValue(LOGS_FILTERS.CAPABILITY, values); + const result = getTransformedLogsFilterValue(values); expect(result).toContain(CAPABILITIES.INSTANCE); expect(result).toContain(CAPABILITIES.INSTANCE_MARC); expect(result.length).toBe(2); @@ -241,41 +241,41 @@ describe('getTransformedLogsFilterValue', () => { it('should remove INSTANCE_MARC from the array if INSTANCE is not present', () => { const values = [CAPABILITIES.INSTANCE_MARC, 'other_value']; - const result = getTransformedLogsFilterValue(LOGS_FILTERS.CAPABILITY, values); + const result = getTransformedLogsFilterValue(values); expect(result).not.toContain(CAPABILITIES.INSTANCE_MARC); expect(result).toContain('other_value'); }); it('should return the same array if INSTANCE and INSTANCE_MARC are not present', () => { const values = ['other_value']; - const result = getTransformedLogsFilterValue(LOGS_FILTERS.CAPABILITY, values); + const result = getTransformedLogsFilterValue(values); expect(result).toEqual(values); }); it('should not modify the original input array', () => { const values = [CAPABILITIES.INSTANCE]; - const result = getTransformedLogsFilterValue(LOGS_FILTERS.CAPABILITY, values); + const result = getTransformedLogsFilterValue(values); expect(values).not.toContain(CAPABILITIES.INSTANCE_MARC); expect(result).toContain(CAPABILITIES.INSTANCE_MARC); }); it('should not modify the original userID', () => { const values = 'userID'; - const result = getTransformedLogsFilterValue(LOGS_FILTERS.USER, values); + const result = getTransformedLogsFilterValue(values); 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); + const result = getTransformedLogsFilterValue(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); + const result = getTransformedLogsFilterValue(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 1b21bc7c..609b5614 100644 --- a/translations/ui-bulk-edit/en.json +++ b/translations/ui-bulk-edit/en.json @@ -471,6 +471,7 @@ "logs.status.RETRIEVING_RECORDS": "Retrieving records", "logs.status.SAVING_RECORDS_LOCALLY": "Saving records", "logs.status.DATA_MODIFICATION": "Data modification", + "logs.status.DATA_MODIFICATION_IN_PROGRESS": "Data modification", "logs.status.REVIEW_CHANGES": "Reviewing changes", "logs.status.REVIEWED_NO_MARC_RECORDS": "Reviewing changes", "logs.status.COMPLETED": "Completed", From 23c97e5795c253b2ef42faf4f28d3c559d4074b0 Mon Sep 17 00:00:00 2001 From: vashjs Date: Mon, 2 Dec 2024 22:03:14 +0100 Subject: [PATCH 2/2] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a168de59..27a1d90a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * [UIBULKED-580](https://folio-org.atlassian.net/browse/UIBULKED-580) Refactor of publish coordinator related logic. * [UIBULKED-587](https://folio-org.atlassian.net/browse/UIBULKED-587) Only Users from the first page are displayed in "Users" dropdown on "Logs" page. * [UIBULKED-560](https://folio-org.atlassian.net/browse/UIBULKED-560) Update actions menu. +* [UIBULKED-585](https://folio-org.atlassian.net/browse/UUIBULKED-585) Adding missing translation and filters. ## [4.2.2](https://github.com/folio-org/ui-bulk-edit/tree/v4.2.2) (2024-11-15)