fix(requests): do not fail request edits if acting user lacks Manage Users permission (#2338)

* fix(api): fix requestedBy logic in request edits

* fix(frontend): do not display empty advanced request options box

* fix(frontend): set max height on modal backdrop
pull/2336/head
TheCatLady 3 years ago committed by GitHub
parent dc7f959cb4
commit 91bfff71b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -549,11 +549,11 @@ requestRoutes.put<{ requestId: string }>(
});
}
let requestUser = req.user;
let requestUser = request.requestedBy;
if (
req.body.userId &&
req.body.userId !== req.user?.id &&
req.body.userId !== request.requestedBy.id &&
!req.user?.hasPermission([
Permission.MANAGE_USERS,
Permission.MANAGE_REQUESTS,

@ -111,7 +111,7 @@ const Modal: React.FC<ModalProps> = ({
}}
>
{backdrop && (
<div className="absolute top-0 left-0 right-0 z-0 w-full h-64">
<div className="absolute top-0 left-0 right-0 z-0 w-full h-64 max-h-full">
<CachedImage
alt=""
src={backdrop}

@ -267,7 +267,17 @@ const AdvancedRequester: React.FC<AdvancedRequesterProps> = ({
);
}
if ((!data || selectedServer === null) && !selectedUser) {
if (
(!data ||
selectedServer === null ||
(data.filter((server) => server.is4k === is4k).length < 2 &&
(!serverData ||
(serverData.profiles.length < 2 &&
serverData.rootFolders.length < 2 &&
(serverData.languageProfiles ?? []).length < 2 &&
!serverData.tags?.length)))) &&
(!selectedUser || (userData?.results ?? []).length < 2)
) {
return null;
}
@ -503,7 +513,8 @@ const AdvancedRequester: React.FC<AdvancedRequesterProps> = ({
</div>
)}
{hasPermission([Permission.MANAGE_REQUESTS, Permission.MANAGE_USERS]) &&
selectedUser && (
selectedUser &&
(userData?.results ?? []).length > 1 && (
<Listbox
as="div"
value={selectedUser}

Loading…
Cancel
Save