Skip to content

Commit

Permalink
UIBULKED-556: ECS - remove link to affected record in Optimistic erro…
Browse files Browse the repository at this point in the history
…r for holdings and items.
  • Loading branch information
UladzislauKutarkin committed Oct 18, 2024
1 parent 3ec4533 commit 710e38a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
* [UIBULKED-555](https://folio-org.atlassian.net/browse/UIBULKED-555)Rearrange item statuses order.
* [UIBULKED-559](https://folio-org.atlassian.net/browse/UIBULKED-559) Update subfield validation in MARC form.
* [UIBULKED-558](https://folio-org.atlassian.net/browse/UIBULKED-558) Add translation for new "Member" column.
* [UIBULKED-556](https://folio-org.atlassian.net/browse/UIBULKED-556) ECS - remove link to affected record in Optimistic error for holdings and items.

## [4.1.4](https://github.com/folio-org/ui-bulk-edit/tree/v4.1.4) (2024-05-29)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,15 @@ import {
Icon,
TextLink,
} from '@folio/stripes/components';
import { useStripes } from '@folio/stripes/core';
import css from '../Preview.css';
import { useSearchParams } from '../../../../../hooks';
import { CRITERIA, ERROR_PARAMETERS_KEYS } from '../../../../../constants';
import { CAPABILITIES, CRITERIA, ERROR_PARAMETERS_KEYS } from '../../../../../constants';

const visibleColumns = ['key', 'message'];

const getParam = (error, key) => error.parameters.find(param => param.key === key)?.value;

const resultsFormatter = {
key: error => getParam(error, ERROR_PARAMETERS_KEYS.IDENTIFIER),
message: error => {
const link = getParam(error, ERROR_PARAMETERS_KEYS.LINK);

return (
<div>
{error.message}
{' '}
{!!link && (
<span className={css.errorLink}>
<TextLink to={link} target="_blank">
<Icon icon="external-link" size="small" iconPosition="end">
<FormattedMessage id="ui-bulk-edit.list.errors.table.link" />
</Icon>
</TextLink>
</span>
)}
</div>
);
},
};

const columnMapping = {
key: <FormattedMessage id="ui-bulk-edit.list.errors.table.code" />,
message: <FormattedMessage id="ui-bulk-edit.list.errors.table.message" />,
Expand All @@ -52,6 +30,36 @@ const ErrorsAccordion = ({
matched,
isInitial,
}) => {
const { user, okapi } = useStripes();
const centralTenant = user?.user?.consortium?.centralTenantId;
const tenantId = okapi.tenant;
const isCentralTenant = tenantId === centralTenant;
const { capabilities } = useSearchParams();
const isLinkAvailable = (isCentralTenant && capabilities === CAPABILITIES.INSTANCE) || !isCentralTenant;

const resultsFormatter = {
key: error => getParam(error, ERROR_PARAMETERS_KEYS.IDENTIFIER),
message: error => {
const link = getParam(error, ERROR_PARAMETERS_KEYS.LINK);

return (
<div>
{error.message}
{' '}
{!!link && isLinkAvailable && (
<span className={css.errorLink}>
<TextLink to={link} target="_blank">
<Icon icon="external-link" size="small" iconPosition="end">
<FormattedMessage id="ui-bulk-edit.list.errors.table.link" />
</Icon>
</TextLink>
</span>
)}
</div>
);
},
};

const location = useLocation();
const { criteria } = useSearchParams();
const fileName = new URLSearchParams(location.search).get('fileName');
Expand Down

0 comments on commit 710e38a

Please sign in to comment.