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

UIQM-699 ECS - send validation request with central tenant id for shared Bib and Authority records. #729

Merged
merged 4 commits into from
Sep 18, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [UIQM-694](https://issues.folio.org/browse/UIQM-694) Separate error messages triggered by controlled subfields of different linked fields.
* [UIQM-592](https://issues.folio.org/browse/UIQM-592) Fix to input polish special chars into fields.
* [UIQM-697](https://issues.folio.org/browse/UIQM-697) Field 008: Validate the length of subfields. Add backslashes if the length of a subfield of field 008 is shorter, if longer - cut off the extra characters.
* [UIQM-699](https://issues.folio.org/browse/UIQM-699) ECS - send validation request with central tenant id for shared Bib and Authority records.

## [8.0.1] (https://github.com/folio-org/ui-quick-marc/tree/v8.0.1) (2024-04-18)

Expand Down
11 changes: 10 additions & 1 deletion src/QuickMarcEditor/QuickMarcCreateWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import React, {
useMemo,
useState,
} from 'react';
import { useLocation } from 'react-router-dom';
import PropTypes from 'prop-types';
import flow from 'lodash/flow';
import noop from 'lodash/noop';
import isEmpty from 'lodash/isEmpty';

import { useShowCallout } from '@folio/stripes-acq-components';
import { useStripes } from '@folio/stripes/core';

import QuickMarcEditor from './QuickMarcEditor';
import { QuickMarcContext } from '../contexts';
Expand All @@ -35,6 +37,7 @@ import {
autopopulateMaterialCharsField,
autopopulateIndicators,
removeRowsWithoutContent,
applyCentralTenantInHeaders,
} from './utils';

const propTypes = {
Expand All @@ -60,11 +63,17 @@ const QuickMarcCreateWrapper = ({
fixedFieldSpec,
locations,
}) => {
const stripes = useStripes();
const location = useLocation();
const showCallout = useShowCallout();
const [httpError, setHttpError] = useState(null);
const { linkableBibFields, actualizeLinks, linkingRules, sourceFiles } = useAuthorityLinking({ marcType, action });
const { validationErrorsRef } = useContext(QuickMarcContext);

const isRequestToCentralTenantFromMember = applyCentralTenantInHeaders(location, stripes, marcType);
const centralTenantId = stripes.user.user.consortium?.centralTenantId;
const tenantId = isRequestToCentralTenantFromMember ? centralTenantId : '';

const validationContext = useMemo(() => ({
initialValues,
marcType,
Expand All @@ -76,7 +85,7 @@ const QuickMarcCreateWrapper = ({
fixedFieldSpec,
instanceId: instance.id,
}), [initialValues, marcType, locations, linkableBibFields, linkingRules, sourceFiles, fixedFieldSpec, instance.id]);
const { validate } = useValidation(validationContext);
const { validate } = useValidation(validationContext, tenantId);

const prepareForSubmit = useCallback((formValues) => {
const formValuesForCreate = flow(
Expand Down
11 changes: 10 additions & 1 deletion src/QuickMarcEditor/QuickMarcDeriveWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import React, {
useMemo,
useState,
} from 'react';
import { useLocation } from 'react-router-dom';
import PropTypes from 'prop-types';
import flow from 'lodash/flow';
import isEmpty from 'lodash/isEmpty';

import { useShowCallout } from '@folio/stripes-acq-components';
import { useStripes } from '@folio/stripes/core';

import QuickMarcEditor from './QuickMarcEditor';
import {
Expand All @@ -35,6 +37,7 @@ import {
removeEnteredDate,
autopopulatePhysDescriptionField,
autopopulateMaterialCharsField,
applyCentralTenantInHeaders,
} from './utils';

const propTypes = {
Expand All @@ -56,11 +59,17 @@ const QuickMarcDeriveWrapper = ({
marcType,
fixedFieldSpec,
}) => {
const stripes = useStripes();
const location = useLocation();
const showCallout = useShowCallout();
const { linkableBibFields, actualizeLinks, linkingRules } = useAuthorityLinking({ marcType, action });
const [httpError, setHttpError] = useState(null);
const { validationErrorsRef } = useContext(QuickMarcContext);

const isRequestToCentralTenantFromMember = applyCentralTenantInHeaders(location, stripes, marcType);
const centralTenantId = stripes.user.user.consortium?.centralTenantId;
const tenantId = isRequestToCentralTenantFromMember ? centralTenantId : '';

const validationContext = useMemo(() => ({
initialValues,
marcType,
Expand All @@ -70,7 +79,7 @@ const QuickMarcDeriveWrapper = ({
fixedFieldSpec,
instanceId: instance.id,
}), [initialValues, marcType, linkableBibFields, linkingRules, fixedFieldSpec, instance.id]);
const { validate } = useValidation(validationContext);
const { validate } = useValidation(validationContext, tenantId);

const prepareForSubmit = useCallback((formValues) => {
const formValuesForDerive = flow(
Expand Down
2 changes: 1 addition & 1 deletion src/QuickMarcEditor/QuickMarcEditWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const QuickMarcEditWrapper = ({
instance.naturalId,
instance.id,
]);
const { validate } = useValidation(validationContext);
const { validate } = useValidation(validationContext, tenantId);

const prepareForSubmit = useCallback((formValues) => {
const formValuesToSave = flow(
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useValidation/useValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ const formatFEValidation = (errors = {}) => {
}, {});
};

const useValidation = (context = {}) => {
const useValidation = (context = {}, tenantId = null) => {
const quickMarcContext = useContext(QuickMarcContext);
const { validate: validateFetch } = useValidate();
const { validate: validateFetch } = useValidate({ tenantId });
const { duplicateLccnCheckingEnabled } = useLccnDuplicateConfig({ marcType: context.marcType });
const ky = useOkapiKy();
const intl = useIntl();
Expand Down
4 changes: 2 additions & 2 deletions src/queries/useValidate/useValidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {

import { VALIDATE_API } from '../../common/constants';

export const useValidate = () => {
const ky = useOkapiKy();
export const useValidate = ({ tenantId } = {}) => {
const ky = useOkapiKy({ tenant: tenantId });
const [namespace] = useNamespace({ key: 'MARC_VALIDATE' });

const { isFetching, data, mutateAsync } = useMutation(
Expand Down
Loading