From 9cb7e1495ab2860cea614d10f6f7b62cf77b4def Mon Sep 17 00:00:00 2001 From: Gauthier Date: Wed, 18 Jun 2025 00:00:48 +0200 Subject: [PATCH] fix: redirect the 'Request' button to the right page (#1711) This PR change the link of the 'Request' button of the UserDropdown for user with no MANAGE_REQUEST or REQUEST_VIEW permissions. These users can't see the /users/:ID/requests page, so there were redirected to the home page. This PR also removes the /profile/request page which is the same as the /request or the /users/:ID/requests page. fix #1588 --- src/components/Layout/UserDropdown/index.tsx | 13 ++++++++++--- src/components/UserProfile/index.tsx | 18 ++++++++++++------ src/pages/profile/requests.tsx | 8 -------- 3 files changed, 22 insertions(+), 17 deletions(-) delete mode 100644 src/pages/profile/requests.tsx diff --git a/src/components/Layout/UserDropdown/index.tsx b/src/components/Layout/UserDropdown/index.tsx index a0539fd35..630112b30 100644 --- a/src/components/Layout/UserDropdown/index.tsx +++ b/src/components/Layout/UserDropdown/index.tsx @@ -1,6 +1,6 @@ import CachedImage from '@app/components/Common/CachedImage'; import MiniQuotaDisplay from '@app/components/Layout/UserDropdown/MiniQuotaDisplay'; -import { useUser } from '@app/hooks/useUser'; +import { Permission, useUser } from '@app/hooks/useUser'; import defineMessages from '@app/utils/defineMessages'; import { Menu, Transition } from '@headlessui/react'; import { @@ -36,7 +36,7 @@ ForwardedLink.displayName = 'ForwardedLink'; const UserDropdown = () => { const intl = useIntl(); - const { user, revalidate } = useUser(); + const { user, revalidate, hasPermission } = useUser(); const logout = async () => { const response = await axios.post('/api/v1/auth/logout'); @@ -118,7 +118,14 @@ const UserDropdown = () => { {({ active }) => ( {
{intl.formatNumber(user.requestCount)} @@ -293,9 +296,12 @@ const UserProfile = () => {
diff --git a/src/pages/profile/requests.tsx b/src/pages/profile/requests.tsx deleted file mode 100644 index f70b0f798..000000000 --- a/src/pages/profile/requests.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import RequestList from '@app/components/RequestList'; -import type { NextPage } from 'next'; - -const UserRequestsPage: NextPage = () => { - return ; -}; - -export default UserRequestsPage;