-
-
Notifications
You must be signed in to change notification settings - Fork 656
/
EnvironmentStrategyDialog.tsx
73 lines (67 loc) · 2.29 KB
/
EnvironmentStrategyDialog.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { useNavigate } from 'react-router-dom';
import { CREATE_FEATURE_STRATEGY } from 'component/providers/AccessProvider/permissions';
import { Dialogue } from 'component/common/Dialogue/Dialogue';
import PermissionButton from '../PermissionButton/PermissionButton';
import { formatCreateStrategyPath } from 'component/feature/FeatureStrategy/FeatureStrategyCreate/FeatureStrategyCreate';
import { styled } from '@mui/material';
interface IEnvironmentStrategyDialogProps {
open: boolean;
featureId: string;
projectId: string;
onClose: () => void;
environmentName: string;
}
const StyledParagraph = styled('p')(({ theme }) => ({
marginBottom: theme.spacing(0.5),
fontSize: theme.fontSizes.bodySize,
}));
const EnvironmentStrategyDialog = ({
open,
environmentName,
featureId,
projectId,
onClose,
}: IEnvironmentStrategyDialogProps) => {
const navigate = useNavigate();
const createStrategyPath = formatCreateStrategyPath(
projectId,
featureId,
environmentName,
'default'
);
const onClick = () => {
onClose();
navigate(createStrategyPath);
};
return (
<Dialogue
open={open}
maxWidth="sm"
onClose={() => onClose()}
title="You need to add a strategy to your toggle"
primaryButtonText="Take me directly to add strategy"
permissionButton={
<PermissionButton
type="button"
permission={CREATE_FEATURE_STRATEGY}
projectId={projectId}
environmentId={environmentName}
onClick={onClick}
>
Take me directly to add strategy
</PermissionButton>
}
secondaryButtonText="Cancel"
>
<StyledParagraph>
Before you can enable the toggle in the environment, you need to
add an activation strategy.
</StyledParagraph>
<StyledParagraph>
You can add the activation strategy by selecting the toggle,
open the environment accordion and add the activation strategy.
</StyledParagraph>
</Dialogue>
);
};
export default EnvironmentStrategyDialog;