1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-02 01:17:58 +02:00

feat: show environments with change requests (#9628)

This commit is contained in:
Mateusz Kwasniewski 2025-03-27 12:16:04 +01:00 committed by GitHub
parent 47c6f43865
commit cc0348beba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,6 +28,8 @@ import { TextCell } from 'component/common/Table/cells/TextCell/TextCell';
import type { IEnvironment } from 'interfaces/environments'; import type { IEnvironment } from 'interfaces/environments';
import { useUiFlag } from 'hooks/useUiFlag'; import { useUiFlag } from 'hooks/useUiFlag';
import { PremiumFeature } from 'component/common/PremiumFeature/PremiumFeature'; import { PremiumFeature } from 'component/common/PremiumFeature/PremiumFeature';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
const StyledAlert = styled(Alert)(({ theme }) => ({ const StyledAlert = styled(Alert)(({ theme }) => ({
marginBottom: theme.spacing(4), marginBottom: theme.spacing(4),
})); }));
@ -37,6 +39,10 @@ export const EnvironmentTable = () => {
const { setToastApiError } = useToast(); const { setToastApiError } = useToast();
const { environments, mutateEnvironments } = useEnvironments(); const { environments, mutateEnvironments } = useEnvironments();
const isFeatureEnabled = useUiFlag('EEA'); const isFeatureEnabled = useUiFlag('EEA');
const globalChangeRequestConfigEnabled = useUiFlag(
'globalChangeRequestConfig',
);
const { isEnterprise } = useUiConfig();
const onMoveItem: OnMoveItem = useCallback( const onMoveItem: OnMoveItem = useCallback(
async ({ dragIndex, dropIndex, save }) => { async ({ dragIndex, dropIndex, save }) => {
@ -61,9 +67,10 @@ export const EnvironmentTable = () => {
); );
const columnsWithActions = useMemo(() => { const columnsWithActions = useMemo(() => {
if (isFeatureEnabled) { const baseColumns = [
return [
...COLUMNS, ...COLUMNS,
...(isFeatureEnabled
? [
{ {
Header: 'Actions', Header: 'Actions',
id: 'Actions', id: 'Actions',
@ -76,11 +83,20 @@ export const EnvironmentTable = () => {
), ),
disableGlobalFilter: true, 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; return baseColumns;
}, [isFeatureEnabled]); }, [isFeatureEnabled, globalChangeRequestConfigEnabled]);
const { const {
getTableProps, getTableProps,