From b39f6a2f0d01761ba158cd5f0d6ecbeafde2f1f9 Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Mon, 21 Nov 2022 13:38:21 +0100 Subject: [PATCH] disable approvers select when no access (#2486) --- .../ChangeRequestConfiguration.tsx | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/frontend/src/component/project/Project/ProjectSettings/ChangeRequestConfiguration/ChangeRequestConfiguration.tsx b/frontend/src/component/project/Project/ProjectSettings/ChangeRequestConfiguration/ChangeRequestConfiguration.tsx index a9eb87a235..0f548cdd21 100644 --- a/frontend/src/component/project/Project/ProjectSettings/ChangeRequestConfiguration/ChangeRequestConfiguration.tsx +++ b/frontend/src/component/project/Project/ProjectSettings/ChangeRequestConfiguration/ChangeRequestConfiguration.tsx @@ -1,4 +1,4 @@ -import React, { useMemo, useState, VFC } from 'react'; +import React, { useContext, useMemo, useState, VFC } from 'react'; import { HeaderGroup, useGlobalFilter, useTable } from 'react-table'; import { Alert, Box, styled, Typography } from '@mui/material'; import { @@ -25,9 +25,10 @@ import { UPDATE_PROJECT } from '@server/types/permissions'; import useToast from 'hooks/useToast'; import { formatUnknownError } from 'utils/formatUnknownError'; import { ChangeRequestProcessHelp } from './ChangeRequestProcessHelp/ChangeRequestProcessHelp'; -import GeneralSelect from '../../../../common/GeneralSelect/GeneralSelect'; +import GeneralSelect from 'component/common/GeneralSelect/GeneralSelect'; import { KeyboardArrowDownOutlined } from '@mui/icons-material'; import { useTheme } from '@mui/material/styles'; +import AccessContext from 'contexts/AccessContext'; const StyledBox = styled(Box)(({ theme }) => ({ padding: theme.spacing(1), @@ -141,27 +142,34 @@ export const ChangeRequestConfiguration: VFC = () => { { Header: 'Required approvals', align: 'center', - Cell: ({ row: { original } }: any) => ( - - { - onRequiredApprovalsChange( - original, - approvals - ); - }} - IconComponent={KeyboardArrowDownOutlined} - fullWidth - /> - - } - /> - ), + Cell: ({ row: { original } }: any) => { + const { hasAccess } = useContext(AccessContext); + + return ( + + { + onRequiredApprovalsChange( + original, + approvals + ); + }} + disabled={!hasAccess(UPDATE_PROJECT)} + IconComponent={ + KeyboardArrowDownOutlined + } + fullWidth + /> + + } + /> + ); + }, width: 100, disableGlobalFilter: true, disableSortBy: true,