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,26 +67,36 @@ export const EnvironmentTable = () => {
); );
const columnsWithActions = useMemo(() => { const columnsWithActions = useMemo(() => {
if (isFeatureEnabled) { const baseColumns = [
return [ ...COLUMNS,
...COLUMNS, ...(isFeatureEnabled
{ ? [
Header: 'Actions', {
id: 'Actions', Header: 'Actions',
align: 'center', id: 'Actions',
width: '1%', align: 'center',
Cell: ({ width: '1%',
row: { original }, Cell: ({
}: { row: { original: IEnvironment } }) => ( row: { original },
<EnvironmentActionCell environment={original} /> }: { row: { original: IEnvironment } }) => (
), <EnvironmentActionCell environment={original} />
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,