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-2811 Use consolidated locations endpoint to fetch all locations when in central tenant context. #2471

Merged
merged 2 commits into from
May 2, 2024

Conversation

BogdanDenis
Copy link
Contributor

Description

Use consolidated locations endpoint to fetch all locations when in central tenant context.

Screenshots

chrome_CyucJPIggv.mp4

Issues

UIIN-2811

Copy link

github-actions bot commented Apr 29, 2024

Jest Unit Test Statistics

       1 files  ±0     246 suites  ±0   13m 17s ⏱️ +13s
1 001 tests +3     999 ✔️ +3  2 💤 ±0  0 ±0 
1 007 runs  +3  1 005 ✔️ +3  2 💤 ±0  0 ±0 

Results for commit 0f4189e. ± Comparison against base commit 653db31.

♻️ This comment has been updated with latest results.

const { data: consolidatedLocations } = useQuery({
queryKey: [namespace, 'consolidatedLocations'],
queryFn: () => ky.get('search/consortium/locations').json(),
enabled: Boolean(isUserInConsortiumMode(stripes) && isUserInCentralTenant),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we use this endpoint on member tenants? This would improve performance (avoid sending 65 requests for 65 tenants for example) and also will allow us to display locations for Consortial holdings accordion for tenants with limited permissions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a limitation on back-end side unfortunately, the endpoint was implemented with this in mind

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use similar endpoints on member tenants - useConsortiumHoldings and useConsortiumItems, but sending requests in the context of central tenant. Or are there some other limitations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I misunderstood your question - useConsortiumHoldings and useConsortiumItems send requests when a user is in central tenant. Same with the locations endpoint. We only use it when user is in central tenant. If it's a member tenant then we should send multiple requests to a regular /locations endpoint
I think it's the same limitation as for holdings and items - user in a member tenant may not have permissions in central or other tenants to fetch locations from other tenants

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a situation where we have an admin from a member tenant who is affiliated with all other tenants in the consortia?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-no, useConsortiumHoldings and useConsortiumItems are also sent from member tenants but in the context of the central tenant (x-okapi-tenant: central). 1 difference here is that they are sent only with the condition that a particular member tenant does not have permission to get holdings/items from inventory storage. You can find more here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint still requires central tenant permissions, and in our case we want users without central tenant permissions to fetch locations from other tenants.

@BogdanDenis BogdanDenis requested review from mariia-aloshyna and a team April 30, 2024 09:08
Copy link

sonarcloud bot commented May 2, 2024

@BogdanDenis BogdanDenis merged commit bf8021e into master May 2, 2024
5 checks passed
@BogdanDenis BogdanDenis deleted the UIIN-2811 branch May 2, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants