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:
parent
47c6f43865
commit
cc0348beba
@ -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 } }) => (
|
||||
<EnvironmentActionCell environment={original} />
|
||||
),
|
||||
disableGlobalFilter: true,
|
||||
},
|
||||
];
|
||||
const baseColumns = [
|
||||
...COLUMNS,
|
||||
...(isFeatureEnabled
|
||||
? [
|
||||
{
|
||||
Header: 'Actions',
|
||||
id: 'Actions',
|
||||
align: 'center',
|
||||
width: '1%',
|
||||
Cell: ({
|
||||
row: { original },
|
||||
}: { row: { original: IEnvironment } }) => (
|
||||
<EnvironmentActionCell environment={original} />
|
||||
),
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user