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

UIIN-3191: Add new ‘Set for deletion’ flag to display on 3rd pane Instance view #2742

Merged
merged 9 commits into from
Feb 14, 2025
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Add Version history button and Version history pane to details view of Item. Refs UIIN-3172.
* Add Version history button and Version history pane to details view of Holdings. Refs UIIN-3171.
* Add Version history button and Version history pane to details view of Instance. Refs UIIN-3170.
* Add new ‘Set for deletion’ flag to display on 3rd pane Instance view. Refs UIIN-3191.

## [12.0.12](https://github.com/folio-org/ui-inventory/tree/v12.0.12) (2025-01-27)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v12.0.11...v12.0.12)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,21 @@ const InstanceAdministrativeView = ({
>
{instance.metadata && <ViewMetaData metadata={instance.metadata} />}
<Row>
{
instance.deleted &&
<Col xs={3}>
<WarningMessage id="ui-inventory.setForDeletion" />
</Col>
}
{
instance.discoverySuppress &&
<Col xs={5}>
<Col xs={3}>
<WarningMessage id="ui-inventory.discoverySuppressed" />
</Col>
}
{
instance.staffSuppress &&
<Col xs={4}>
<Col xs={3}>
<WarningMessage id="ui-inventory.staffSuppressed" />
</Col>
}
Expand All @@ -111,7 +117,7 @@ const InstanceAdministrativeView = ({
}
</Row>

{(instance.discoverySuppress || instance.staffSuppress || instance.previouslyHeld) && <br />}
{(instance.deleted || instance.discoverySuppress || instance.staffSuppress || instance.previouslyHeld) && <br />}

<Row>
<Col xs={3}>
Expand Down
47 changes: 32 additions & 15 deletions src/Instance/InstanceDetails/InstanceDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
Row,
MessageBanner,
PaneCloseLink,
Paneset,
Layout,
} from '@folio/stripes/components';
import { VersionHistoryButton } from '@folio/stripes-acq-components';

Expand Down Expand Up @@ -164,6 +164,25 @@ const InstanceDetails = forwardRef(({
setIsAllExpanded(isExpanded);
};

const warningBanners = [
{
condition: !instance.deleted && instance.staffSuppress && !instance.discoverySuppress,
messageId: 'ui-inventory.warning.instance.staffSuppressed',
},
{
condition: !instance.deleted && instance.discoverySuppress && !instance.staffSuppress,
messageId: 'ui-inventory.warning.instance.suppressedFromDiscovery',
},
{
condition: !instance.deleted && instance.discoverySuppress && instance.staffSuppress,
messageId: 'ui-inventory.warning.instance.suppressedFromDiscoveryAndStaffSuppressed',
},
{
condition: instance.deleted && instance.discoverySuppress && instance.staffSuppress,
messageId: 'ui-inventory.warning.instance.setForDeletionAndSuppressedFromDiscoveryAndStaffSuppressed',
},
];

return (
<>
<Pane
Expand All @@ -187,20 +206,18 @@ const InstanceDetails = forwardRef(({

<AccordionStatus ref={ref}>
<Row>
<Col xs={10}>
<MessageBanner show={Boolean(instance.staffSuppress && !instance.discoverySuppress)} type="warning">
<FormattedMessage id="ui-inventory.warning.instance.staffSuppressed" />
</MessageBanner>
<MessageBanner show={Boolean(instance.discoverySuppress && !instance.staffSuppress)} type="warning">
<FormattedMessage id="ui-inventory.warning.instance.suppressedFromDiscovery" />
</MessageBanner>
<MessageBanner show={Boolean(instance.discoverySuppress && instance.staffSuppress)} type="warning">
<FormattedMessage id="ui-inventory.warning.instance.suppressedFromDiscoveryAndStaffSuppressed" />
</MessageBanner>
</Col>
<Col data-test-expand-all xs={2}>
<ExpandAllButton onToggle={onToggle} />
</Col>
<Layout className="display-flex full flex-align-items-center justify-end">
<Col xs={10}>
{warningBanners.map(({ condition, messageId }) => (
<MessageBanner key={messageId} show={Boolean(condition)} type="warning">
<FormattedMessage id={messageId} />
</MessageBanner>
))}
</Col>
<Col data-test-expand-all xs={2}>
<ExpandAllButton onToggle={onToggle} />
</Col>
</Layout>
</Row>

<InstanceTitle
Expand Down
15 changes: 15 additions & 0 deletions src/Instance/InstanceDetails/InstanceDetails.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const instance = {
notes: [],
staffSuppress: false,
discoverySuppress: false,
deleted: false,
shared: false,
};

Expand Down Expand Up @@ -148,6 +149,20 @@ describe('InstanceDetails', () => {

expect(screen.getByText('Warning: Instance is marked suppressed from discovery and staff suppressed')).toBeInTheDocument();
});
it('should show a correct Warning message banner when set for deletion, staff and discovery suppressed', () => {
const deletedAndBothSuppressedInstance = {
...instance,
staffSuppress: true,
discoverySuppress: true,
deleted: true,
};
renderInstanceDetails({ instance: deletedAndBothSuppressedInstance });

const warningBanner = screen.getByText('Warning:', { exact: false });

expect(warningBanner.textContent).toEqual('Warning: Instance is set for deletion, suppressed from discovery, and staff suppressed');
expect(screen.getByText('Set for deletion')).toBeInTheDocument();
});

it('expands and collapses the accordion sections', () => {
renderInstanceDetails();
Expand Down
2 changes: 2 additions & 0 deletions translations/ui-inventory/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,12 @@
"warning.instance.suppressedFromDiscovery": "Warning: Instance is marked suppressed from discovery",
"warning.instance.staffSuppressed": "Warning: Instance is marked staff suppressed",
"warning.instance.suppressedFromDiscoveryAndStaffSuppressed": "Warning: Instance is marked suppressed from discovery and staff suppressed",
"warning.instance.setForDeletionAndSuppressedFromDiscoveryAndStaffSuppressed": "Warning: <b>Instance is set for deletion</b>, suppressed from discovery, and staff suppressed",
"warning.instance.sharingLocalInstance": "Sharing this local instance will take a few moments. A success message and updated details will be displayed upon completion.",
"warning.instance.accessSharedInstance": "You do not currently have permission to access details of shared instances. Contact your FOLIO administrator for more information.",
"warning.holdingsRecord.suppressedFromDiscovery": "Warning: Holdings is marked suppressed from discovery",
"warning.item.suppressedFromDiscovery": "Warning: Item is marked suppressed from discovery",
"setForDeletion": "Set for deletion",
"discoverySuppressed": "Suppressed from discovery",
"staffSuppressed": "Staff suppressed",
"hridCopied": "The instance HRID {hrid} was successfully copied to the clipboard",
Expand Down