1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00
unleash.unleash/frontend/src/component/common/EnvironmentStrategiesDialog/EnvironmentStrategyDialog.tsx
olav d8143c6ff4 chore: update react-router to v6 (#946)
* refactor: fix child selector warnings

* refactor: update react-router-dom

* refactor: use BrowserRouter as in react-router docs

* refactor: replace Redirect with Navigate

* refactor: replace Switch with Routes

* refactor: replace useHistory with useNavigate

* refactor: replace useParams types with useRequiredPathParam

* refactor: replace NavLink activeStyle with callback

* refactor: fix matchPath arg order

* refactor: Remove unused link state

* refactor: delete broken snapshot test

* refactor: render 404 page without redirect

* refactor: normalize path parameter names

* refactor: fix Route component usage
2022-05-05 13:42:18 +02:00

70 lines
2.2 KiB
TypeScript

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 { useStyles } from './EnvironmentStrategyDialog.styles';
import { formatCreateStrategyPath } from 'component/feature/FeatureStrategy/FeatureStrategyCreate/FeatureStrategyCreate';
interface IEnvironmentStrategyDialogProps {
open: boolean;
featureId: string;
projectId: string;
onClose: () => void;
environmentName: string;
}
const EnvironmentStrategyDialog = ({
open,
environmentName,
featureId,
projectId,
onClose,
}: IEnvironmentStrategyDialogProps) => {
const { classes: styles } = useStyles();
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"
>
<p className={styles.infoText}>
Before you can enable the toggle in the environment, you need to
add an activation strategy.
</p>
<p className={styles.infoText}>
You can add the activation strategy by selecting the toggle,
open the environment accordion and add the activation strategy.
</p>
</Dialogue>
);
};
export default EnvironmentStrategyDialog;