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-2452: Fix creating/editing/duplicating holdings/items for different member tenants (follow-up) #2319

Merged
merged 56 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
e9ff698
Consortial holdings acc
mariia-aloshyna Sep 22, 2023
f5c029c
UIIN-2410: Adjustments
mariia-aloshyna Sep 25, 2023
4a08c0c
UIIN-2410: Add new hook
mariia-aloshyna Sep 27, 2023
5dfcf0d
UIIN-2410: Add tests
mariia-aloshyna Sep 27, 2023
188acc3
UIIN-2452: Disable buttons when member tenant does not have permissions
OleksandrHladchenko1 Oct 3, 2023
58f4cd4
UIIN-2410: Instance 3rd pane: Add consortial holdings/item accordion
mariia-aloshyna Sep 22, 2023
dc2e0d0
UIIN-2452: Add unit tests & switching affiliation when view holdings …
OleksandrHladchenko1 Oct 3, 2023
108f852
UIIN-2410: Fix tests
mariia-aloshyna Oct 4, 2023
3f42476
Merge branch 'master' into UIIN-2410
mariia-aloshyna Oct 4, 2023
9e1b138
UIIN-2452: Add switching affiliation when click on item barcode & Add…
OleksandrHladchenko1 Oct 5, 2023
872f7be
Merge branch 'master' into UIIN-2452
OleksandrHladchenko1 Oct 5, 2023
c8e3f29
UIIN-2452: Add behaviour for non-consortial tenant
OleksandrHladchenko1 Oct 6, 2023
f57ce13
Merge branch 'UIIN-2452' of https://github.com/folio-org/ui-inventory…
OleksandrHladchenko1 Oct 6, 2023
5726f06
UIIN-2452: Fix tests
OleksandrHladchenko1 Oct 6, 2023
d25021e
Merge branch 'master' into UIIN-2452
OleksandrHladchenko1 Oct 6, 2023
767a4a1
Update HoldingAccordion.js
OleksandrHladchenko1 Oct 6, 2023
5769fca
Update HoldingButtonsGroup.js
OleksandrHladchenko1 Oct 6, 2023
fc4b05a
UIIN-2452: Fix tests
OleksandrHladchenko1 Oct 6, 2023
1c5bcd1
Merge branch 'UIIN-2452' of https://github.com/folio-org/ui-inventory…
OleksandrHladchenko1 Oct 6, 2023
081f18b
Update HoldingsListMovement.js
OleksandrHladchenko1 Oct 8, 2023
60b4011
Update HoldingContainer.js
OleksandrHladchenko1 Oct 9, 2023
9c397c8
UIIN-2452: Add returning to the previous affiliation
OleksandrHladchenko1 Oct 10, 2023
483d77e
Merge branch 'UIIN-2452' of https://github.com/folio-org/ui-inventory…
OleksandrHladchenko1 Oct 10, 2023
7894483
UIIN-2452: Add tenantId to props validation
OleksandrHladchenko1 Oct 10, 2023
a7efac1
UIIN-2452: Add behaviour for non-consortial tenant
OleksandrHladchenko1 Oct 10, 2023
42f16f0
Fix some comments
mariia-aloshyna Oct 13, 2023
22d2dc9
Fix perms handling
mariia-aloshyna Oct 13, 2023
ae50bd4
Merge branch 'master' into UIIN-2452
mariia-aloshyna Oct 13, 2023
69396b4
Fix warnings
mariia-aloshyna Oct 13, 2023
4244578
Adjust tests
mariia-aloshyna Oct 13, 2023
39c34b5
Merge branch 'master' into UIIN-2452
mariia-aloshyna Oct 13, 2023
27fc561
Fix tests
mariia-aloshyna Oct 13, 2023
2398063
Merge remote-tracking branch 'origin/UIIN-2452' into UIIN-2452
mariia-aloshyna Oct 13, 2023
a603d03
UIIN-2452: Switch user affiliation using validateUser
OleksandrHladchenko1 Oct 17, 2023
b313553
Merge branch 'master' into UIIN-2452
OleksandrHladchenko1 Oct 17, 2023
e18e43c
Update HoldingAccordion.js
OleksandrHladchenko1 Oct 17, 2023
f72699c
Supress Add holding & Add item & View holdings buttons if user doesn'…
OleksandrHladchenko1 Oct 18, 2023
10a2e3a
Resolve conflicts
OleksandrHladchenko1 Oct 18, 2023
773e3c1
UIIN-2452: Fix comments & add unit tests
OleksandrHladchenko1 Oct 18, 2023
76a05f7
UIIN-2452: Fixes after review
OleksandrHladchenko1 Oct 18, 2023
4d4d213
Merge branch 'master' into UIIN-2452
OleksandrHladchenko1 Oct 18, 2023
355c482
UIIN-2452: Fix code smells
OleksandrHladchenko1 Oct 18, 2023
00589ea
Merge branch 'UIIN-2452' of https://github.com/folio-org/ui-inventory…
OleksandrHladchenko1 Oct 18, 2023
99a92ca
UIIN-2452: Change permissions to view/create holdings and items
OleksandrHladchenko1 Oct 24, 2023
05d6335
UIIN-2452: Change permissions to view/create holdings and items
OleksandrHladchenko1 Oct 24, 2023
527541f
Merge branch 'master' into UIIN-2452
OleksandrHladchenko1 Oct 24, 2023
730279c
UIIN-2452: Instance 3rd pane: Enable/disable consortial holdings/item…
mariia-aloshyna Oct 24, 2023
fd7e0ce
Merge origin UIIN-2452
mariia-aloshyna Oct 24, 2023
1523490
UIIN-2452: Fixes in CreateHoldings component
OleksandrHladchenko1 Oct 24, 2023
add9713
UIIN-2452: Fix test
OleksandrHladchenko1 Oct 24, 2023
d62e8d3
UIIN-2452: fix creating holdings/items for different member tenants
OleksandrHladchenko1 Oct 26, 2023
22ec665
UIIN-2452: Fix code smells
OleksandrHladchenko1 Oct 26, 2023
b5c1604
Merge branch 'master' into UIIN-2452
OleksandrHladchenko1 Oct 26, 2023
bdd7406
UIIN-2452: Fix tests
OleksandrHladchenko1 Oct 27, 2023
cd47a0d
Merge branch 'UIIN-2452' of https://github.com/folio-org/ui-inventory…
OleksandrHladchenko1 Oct 27, 2023
56ad03a
UIIN-2452: Remove excessive permission checking
OleksandrHladchenko1 Oct 27, 2023
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
11 changes: 6 additions & 5 deletions src/Holding/CreateHolding/CreateHolding.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const CreateHolding = ({
const callout = useCallout();
const { instance, isLoading: isInstanceLoading } = useInstance(instanceId);
const sourceId = referenceData.holdingsSourcesByName?.FOLIO?.id;
const { location: { state: { tenantFrom } } } = history;
const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant;

const goBack = useCallback(() => {
history.push({
Expand All @@ -39,21 +39,22 @@ const CreateHolding = ({
});
}, [location.search, instanceId]);

const onCancel = useCallback(() => {
switchAffiliation(stripes, tenantFrom, goBack);
const onCancel = useCallback(async () => {
await switchAffiliation(stripes, tenantFrom, goBack);
}, [stripes, tenantFrom, goBack]);

const onSubmit = useCallback((newHolding) => {
return mutator.holding.POST(newHolding)
.then((holdingsRecord) => {
.then(async (holdingsRecord) => {
await onCancel();

callout.sendCallout({
type: 'success',
message: <FormattedMessage
id="ui-inventory.holdingsRecord.successfullySaved"
values={{ hrid: holdingsRecord.hrid }}
/>,
});
onCancel();
});
}, [onCancel, callout]);

Expand Down
8 changes: 6 additions & 2 deletions src/Instance/HoldingsList/Holding/HoldingButtonsGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const HoldingButtonsGroup = ({
<Button
id={`clickable-view-holdings-${holding.id}`}
data-test-view-holdings
onClick={() => switchAffiliation(stripes, tenantId, onViewHolding)}
onClick={async () => {
await switchAffiliation(stripes, tenantId, onViewHolding);
}}
>
<FormattedMessage id="ui-inventory.viewHoldings" />
</Button>
Expand All @@ -58,7 +60,9 @@ const HoldingButtonsGroup = ({
<Button
id={`clickable-new-item-${holding.id}`}
data-test-add-item
onClick={() => switchAffiliation(stripes, tenantId, onAddItem)}
onClick={async () => {
await switchAffiliation(stripes, tenantId, onAddItem);
}}
buttonStyle="primary paneHeaderNewButton"
>
<FormattedMessage id="ui-inventory.addItem" />
Expand Down
6 changes: 3 additions & 3 deletions src/Instance/HoldingsList/HoldingsListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const HoldingsListContainer = ({
const stripes = useStripes();
const { holdingsRecords: holdings, isLoading } = useInstanceHoldingsQuery(instance.id, { tenantId });

const canViewHoldings = stripes.hasPerm('ui-inventory.instance.view');
const canCreateItem = stripes.hasPerm('ui-inventory.item.edit');
const canViewItems = stripes.hasPerm('ui-inventory.instance.view');
const canViewHoldings = stripes.hasPerm('ui-inventory.holdings.create');
const canCreateItem = stripes.hasPerm('ui-inventory.item.create');
const canViewItems = stripes.hasPerm('ui-inventory.item.create');

if (isLoading) return <Loading size="large" />;

Expand Down
2 changes: 1 addition & 1 deletion src/Instance/InstanceDetails/InstanceDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const InstanceDetails = forwardRef(({
const tags = instance?.tags?.tagList;
const isUserInCentralTenant = checkIfUserInCentralTenant(stripes);

const canCreateHoldings = stripes.hasPerm('ui-inventory.holdings.edit');
const canCreateHoldings = stripes.hasPerm('ui-inventory.holdings.create');

const detailsLastMenu = useMemo(() => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ const InstanceNewHolding = ({
aria-label={label}
buttonStyle="primary"
fullWidth
onClick={() => switchAffiliation(stripes, tenantId, onNewHolding)}
onClick={async () => {
await switchAffiliation(stripes, tenantId, onNewHolding);
}}
>
{label}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ const MemberTenantHoldings = ({
const { holdingsRecords, isLoading } = useInstanceHoldingsQuery(instance?.id, { tenantId: id });
const isUserInCentralTenant = checkIfUserInCentralTenant(stripes);

const canViewHoldings = hasMemberTenantPermission('ui-inventory.instance.view', id, userTenantPermissions);
const canCreateItem = hasMemberTenantPermission('ui-inventory.item.edit', id, userTenantPermissions);
const canCreateHoldings = hasMemberTenantPermission('ui-inventory.holdings.edit', id, userTenantPermissions);
const canViewItems = hasMemberTenantPermission('ui-inventory.instance.view', id, userTenantPermissions);
const canViewHoldings = hasMemberTenantPermission('ui-inventory.holdings.create', id, userTenantPermissions);
OleksandrHladchenko1 marked this conversation as resolved.
Show resolved Hide resolved
const canCreateItem = hasMemberTenantPermission('ui-inventory.item.create', id, userTenantPermissions);
const canCreateHoldings = hasMemberTenantPermission('ui-inventory.holdings.create', id, userTenantPermissions);
const canViewItems = hasMemberTenantPermission('ui-inventory.item.create', id, userTenantPermissions);

if (isEmpty(holdingsRecords)) return null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const mockMemberTenant = {
const userTenantPermissions = [{
tenantId: 'college',
permissionNames: [{
permissionName: 'ui-inventory.holdings.edit',
permissionName: 'ui-inventory.holdings.create',
subPermissions: ['test subPermission 1']
}],
}];
Expand Down
4 changes: 3 additions & 1 deletion src/Instance/ItemsList/ItemBarcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ const ItemBarcode = ({
<Button
buttonStyle="link"
buttonClass={css.linkWithoutBorder}
onClick={() => switchAffiliation(stripes, tenantId, onViewItem)}
onClick={async () => {
await switchAffiliation(stripes, tenantId, onViewItem);
}}
>
{itemBarcode}
</Button>
Expand Down
10 changes: 5 additions & 5 deletions src/Item/CreateItem/CreateItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const CreateItem = ({
state: {
tenantTo,
tenantFrom,
},
},
} = {},
} = {},
} = useHistory();

const { isLoading: isInstanceLoading, instance } = useInstanceQuery(instanceId, { tenantId: tenantTo });
Expand All @@ -51,14 +51,14 @@ const CreateItem = ({
});
}, [instanceId, search]);

const onCancel = useCallback(() => {
switchAffiliation(stripes, tenantFrom, goBack);
const onCancel = useCallback(async () => {
await switchAffiliation(stripes, tenantFrom, goBack);
}, [stripes, tenantFrom]);

const onSuccess = useCallback(async (response) => {
const { hrid } = await response.json();

onCancel();
await onCancel();

return callout.sendCallout({
type: 'success',
Expand Down
4 changes: 3 additions & 1 deletion src/ViewHoldingsRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,9 @@ class ViewHoldingsRecord extends React.Component {
updatedDate: getDate(holdingsRecord?.metadata?.updatedDate),
})}
dismissible
onClose={() => switchAffiliation(stripes, tenantFrom, this.onClose)}
onClose={async () => {
await switchAffiliation(stripes, tenantFrom, this.onClose);
}}
actionMenu={this.getPaneHeaderActionMenu}
>
<Row center="xs">
Expand Down
4 changes: 2 additions & 2 deletions src/routes/ItemRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ class ItemRoute extends React.Component {
});
}

onClose = () => {
onClose = async () => {
const {
stripes,
location,
} = this.props;
const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant;

switchAffiliation(stripes, tenantFrom, this.goBack);
await switchAffiliation(stripes, tenantFrom, this.goBack);
}

isLoading = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ export const switchAffiliation = async (stripes, tenantId, move) => {
if (stripes.okapi.tenant !== tenantId) {
await updateTenant(stripes.okapi, tenantId);

validateUser(
await validateUser(
stripes.okapi.url,
stripes.store,
tenantId,
Expand Down
Loading