From 2953a8c2777ef81f6119087c6519bb549e528cf9 Mon Sep 17 00:00:00 2001 From: Alexandra Stoica Date: Thu, 24 Nov 2022 11:00:53 +0000 Subject: [PATCH] fix: do not make pins request if the user does not have access #2117 --- .../account/filesManager/pinRequestsTable.js | 13 ++++++++----- packages/website/components/contexts/userContext.js | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/website/components/account/filesManager/pinRequestsTable.js b/packages/website/components/account/filesManager/pinRequestsTable.js index 671411e79c..b095f1156b 100644 --- a/packages/website/components/account/filesManager/pinRequestsTable.js +++ b/packages/website/components/account/filesManager/pinRequestsTable.js @@ -10,9 +10,9 @@ import Modal from 'modules/zero/components/modal/modal'; import CloseIcon from 'assets/icons/close'; import { useUser } from 'components/contexts/userContext'; import RefreshIcon from 'assets/icons/refresh'; +import { usePinRequests } from 'components/contexts/pinRequestsContext'; import PinRequestRowItem from './pinRequestRowItem'; import GradientBackground from '../../gradientbackground/gradientbackground.js'; -import { usePinRequests } from 'components/contexts/pinRequestsContext'; /** * @typedef {Object} PinRequestsTableProps @@ -29,6 +29,7 @@ const PinRequestsTable = ({ content, hidden, onUpdatingChange, showCheckOverlay const { pinRequests, pages, fetchDate, getPinRequests, isFetching, deletePinRequest } = usePinRequests(); const { storageData: { refetch }, + info, } = useUser(); const [status] = useState('queued,pinning,pinned,failed'); @@ -44,9 +45,11 @@ const PinRequestsTable = ({ content, hidden, onUpdatingChange, showCheckOverlay const fileRowLabels = content?.table.file_row_labels; useEffect(() => { - getPinRequests({ status, page, size }); - setSelectedPinRequests([]); - }, [getPinRequests, status, page, size]); + if (info?.tags?.HasPsaAccess) { + getPinRequests({ status, page, size }); + setSelectedPinRequests([]); + } + }, [info, getPinRequests, status, page, size]); const onSelectAllToggle = useCallback( e => { @@ -131,7 +134,7 @@ const PinRequestsTable = ({ content, hidden, onUpdatingChange, showCheckOverlay showCheckOverlay(); }, [getPinRequests, status, page, size, showCheckOverlay]); - if (hidden) { + if (hidden || !info?.tags?.HasPsaAccess) { return null; } diff --git a/packages/website/components/contexts/userContext.js b/packages/website/components/contexts/userContext.js index 203186f184..44753a9970 100644 --- a/packages/website/components/contexts/userContext.js +++ b/packages/website/components/contexts/userContext.js @@ -2,12 +2,13 @@ import React from 'react'; import { useQuery } from 'react-query'; import { getInfo, getStorage } from 'lib/api.js'; -import { useAuthorization } from './authorizationContext.js'; import AccountBlockedModal from 'components/account/accountBlockedModal/accountBlockedModal.js'; +import { useAuthorization } from './authorizationContext.js'; /** * @typedef Tags * @property {boolean} [HasAccountRestriction] + * @property {boolean} [HasPsaAccess] */ /**