Skip to content

Commit

Permalink
fix: do not make pins request if the user does not have access #2117
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra Stoica committed Nov 24, 2022
1 parent fdfa333 commit 2953a8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
Expand All @@ -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 => {
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/website/components/contexts/userContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
*/

/**
Expand Down

0 comments on commit 2953a8c

Please sign in to comment.