diff --git a/src/Instance/HoldingsList/Holding/Holding.js b/src/Instance/HoldingsList/Holding/Holding.js index cac25c97a..907d2283b 100644 --- a/src/Instance/HoldingsList/Holding/Holding.js +++ b/src/Instance/HoldingsList/Holding/Holding.js @@ -23,8 +23,8 @@ const Holding = ({ isDraggable, isItemsDroppable, tenantId, - isViewHoldingsDisabled, - isAddItemDisabled, + showViewHoldingsButton, + showAddItemButton, isBarcodeAsHotlink, }) => { return ( @@ -55,8 +55,8 @@ const Holding = ({ onViewHolding={onViewHolding} onAddItem={onAddItem} tenantId={tenantId} - isViewHoldingsDisabled={isViewHoldingsDisabled} - isAddItemDisabled={isAddItemDisabled} + showViewHoldingsButton={showViewHoldingsButton} + showAddItemButton={showAddItemButton} > { const searchParams = { limit: 0, @@ -63,8 +63,8 @@ const HoldingAccordion = ({ withMoveDropdown={withMoveDropdown} isOpen={open} tenantId={tenantId} - isViewHoldingsDisabled={isViewHoldingsDisabled} - isAddItemDisabled={isAddItemDisabled} + showViewHoldingsButton={showViewHoldingsButton} + showAddItemButton={showAddItemButton} />; const location = labelLocation?.isActive ? @@ -125,8 +125,8 @@ HoldingAccordion.propTypes = { withMoveDropdown: PropTypes.bool, children: PropTypes.object, tenantId: PropTypes.string, - isViewHoldingsDisabled: PropTypes.bool, - isAddItemDisabled: PropTypes.bool, + showViewHoldingsButton: PropTypes.bool, + showAddItemButton: PropTypes.bool, }; export default HoldingAccordion; diff --git a/src/Instance/HoldingsList/Holding/HoldingButtonsGroup.js b/src/Instance/HoldingsList/Holding/HoldingButtonsGroup.js index 7437816cb..a1cf5eb16 100644 --- a/src/Instance/HoldingsList/Holding/HoldingButtonsGroup.js +++ b/src/Instance/HoldingsList/Holding/HoldingButtonsGroup.js @@ -27,8 +27,8 @@ const HoldingButtonsGroup = ({ itemCount, isOpen, tenantId, - isViewHoldingsDisabled, - isAddItemDisabled, + showViewHoldingsButton, + showAddItemButton, }) => { const stripes = useStripes(); const isUserInCentralTenant = checkIfUserInCentralTenant(stripes); @@ -44,23 +44,22 @@ const HoldingButtonsGroup = ({ /> ) } - - - {!isUserInCentralTenant && ( + {showViewHoldingsButton && + + } + {!isUserInCentralTenant && showAddItemButton && ( @@ -80,8 +79,8 @@ HoldingButtonsGroup.propTypes = { onAddItem: PropTypes.func.isRequired, onViewHolding: PropTypes.func.isRequired, withMoveDropdown: PropTypes.bool, - isViewHoldingsDisabled: PropTypes.bool, - isAddItemDisabled: PropTypes.bool, + showViewHoldingsButton: PropTypes.bool, + showAddItemButton: PropTypes.bool, tenantId: PropTypes.string, }; diff --git a/src/Instance/HoldingsList/Holding/HoldingButtonsGroup.test.js b/src/Instance/HoldingsList/Holding/HoldingButtonsGroup.test.js index f23dccea4..4ff6aaf4c 100644 --- a/src/Instance/HoldingsList/Holding/HoldingButtonsGroup.test.js +++ b/src/Instance/HoldingsList/Holding/HoldingButtonsGroup.test.js @@ -31,8 +31,8 @@ const HoldingButtonsGroupSetup = props => ( onAddItem={mockOnAddItem} itemCount={mockItemCount} isOpen={false} - isViewHoldingsDisabled={false} - isAddItemDisabled={false} + showViewHoldingsButton + showAddItemButton {...props} > {() => null} @@ -64,18 +64,18 @@ describe('HoldingButtonsGroup', () => { }); describe('when user has no permissions to view holdings', () => { - it('should render "View Holdings" button as disabled', () => { - const { getByRole } = renderHoldingButtonsGroup({ isViewHoldingsDisabled: true }); + it('should supress "View Holdings" button', () => { + const { queryByRole } = renderHoldingButtonsGroup({ showViewHoldingsButton: false }); - expect(getByRole('button', { name: 'View holdings' })).toBeDisabled(); + expect(queryByRole('button', { name: 'View holdings' })).not.toBeInTheDocument(); }); }); describe('when user has no permissions to create items', () => { - it('should render "Add item" button as disabled', () => { - const { getByRole } = renderHoldingButtonsGroup({ isAddItemDisabled: true }); + it('should supress "Add item" button', () => { + const { queryByRole } = renderHoldingButtonsGroup({ showAddItemButton: false }); - expect(getByRole('button', { name: 'Add item' })).toBeDisabled(); + expect(queryByRole('button', { name: 'Add item' })).not.toBeInTheDocument(); }); }); diff --git a/src/Instance/HoldingsList/Holding/HoldingContainer.js b/src/Instance/HoldingsList/Holding/HoldingContainer.js index 19295eda9..ae7a4ced9 100644 --- a/src/Instance/HoldingsList/Holding/HoldingContainer.js +++ b/src/Instance/HoldingsList/Holding/HoldingContainer.js @@ -38,8 +38,8 @@ const DraggableHolding = ({ onViewHolding, onAddItem, tenantId, - isViewHoldingsDisabled, - isAddItemDisabled, + showViewHoldingsButton, + showAddItemButton, isBarcodeAsHotlink, ...rest }) => { @@ -73,8 +73,8 @@ const DraggableHolding = ({ onViewHolding={onViewHolding} onAddItem={onAddItem} tenantId={tenantId} - isViewHoldingsDisabled={isViewHoldingsDisabled} - isAddItemDisabled={isAddItemDisabled} + showViewHoldingsButton={showViewHoldingsButton} + showAddItemButton={showAddItemButton} isBarcodeAsHotlink={isBarcodeAsHotlink} /> ) @@ -95,16 +95,16 @@ DraggableHolding.propTypes = { onViewHolding: PropTypes.func, onAddItem: PropTypes.func, tenantId: PropTypes.string, - isViewHoldingsDisabled: PropTypes.bool, - isAddItemDisabled: PropTypes.bool, + showViewHoldingsButton: PropTypes.bool, + showAddItemButton: PropTypes.bool, isBarcodeAsHotlink: PropTypes.bool, }; const HoldingContainer = ({ location, history, - isViewHoldingsDisabled, - isAddItemDisabled, + showViewHoldingsButton, + showAddItemButton, isBarcodeAsHotlink, instance, holding, @@ -153,8 +153,8 @@ const HoldingContainer = ({ onViewHolding={onViewHolding} onAddItem={onAddItem} tenantId={tenantId} - isViewHoldingsDisabled={isViewHoldingsDisabled} - isAddItemDisabled={isAddItemDisabled} + showViewHoldingsButton={showViewHoldingsButton} + showAddItemButton={showAddItemButton} isBarcodeAsHotlink={isBarcodeAsHotlink} {...rest} /> @@ -167,8 +167,8 @@ const HoldingContainer = ({ onViewHolding={onViewHolding} onAddItem={onAddItem} tenantId={tenantId} - isViewHoldingsDisabled={isViewHoldingsDisabled} - isAddItemDisabled={isAddItemDisabled} + showViewHoldingsButton={showViewHoldingsButton} + showAddItemButton={showAddItemButton} isBarcodeAsHotlink={isBarcodeAsHotlink} /> ); @@ -185,8 +185,8 @@ HoldingContainer.propTypes = { isDraggable: PropTypes.bool, draggingHoldingsCount: PropTypes.number, tenantId: PropTypes.string, - isViewHoldingsDisabled: PropTypes.bool, - isAddItemDisabled: PropTypes.bool, + showViewHoldingsButton: PropTypes.bool, + showAddItemButton: PropTypes.bool, isBarcodeAsHotlink: PropTypes.bool, }; diff --git a/src/Instance/HoldingsList/Holding/HoldingContainer.test.js b/src/Instance/HoldingsList/Holding/HoldingContainer.test.js index 1cb2c6129..2a307ce06 100644 --- a/src/Instance/HoldingsList/Holding/HoldingContainer.test.js +++ b/src/Instance/HoldingsList/Holding/HoldingContainer.test.js @@ -54,6 +54,8 @@ const renderHoldingContainer = (props = {}) => renderWithIntl( provided={{ draggableProps: { style: true } }} onViewHolding={jest.fn()} onAddItem={jest.fn()} + showViewHoldingsButton + showAddItemButton {...props} /> diff --git a/src/Instance/HoldingsList/HoldingsList.js b/src/Instance/HoldingsList/HoldingsList.js index a7d43cd80..233329569 100644 --- a/src/Instance/HoldingsList/HoldingsList.js +++ b/src/Instance/HoldingsList/HoldingsList.js @@ -7,8 +7,8 @@ const HoldingsList = ({ instance, holdings, tenantId, - isViewHoldingsDisabled, - isAddItemDisabled, + showViewHoldingsButton, + showAddItemButton, isBarcodeAsHotlink, draggable, droppable, @@ -21,8 +21,8 @@ const HoldingsList = ({ droppable={droppable} holdings={holdings} tenantId={tenantId} - isViewHoldingsDisabled={isViewHoldingsDisabled} - isAddItemDisabled={isAddItemDisabled} + showViewHoldingsButton={showViewHoldingsButton} + showAddItemButton={showAddItemButton} isBarcodeAsHotlink={isBarcodeAsHotlink} /> )); @@ -31,8 +31,8 @@ HoldingsList.propTypes = { instance: PropTypes.object.isRequired, holdings: PropTypes.arrayOf(PropTypes.object), tenantId: PropTypes.string, - isViewHoldingsDisabled: PropTypes.bool, - isAddItemDisabled: PropTypes.bool, + showViewHoldingsButton: PropTypes.bool, + showAddItemButton: PropTypes.bool, isBarcodeAsHotlink: PropTypes.bool, draggable: PropTypes.bool, droppable: PropTypes.bool, diff --git a/src/Instance/HoldingsList/HoldingsListContainer.js b/src/Instance/HoldingsList/HoldingsListContainer.js index b12e2f186..72baed8a4 100644 --- a/src/Instance/HoldingsList/HoldingsListContainer.js +++ b/src/Instance/HoldingsList/HoldingsListContainer.js @@ -32,8 +32,8 @@ const HoldingsListContainer = ({ holdings={holdings} instance={instance} tenantId={tenantId} - isViewHoldingsDisabled={!canViewHoldings} - isAddItemDisabled={!canCreateItem} + showViewHoldingsButton={canViewHoldings} + showAddItemButton={canCreateItem} isBarcodeAsHotlink={canViewItems} /> ) : ( @@ -42,8 +42,8 @@ const HoldingsListContainer = ({ holdings={holdings} instance={instance} tenantId={tenantId} - isViewHoldingsDisabled={!canViewHoldings} - isAddItemDisabled={!canCreateItem} + showViewHoldingsButton={canViewHoldings} + showAddItemButton={canCreateItem} isBarcodeAsHotlink={canViewItems} /> ) diff --git a/src/Instance/InstanceDetails/InstanceDetails.js b/src/Instance/InstanceDetails/InstanceDetails.js index 8190caf2d..51f4338c4 100644 --- a/src/Instance/InstanceDetails/InstanceDetails.js +++ b/src/Instance/InstanceDetails/InstanceDetails.js @@ -197,10 +197,9 @@ const InstanceDetails = forwardRef(({ {children} - {!isUserInCentralTenant && ( + {!isUserInCentralTenant && canCreateHoldings && ( )} diff --git a/src/Instance/InstanceDetails/InstanceNewHolding/InstanceNewHolding.js b/src/Instance/InstanceDetails/InstanceNewHolding/InstanceNewHolding.js index c21dff9c7..257b07fe1 100644 --- a/src/Instance/InstanceDetails/InstanceNewHolding/InstanceNewHolding.js +++ b/src/Instance/InstanceDetails/InstanceNewHolding/InstanceNewHolding.js @@ -20,7 +20,6 @@ const InstanceNewHolding = ({ location, instance, tenantId, - disabled, }) => { const intl = useIntl(); const stripes = useStripes(); @@ -49,7 +48,6 @@ const InstanceNewHolding = ({ buttonStyle="primary" fullWidth onClick={() => switchAffiliation(stripes, tenantId, onNewHolding)} - disabled={disabled} > {label} @@ -63,7 +61,6 @@ InstanceNewHolding.propTypes = { location: PropTypes.object.isRequired, instance: PropTypes.object, tenantId: PropTypes.string, - disabled: PropTypes.bool, }; export default withRouter(InstanceNewHolding); diff --git a/src/Instance/InstanceDetails/MemberTenantHoldings/MemberTenantHoldings.js b/src/Instance/InstanceDetails/MemberTenantHoldings/MemberTenantHoldings.js index 238e0bf05..45bb6c1dd 100644 --- a/src/Instance/InstanceDetails/MemberTenantHoldings/MemberTenantHoldings.js +++ b/src/Instance/InstanceDetails/MemberTenantHoldings/MemberTenantHoldings.js @@ -58,18 +58,17 @@ const MemberTenantHoldings = ({ tenantId={id} draggable={false} droppable={false} - isViewHoldingsDisabled={!canViewHoldings} - isAddItemDisabled={!canCreateItem} + showViewHoldingsButton={canViewHoldings} + showAddItemButton={canCreateItem} isBarcodeAsHotlink={canViewItems} /> )} - {!isUserInCentralTenant && ( + {!isUserInCentralTenant && canCreateHoldings && ( )} diff --git a/src/Instance/InstanceDetails/MemberTenantHoldings/MemberTenantHoldings.test.js b/src/Instance/InstanceDetails/MemberTenantHoldings/MemberTenantHoldings.test.js index 35493a3a9..f6271d607 100644 --- a/src/Instance/InstanceDetails/MemberTenantHoldings/MemberTenantHoldings.test.js +++ b/src/Instance/InstanceDetails/MemberTenantHoldings/MemberTenantHoldings.test.js @@ -33,7 +33,7 @@ const mockMemberTenant = { const userTenantPermissions = [{ tenantId: 'college', permissionNames: [{ - permissionName: 'test Permission name 1', + permissionName: 'ui-inventory.holdings.edit', subPermissions: ['test subPermission 1'] }], }]; diff --git a/src/Instance/InstanceMovement/HoldingMovementList/HoldingsListMovement.js b/src/Instance/InstanceMovement/HoldingMovementList/HoldingsListMovement.js index 36aeec7ec..8941f41e9 100644 --- a/src/Instance/InstanceMovement/HoldingMovementList/HoldingsListMovement.js +++ b/src/Instance/InstanceMovement/HoldingMovementList/HoldingsListMovement.js @@ -23,8 +23,8 @@ const HoldingsListMovement = ({ draggable, droppable, tenantId, - isViewHoldingsDisabled, - isAddItemDisabled, + showViewHoldingsButton, + showAddItemButton, isBarcodeAsHotlink, }) => { const { @@ -61,8 +61,8 @@ const HoldingsListMovement = ({ holdingIndex={index} draggingHoldingsCount={draggingHoldingsCount} tenantId={tenantId} - isViewHoldingsDisabled={isViewHoldingsDisabled} - isAddItemDisabled={isAddItemDisabled} + showViewHoldingsButton={showViewHoldingsButton} + showAddItemButton={showAddItemButton} isBarcodeAsHotlink={isBarcodeAsHotlink} /> )) @@ -82,8 +82,8 @@ const HoldingsListMovement = ({ HoldingsListMovement.propTypes = { instance: PropTypes.object.isRequired, holdings: PropTypes.arrayOf(PropTypes.object), - isViewHoldingsDisabled: PropTypes.bool, - isAddItemDisabled: PropTypes.bool, + showViewHoldingsButton: PropTypes.bool, + showAddItemButton: PropTypes.bool, isBarcodeAsHotlink: PropTypes.bool, draggable: PropTypes.bool, droppable: PropTypes.bool,