mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-03 01:18:43 +02:00
Disable default env in project view (#969)
* fix: Block user from turning on default env in project view * fix: Allow changing environment state for default in a project if using non OSS Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
This commit is contained in:
parent
d1e7a26763
commit
3f766995fb
@ -22,6 +22,7 @@ import { IProjectEnvironment } from 'interfaces/environments';
|
|||||||
import { getEnabledEnvs } from './helpers';
|
import { getEnabledEnvs } from './helpers';
|
||||||
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
||||||
import { useThemeStyles } from 'themes/themeStyles';
|
import { useThemeStyles } from 'themes/themeStyles';
|
||||||
|
import { isDescendantOrSelf } from '@testing-library/user-event/dist/types/utils';
|
||||||
|
|
||||||
interface IProjectEnvironmentListProps {
|
interface IProjectEnvironmentListProps {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
@ -46,6 +47,7 @@ const ProjectEnvironmentList = ({
|
|||||||
const [confirmName, setConfirmName] = useState('');
|
const [confirmName, setConfirmName] = useState('');
|
||||||
const ref = useLoading(loading);
|
const ref = useLoading(loading);
|
||||||
const { classes: styles } = useStyles();
|
const { classes: styles } = useStyles();
|
||||||
|
const { isOss } = useUiConfig();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const envs = environments.map(e => ({
|
const envs = environments.map(e => ({
|
||||||
@ -146,6 +148,10 @@ const ProjectEnvironmentList = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const envIsDisabled = (projectName: string) => {
|
||||||
|
return isOss() && projectName === 'default';
|
||||||
|
};
|
||||||
|
|
||||||
const renderEnvironments = () => {
|
const renderEnvironments = () => {
|
||||||
return (
|
return (
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
@ -159,6 +165,7 @@ const ProjectEnvironmentList = ({
|
|||||||
env.enabled ? 'Disable' : 'Enable'
|
env.enabled ? 'Disable' : 'Enable'
|
||||||
} environment`}
|
} environment`}
|
||||||
size="medium"
|
size="medium"
|
||||||
|
disabled={envIsDisabled(env.name)}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
permission={UPDATE_PROJECT}
|
permission={UPDATE_PROJECT}
|
||||||
checked={env.enabled}
|
checked={env.enabled}
|
||||||
|
Loading…
Reference in New Issue
Block a user