mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: add dont show again when update prod env (#588)
* feat: add dont show again when update prod env * fix: remove unused dependency * fix: update key Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
This commit is contained in:
parent
b209368c84
commit
624f1a84d2
@ -9,7 +9,9 @@ import FeatureStrategyAccordion from '../../FeatureStrategyAccordion/FeatureStra
|
|||||||
import useFeatureStrategyApi from '../../../../../../hooks/api/actions/useFeatureStrategyApi/useFeatureStrategyApi';
|
import useFeatureStrategyApi from '../../../../../../hooks/api/actions/useFeatureStrategyApi/useFeatureStrategyApi';
|
||||||
|
|
||||||
import { useStyles } from './FeatureStrategiesConfigure.styles';
|
import { useStyles } from './FeatureStrategiesConfigure.styles';
|
||||||
import FeatureStrategiesProductionGuard from '../FeatureStrategiesProductionGuard/FeatureStrategiesProductionGuard';
|
import FeatureStrategiesProductionGuard, {
|
||||||
|
FEATURE_STRATEGY_PRODUCTION_GUARD_SETTING,
|
||||||
|
} from '../FeatureStrategiesProductionGuard/FeatureStrategiesProductionGuard';
|
||||||
import { IFeatureViewParams } from '../../../../../../interfaces/params';
|
import { IFeatureViewParams } from '../../../../../../interfaces/params';
|
||||||
import cloneDeep from 'lodash.clonedeep';
|
import cloneDeep from 'lodash.clonedeep';
|
||||||
import { PRODUCTION } from '../../../../../../constants/environmentTypes';
|
import { PRODUCTION } from '../../../../../../constants/environmentTypes';
|
||||||
@ -26,7 +28,10 @@ const FeatureStrategiesConfigure = () => {
|
|||||||
const { refetch } = useFeature(projectId, featureId);
|
const { refetch } = useFeature(projectId, featureId);
|
||||||
|
|
||||||
const [productionGuard, setProductionGuard] = useState(false);
|
const [productionGuard, setProductionGuard] = useState(false);
|
||||||
|
const dontShow = JSON.parse(
|
||||||
|
localStorage.getItem(FEATURE_STRATEGY_PRODUCTION_GUARD_SETTING) ||
|
||||||
|
'false'
|
||||||
|
);
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
const {
|
const {
|
||||||
activeEnvironment,
|
activeEnvironment,
|
||||||
@ -51,7 +56,7 @@ const FeatureStrategiesConfigure = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const resolveSubmit = () => {
|
const resolveSubmit = () => {
|
||||||
if (activeEnvironment.type === PRODUCTION) {
|
if (activeEnvironment.type === PRODUCTION && !dontShow) {
|
||||||
setProductionGuard(true);
|
setProductionGuard(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import { getStrategyObject } from '../../../../../../utils/get-strategy-object';
|
|||||||
|
|
||||||
import { useStyles } from './FeatureStrategiesEnvironmentList.styles';
|
import { useStyles } from './FeatureStrategiesEnvironmentList.styles';
|
||||||
import FeatureOverviewEnvSwitch from '../../../FeatureOverview/FeatureOverviewEnvSwitches/FeatureOverviewEnvSwitch/FeatureOverviewEnvSwitch';
|
import FeatureOverviewEnvSwitch from '../../../FeatureOverview/FeatureOverviewEnvSwitches/FeatureOverviewEnvSwitch/FeatureOverviewEnvSwitch';
|
||||||
|
import { FEATURE_STRATEGY_PRODUCTION_GUARD_SETTING } from '../FeatureStrategiesProductionGuard/FeatureStrategiesProductionGuard';
|
||||||
|
|
||||||
interface IFeatureStrategiesEnvironmentListProps {
|
interface IFeatureStrategiesEnvironmentListProps {
|
||||||
strategies: IFeatureStrategy[];
|
strategies: IFeatureStrategy[];
|
||||||
@ -31,6 +32,10 @@ const FeatureStrategiesEnvironmentList = ({
|
|||||||
}: IFeatureStrategiesEnvironmentListProps) => {
|
}: IFeatureStrategiesEnvironmentListProps) => {
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
const { strategies: selectableStrategies } = useStrategies();
|
const { strategies: selectableStrategies } = useStrategies();
|
||||||
|
const dontShow = JSON.parse(
|
||||||
|
localStorage.getItem(FEATURE_STRATEGY_PRODUCTION_GUARD_SETTING) ||
|
||||||
|
'false'
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
activeEnvironmentsRef,
|
activeEnvironmentsRef,
|
||||||
@ -94,7 +99,7 @@ const FeatureStrategiesEnvironmentList = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const resolveUpdateStrategy = (strategy: IFeatureStrategy, callback) => {
|
const resolveUpdateStrategy = (strategy: IFeatureStrategy, callback) => {
|
||||||
if (activeEnvironmentsRef?.current?.type === PRODUCTION) {
|
if (activeEnvironmentsRef?.current?.type === PRODUCTION && !dontShow) {
|
||||||
setProductionGuard({ show: true, strategy, callback });
|
setProductionGuard({ show: true, strategy, callback });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
|
import { Checkbox, FormControlLabel } from '@material-ui/core';
|
||||||
import { Alert } from '@material-ui/lab';
|
import { Alert } from '@material-ui/lab';
|
||||||
|
import { useState } from 'react';
|
||||||
import Dialogue from '../../../../../common/Dialogue';
|
import Dialogue from '../../../../../common/Dialogue';
|
||||||
|
|
||||||
|
export const FEATURE_STRATEGY_PRODUCTION_GUARD_SETTING =
|
||||||
|
'FEATURE_STRATEGY_PRODUCTION_GUARD_SETTING';
|
||||||
|
|
||||||
interface IFeatureStrategiesProductionGuard {
|
interface IFeatureStrategiesProductionGuard {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
@ -16,6 +21,19 @@ const FeatureStrategiesProductionGuard = ({
|
|||||||
primaryButtonText,
|
primaryButtonText,
|
||||||
loading,
|
loading,
|
||||||
}: IFeatureStrategiesProductionGuard) => {
|
}: IFeatureStrategiesProductionGuard) => {
|
||||||
|
const [checked, setIsChecked] = useState(
|
||||||
|
JSON.parse(
|
||||||
|
localStorage.getItem(FEATURE_STRATEGY_PRODUCTION_GUARD_SETTING) ||
|
||||||
|
'false'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const handleOnchange = () => {
|
||||||
|
setIsChecked(!checked);
|
||||||
|
localStorage.setItem(
|
||||||
|
FEATURE_STRATEGY_PRODUCTION_GUARD_SETTING,
|
||||||
|
(!checked).toString()
|
||||||
|
);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<Dialogue
|
<Dialogue
|
||||||
title="Changing production environment!"
|
title="Changing production environment!"
|
||||||
@ -30,10 +48,15 @@ const FeatureStrategiesProductionGuard = ({
|
|||||||
WARNING. You are about to make changes to a production
|
WARNING. You are about to make changes to a production
|
||||||
environment. These changes will affect your customers.
|
environment. These changes will affect your customers.
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|
||||||
<p style={{ marginTop: '1rem' }}>
|
<p style={{ marginTop: '1rem' }}>
|
||||||
Are you sure you want to proceed?
|
Are you sure you want to proceed?
|
||||||
</p>
|
</p>
|
||||||
|
<FormControlLabel
|
||||||
|
label="Don't show again"
|
||||||
|
control={
|
||||||
|
<Checkbox checked={checked} onChange={handleOnchange} />
|
||||||
|
}
|
||||||
|
/>
|
||||||
</Dialogue>
|
</Dialogue>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user