diff --git a/frontend/src/component/environments/EnvironmentTable/EnvironmentTable.tsx b/frontend/src/component/environments/EnvironmentTable/EnvironmentTable.tsx index f65638e230..d4b0e948f4 100644 --- a/frontend/src/component/environments/EnvironmentTable/EnvironmentTable.tsx +++ b/frontend/src/component/environments/EnvironmentTable/EnvironmentTable.tsx @@ -28,6 +28,8 @@ import { TextCell } from 'component/common/Table/cells/TextCell/TextCell'; import type { IEnvironment } from 'interfaces/environments'; import { useUiFlag } from 'hooks/useUiFlag'; import { PremiumFeature } from 'component/common/PremiumFeature/PremiumFeature'; +import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; + const StyledAlert = styled(Alert)(({ theme }) => ({ marginBottom: theme.spacing(4), })); @@ -37,6 +39,10 @@ export const EnvironmentTable = () => { const { setToastApiError } = useToast(); const { environments, mutateEnvironments } = useEnvironments(); const isFeatureEnabled = useUiFlag('EEA'); + const globalChangeRequestConfigEnabled = useUiFlag( + 'globalChangeRequestConfig', + ); + const { isEnterprise } = useUiConfig(); const onMoveItem: OnMoveItem = useCallback( async ({ dragIndex, dropIndex, save }) => { @@ -61,26 +67,36 @@ export const EnvironmentTable = () => { ); const columnsWithActions = useMemo(() => { - if (isFeatureEnabled) { - return [ - ...COLUMNS, - { - Header: 'Actions', - id: 'Actions', - align: 'center', - width: '1%', - Cell: ({ - row: { original }, - }: { row: { original: IEnvironment } }) => ( - - ), - disableGlobalFilter: true, - }, - ]; + const baseColumns = [ + ...COLUMNS, + ...(isFeatureEnabled + ? [ + { + Header: 'Actions', + id: 'Actions', + align: 'center', + width: '1%', + Cell: ({ + row: { original }, + }: { row: { original: IEnvironment } }) => ( + + ), + disableGlobalFilter: true, + }, + ] + : []), + ]; + if (globalChangeRequestConfigEnabled && isEnterprise()) { + baseColumns.splice(2, 0, { + Header: 'Change request', + accessor: (row: IEnvironment) => + Number.isInteger(row.requiredApprovals) ? 'yes' : 'no', + Cell: TextCell, + }); } - return COLUMNS; - }, [isFeatureEnabled]); + return baseColumns; + }, [isFeatureEnabled, globalChangeRequestConfigEnabled]); const { getTableProps,