1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-21 13:47:39 +02:00

disable approvers select when no access (#2486)

This commit is contained in:
Mateusz Kwasniewski 2022-11-21 13:38:21 +01:00 committed by GitHub
parent 6e5b214475
commit b39f6a2f0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 { HeaderGroup, useGlobalFilter, useTable } from 'react-table';
import { Alert, Box, styled, Typography } from '@mui/material'; import { Alert, Box, styled, Typography } from '@mui/material';
import { import {
@ -25,9 +25,10 @@ import { UPDATE_PROJECT } from '@server/types/permissions';
import useToast from 'hooks/useToast'; import useToast from 'hooks/useToast';
import { formatUnknownError } from 'utils/formatUnknownError'; import { formatUnknownError } from 'utils/formatUnknownError';
import { ChangeRequestProcessHelp } from './ChangeRequestProcessHelp/ChangeRequestProcessHelp'; 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 { KeyboardArrowDownOutlined } from '@mui/icons-material';
import { useTheme } from '@mui/material/styles'; import { useTheme } from '@mui/material/styles';
import AccessContext from 'contexts/AccessContext';
const StyledBox = styled(Box)(({ theme }) => ({ const StyledBox = styled(Box)(({ theme }) => ({
padding: theme.spacing(1), padding: theme.spacing(1),
@ -141,7 +142,10 @@ export const ChangeRequestConfiguration: VFC = () => {
{ {
Header: 'Required approvals', Header: 'Required approvals',
align: 'center', align: 'center',
Cell: ({ row: { original } }: any) => ( Cell: ({ row: { original } }: any) => {
const { hasAccess } = useContext(AccessContext);
return (
<ConditionallyRender <ConditionallyRender
condition={original.changeRequestEnabled} condition={original.changeRequestEnabled}
show={ show={
@ -155,13 +159,17 @@ export const ChangeRequestConfiguration: VFC = () => {
approvals approvals
); );
}} }}
IconComponent={KeyboardArrowDownOutlined} disabled={!hasAccess(UPDATE_PROJECT)}
IconComponent={
KeyboardArrowDownOutlined
}
fullWidth fullWidth
/> />
</StyledBox> </StyledBox>
} }
/> />
), );
},
width: 100, width: 100,
disableGlobalFilter: true, disableGlobalFilter: true,
disableSortBy: true, disableSortBy: true,