Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrHladchenko1 committed Oct 18, 2023
2 parents f72699c + e18e43c commit 10a2e3a
Show file tree
Hide file tree
Showing 19 changed files with 250 additions and 110 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 10.0.1 IN PROGRESS

* Instance 3rd pane: Adjust behavior when returning to instance from holdings/item full screen. Refs UIIN-2453.
* Consortial holdings accordion is not appearing after the sharing of Instance. Fixes UIIN-2629.
* Enable/disable consortial holdings/item actions based on User permissions. Refs UIIN-2452.

## [10.0.0](https://github.com/folio-org/ui-inventory/tree/v10.0.0) (2023-10-13)
Expand Down
7 changes: 7 additions & 0 deletions src/Instance/HoldingsList/Holding/Holding.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const Holding = ({
showViewHoldingsButton,
showAddItemButton,
isBarcodeAsHotlink,
instanceId,
pathToAccordionsState,
}) => {
return (
<div>
Expand Down Expand Up @@ -55,6 +57,8 @@ const Holding = ({
onViewHolding={onViewHolding}
onAddItem={onAddItem}
tenantId={tenantId}
instanceId={instanceId}
pathToAccordionsState={pathToAccordionsState}
showViewHoldingsButton={showViewHoldingsButton}
showAddItemButton={showAddItemButton}
>
Expand All @@ -75,6 +79,7 @@ Holding.propTypes = {
holding: PropTypes.object.isRequired,
onViewHolding: PropTypes.func.isRequired,
onAddItem: PropTypes.func.isRequired,
instanceId: PropTypes.string.isRequired,
holdings: PropTypes.arrayOf(PropTypes.object),
draggable: PropTypes.bool,
droppable: PropTypes.bool,
Expand All @@ -86,10 +91,12 @@ Holding.propTypes = {
showViewHoldingsButton: PropTypes.bool,
showAddItemButton: PropTypes.bool,
isBarcodeAsHotlink: PropTypes.bool,
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
};

Holding.defaultProps = {
isItemsDroppable: true,
pathToAccordionsState: [],
};

export default Holding;
2 changes: 2 additions & 0 deletions src/Instance/HoldingsList/Holding/Holding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const HoldingSetup = () => (
<Router>
<Holding
holding={holding}
instanceId="instanceId"
onViewHolding={onViewHolding}
onAddItem={onAddItem}
holdings={holdings}
Expand All @@ -38,6 +39,7 @@ const HoldingSetup = () => (
isHoldingDragSelected={isHoldingDragSelected}
isDraggable={isDraggable}
isItemsDroppable={isItemsDroppable}
pathToAccordionsState={['holdings']}
/>
</Router>
);
Expand Down
14 changes: 11 additions & 3 deletions src/Instance/HoldingsList/Holding/HoldingAccordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import {
} from '@folio/stripes/components';

import { callNumberLabel } from '../../../utils';

import HoldingButtonsGroup from './HoldingButtonsGroup';
import {
useHoldingsAccordionState,
useLocationsQuery,
useHoldingItemsQuery,
} from '../../../hooks';

import HoldingButtonsGroup from './HoldingButtonsGroup';

const HoldingAccordion = ({
children,
holding,
Expand All @@ -28,13 +29,16 @@ const HoldingAccordion = ({
tenantId,
showViewHoldingsButton,
showAddItemButton,
instanceId,
pathToAccordionsState,
}) => {
const searchParams = {
limit: 0,
offset: 0,
};

const [open, setOpen] = useState(false);
const pathToAccordion = [...pathToAccordionsState, holding?.id];
const [open, setOpen] = useHoldingsAccordionState({ instanceId, pathToAccordion });
const [openFirstTime, setOpenFirstTime] = useState(false);
const { totalRecords, isFetching } = useHoldingItemsQuery(holding.id, { searchParams, key: 'itemCount', tenantId });
const { data: locations } = useLocationsQuery({ tenantId });
Expand Down Expand Up @@ -121,12 +125,16 @@ HoldingAccordion.propTypes = {
holding: PropTypes.object.isRequired,
onViewHolding: PropTypes.func.isRequired,
onAddItem: PropTypes.func.isRequired,
instanceId: PropTypes.string.isRequired,
holdings: PropTypes.arrayOf(PropTypes.object),
withMoveDropdown: PropTypes.bool,
children: PropTypes.object,
tenantId: PropTypes.string,
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
showViewHoldingsButton: PropTypes.bool,
showAddItemButton: PropTypes.bool,
};

HoldingAccordion.defaultProps = { pathToAccordionsState: [] };

export default HoldingAccordion;
2 changes: 2 additions & 0 deletions src/Instance/HoldingsList/Holding/HoldingAccordion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const HoldingAccordionSetup = () => (
onViewHolding={noop}
onAddItem={noop}
withMoveDropdown={false}
instanceId="instanceId"
pathToAccordionsState={['holdings']}
>
<></>
</HoldingAccordion>
Expand Down
16 changes: 16 additions & 0 deletions src/Instance/HoldingsList/Holding/HoldingContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const DraggableHolding = ({
showViewHoldingsButton,
showAddItemButton,
isBarcodeAsHotlink,
instanceId,
pathToAccordionsState,
...rest
}) => {
const rowStyles = useMemo(() => (
Expand Down Expand Up @@ -76,6 +78,8 @@ const DraggableHolding = ({
showViewHoldingsButton={showViewHoldingsButton}
showAddItemButton={showAddItemButton}
isBarcodeAsHotlink={isBarcodeAsHotlink}
instanceId={instanceId}
pathToAccordionsState={pathToAccordionsState}
/>
)
}
Expand All @@ -91,15 +95,19 @@ DraggableHolding.propTypes = {
draggingHoldingsCount: PropTypes.number,
provided: PropTypes.object.isRequired,
snapshot: PropTypes.object.isRequired,
instanceId: PropTypes.string.isRequired,
holding: PropTypes.object,
onViewHolding: PropTypes.func,
onAddItem: PropTypes.func,
tenantId: PropTypes.string,
showViewHoldingsButton: PropTypes.bool,
showAddItemButton: PropTypes.bool,
isBarcodeAsHotlink: PropTypes.bool,
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
};

DraggableHolding.defaultProps = { pathToAccordionsState: [] };

const HoldingContainer = ({
location,
history,
Expand All @@ -112,6 +120,7 @@ const HoldingContainer = ({
holdingIndex,
draggingHoldingsCount,
tenantId,
pathToAccordionsState,
...rest
}) => {
const stripes = useStripes();
Expand Down Expand Up @@ -156,6 +165,8 @@ const HoldingContainer = ({
showViewHoldingsButton={showViewHoldingsButton}
showAddItemButton={showAddItemButton}
isBarcodeAsHotlink={isBarcodeAsHotlink}
instanceId={instance?.id}
pathToAccordionsState={pathToAccordionsState}
{...rest}
/>
)}
Expand All @@ -170,6 +181,8 @@ const HoldingContainer = ({
showViewHoldingsButton={showViewHoldingsButton}
showAddItemButton={showAddItemButton}
isBarcodeAsHotlink={isBarcodeAsHotlink}
instanceId={instance?.id}
pathToAccordionsState={pathToAccordionsState}
/>
);
};
Expand All @@ -188,6 +201,9 @@ HoldingContainer.propTypes = {
showViewHoldingsButton: PropTypes.bool,
showAddItemButton: PropTypes.bool,
isBarcodeAsHotlink: PropTypes.bool,
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
};

HoldingContainer.defaultProps = { pathToAccordionsState: [] };

export default withRouter(HoldingContainer);
1 change: 1 addition & 0 deletions src/Instance/HoldingsList/Holding/HoldingContainer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const renderHoldingContainer = (props = {}) => renderWithIntl(
onAddItem={jest.fn()}
showViewHoldingsButton
showAddItemButton
pathToAccordionsState={['holdings']}
{...props}
/>
</DnDContext.Provider>
Expand Down
4 changes: 4 additions & 0 deletions src/Instance/HoldingsList/HoldingsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const HoldingsList = ({
showViewHoldingsButton,
showAddItemButton,
isBarcodeAsHotlink,
pathToAccordionsState,
draggable,
droppable,
}) => holdings.map(holding => (
Expand All @@ -24,6 +25,7 @@ const HoldingsList = ({
showViewHoldingsButton={showViewHoldingsButton}
showAddItemButton={showAddItemButton}
isBarcodeAsHotlink={isBarcodeAsHotlink}
pathToAccordionsState={pathToAccordionsState}
/>
));

Expand All @@ -34,12 +36,14 @@ HoldingsList.propTypes = {
showViewHoldingsButton: PropTypes.bool,
showAddItemButton: PropTypes.bool,
isBarcodeAsHotlink: PropTypes.bool,
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
draggable: PropTypes.bool,
droppable: PropTypes.bool,
};

HoldingsList.defaultProps = {
holdings: [],
pathToAccordionsState: [],
};

export default HoldingsList;
10 changes: 7 additions & 3 deletions src/Instance/HoldingsList/HoldingsListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';

import { useStripes } from '@folio/stripes/core';
import {
Loading,
} from '@folio/stripes/components';
import { Loading } from '@folio/stripes/components';

import HoldingsList from './HoldingsList';
import { HoldingsListMovement } from '../InstanceMovement/HoldingMovementList';
Expand All @@ -14,6 +12,7 @@ const HoldingsListContainer = ({
instance,
isHoldingsMove,
tenantId,
pathToAccordionsState,
...rest
}) => {
const stripes = useStripes();
Expand All @@ -35,6 +34,7 @@ const HoldingsListContainer = ({
showViewHoldingsButton={canViewHoldings}
showAddItemButton={canCreateItem}
isBarcodeAsHotlink={canViewItems}
pathToAccordionsState={pathToAccordionsState}
/>
) : (
<HoldingsList
Expand All @@ -45,6 +45,7 @@ const HoldingsListContainer = ({
showViewHoldingsButton={canViewHoldings}
showAddItemButton={canCreateItem}
isBarcodeAsHotlink={canViewItems}
pathToAccordionsState={pathToAccordionsState}
/>
)
);
Expand All @@ -54,6 +55,9 @@ HoldingsListContainer.propTypes = {
instance: PropTypes.object.isRequired,
isHoldingsMove: PropTypes.bool,
tenantId: PropTypes.string,
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
};

HoldingsListContainer.defaultProps = { pathToAccordionsState: [] };

export default HoldingsListContainer;
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import React, { useContext } from 'react';
import React, {
useContext,
useEffect,
useRef,
} from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

Expand All @@ -13,36 +17,53 @@ import {

import { MemberTenantHoldings } from '../MemberTenantHoldings';
import { DataContext } from '../../../contexts';
import { useSearchForShadowInstanceTenants } from '../../../hooks';
import {
useHoldingsAccordionState,
useSearchForShadowInstanceTenants,
} from '../../../hooks';

const ConsortialHoldings = ({
instance,
userTenantPermissions,
}) => {
const stripes = useStripes();
const instanceId = instance?.id;
const prevInstanceId = useRef(instanceId);

const { consortiaTenantsById } = useContext(DataContext);

const { tenants } = useSearchForShadowInstanceTenants({ instanceId: instance?.id });
const { tenants } = useSearchForShadowInstanceTenants({ instanceId });

const memberTenants = tenants
.map(tenant => consortiaTenantsById[tenant.id])
.filter(tenant => !tenant?.isCentral && (tenant?.id !== stripes.okapi.tenant))
.sort((a, b) => a.name.localeCompare(b.name));

const pathToAccordion = ['consortialHoldings', '_state'];
const [isConsortialAccOpen, setConsortialAccOpen] = useHoldingsAccordionState({ instanceId, pathToAccordion });

useEffect(() => {
if (instanceId !== prevInstanceId.current) {
setConsortialAccOpen(false);
prevInstanceId.current = instanceId;
}
}, [instanceId]);

return (
<IfInterface name="consortia">
<Accordion
id="consortial-holdings"
label={<FormattedMessage id="ui-inventory.consortialHoldings" />}
closedByDefault
open={isConsortialAccOpen}
onToggle={() => setConsortialAccOpen(prevState => !prevState)}
>
{!memberTenants.length
? <FormattedMessage id="stripes-components.tableEmpty" />
: (
<AccordionSet>
{memberTenants.map(memberTenant => (
<MemberTenantHoldings
key={memberTenant.id}
key={`${memberTenant.id}.${instanceId}`}
memberTenant={memberTenant}
instance={instance}
userTenantPermissions={userTenantPermissions}
Expand Down
4 changes: 3 additions & 1 deletion src/Instance/InstanceDetails/InstanceDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ const InstanceDetails = forwardRef(({
);
}

const isConsortialHoldingsVisible = instance?.shared || isInstanceShadowCopy(instance?.source);

const renderPaneTitle = () => {
const isInstanceShared = Boolean(isShared || isInstanceShadowCopy(instance?.source));

Expand Down Expand Up @@ -204,7 +206,7 @@ const InstanceDetails = forwardRef(({
/>
)}

{instance?.shared && (
{isConsortialHoldingsVisible && (
<ConsortialHoldings
instance={instance}
userTenantPermissions={userTenantPermissions}
Expand Down
Loading

0 comments on commit 10a2e3a

Please sign in to comment.