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

UISACQCOMP-230 Fix version history label resolving #835

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import escapeRegExp from 'lodash/escapeRegExp';
import PropTypes from 'prop-types';
import {
useContext,
Expand All @@ -21,7 +22,7 @@ export const VersionKeyValue = ({
const versionContext = useContext(VersionViewContext);
const isUpdated = useMemo(() => (
multiple
? versionContext?.paths?.find((field) => new RegExp(`^${name}\\[\\d\\]$`).test(field))
? versionContext?.paths?.find((field) => new RegExp(`^${escapeRegExp(name)}\\[\\d\\]$`).test(field))
: versionContext?.paths?.includes(name)
), [multiple, name, versionContext?.paths]);

Expand Down
2 changes: 1 addition & 1 deletion lib/VersionHistory/getFieldLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const getFieldLabels = (intl, paths, labelsMap = {}, hiddenFields = []) =

return paths.reduce((acc, path) => {
const fieldLabel = labelsMapEntries.find(([fieldPath]) => {
const regex = new RegExp(`^${escapeRegExp(fieldPath).replace('\\\\d', '\\d')}$`);
const regex = new RegExp(`^${escapeRegExp(fieldPath).replaceAll('\\\\d', '\\d')}$`);

return regex.test(path);
})?.[1] || path;
Expand Down
13 changes: 7 additions & 6 deletions lib/hooks/useCategories/useCategories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@folio/stripes/core';

import {
ALL_RECORDS_CQL,
CATEGORIES_API,
LIMIT_MAX,
} from '../../constants';
Expand All @@ -19,18 +20,18 @@ export const useCategories = (options = {}) => {

const searchParams = {
limit: LIMIT_MAX,
query: 'cql.allRecords=1',
query: ALL_RECORDS_CQL,
};

const {
data,
isFetching,
isLoading,
} = useQuery(
[namespace],
() => ky.get(CATEGORIES_API, { searchParams }).json(),
options,
);
} = useQuery({
queryKey: [namespace],
queryFn: ({ signal }) => ky.get(CATEGORIES_API, { searchParams, signal }).json(),
...options,
});

const [translatedCategories] = useTranslatedCategories(data?.categories);

Expand Down
Loading