1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-14 00:19:16 +01:00

conditional message for change request strategy form (#2465)

This commit is contained in:
Mateusz Kwasniewski 2022-11-17 15:40:45 +01:00 committed by GitHub
parent 42eadef8da
commit c9c5cf5364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import React from 'react'; import React, { FC } from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { Alert } from '@mui/material'; import { Alert } from '@mui/material';
@ -12,11 +12,12 @@ interface IFeatureStrategyEnabledProps {
environmentId: string; environmentId: string;
} }
export const FeatureStrategyEnabled = ({ export const FeatureStrategyEnabled: FC<IFeatureStrategyEnabledProps> = ({
projectId, projectId,
featureId, featureId,
environmentId, environmentId,
}: IFeatureStrategyEnabledProps) => { children,
}) => {
const featurePagePath = formatFeaturePath(projectId, featureId); const featurePagePath = formatFeaturePath(projectId, featureId);
const { feature } = useFeature(projectId, featureId); const { feature } = useFeature(projectId, featureId);
@ -29,14 +30,7 @@ export const FeatureStrategyEnabled = ({
return ( return (
<ConditionallyRender <ConditionallyRender
condition={isFeatureEnabledInEnvironment(feature, environmentId)} condition={isFeatureEnabledInEnvironment(feature, environmentId)}
show={ show={children}
<Alert severity="success">
This feature toggle is currently enabled in the{' '}
<strong>{environmentId}</strong> environment. Any changes
made here will be available to users as soon as you hit{' '}
<strong>save</strong>.
</Alert>
}
elseShow={ elseShow={
<Alert severity="warning"> <Alert severity="warning">
This feature toggle is currently disabled in the{' '} This feature toggle is currently disabled in the{' '}

View File

@ -1,6 +1,6 @@
import React, { useState, useContext } from 'react'; import React, { useState, useContext } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { Button } from '@mui/material'; import { Alert, Button } from '@mui/material';
import { import {
IFeatureStrategy, IFeatureStrategy,
IFeatureStrategyParameters, IFeatureStrategyParameters,
@ -141,7 +141,27 @@ export const FeatureStrategyForm = ({
projectId={feature.project} projectId={feature.project}
featureId={feature.name} featureId={feature.name}
environmentId={environmentId} environmentId={environmentId}
>
<ConditionallyRender
condition={Boolean(isChangeRequest)}
show={
<Alert severity="success">
This feature toggle is currently enabled in the{' '}
<strong>{environmentId}</strong> environment. Any
changes made here will be available to users as soon
as these changes are approved and applied.
</Alert>
}
elseShow={
<Alert severity="success">
This feature toggle is currently enabled in the{' '}
<strong>{environmentId}</strong> environment. Any
changes made here will be available to users as soon
as you hit <strong>save</strong>.
</Alert>
}
/> />
</FeatureStrategyEnabled>
<hr className={styles.hr} /> <hr className={styles.hr} />
<ConditionallyRender <ConditionallyRender
condition={Boolean(uiConfig.flags.SE)} condition={Boolean(uiConfig.flags.SE)}