1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-21 13:47:39 +02:00

Allow hiding environments from the feature overview screen fix (#2831)

This commit is contained in:
sjaanus 2023-01-06 11:32:26 +02:00 committed by GitHub
parent 89c6c09db3
commit 2139d8342a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 13 deletions

View File

@ -56,7 +56,12 @@ const FeatureOverview = () => {
setHiddenEnvironments={setHiddenEnvironments} setHiddenEnvironments={setHiddenEnvironments}
/> />
} }
elseShow={<FeatureOverviewEnvSwitches />} elseShow={
<FeatureOverviewEnvSwitches
hiddenEnvironments={hiddenEnvironments}
setHiddenEnvironments={setHiddenEnvironments}
/>
}
/> />
</div> </div>
<StyledMainContent> <StyledMainContent>

View File

@ -11,17 +11,24 @@ import { formatUnknownError } from 'utils/formatUnknownError';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { useChangeRequestToggle } from 'hooks/useChangeRequestToggle'; import { useChangeRequestToggle } from 'hooks/useChangeRequestToggle';
import { ChangeRequestDialogue } from 'component/changeRequest/ChangeRequestConfirmDialog/ChangeRequestConfirmDialog'; import { ChangeRequestDialogue } from 'component/changeRequest/ChangeRequestConfirmDialog/ChangeRequestConfirmDialog';
import { UpdateEnabledMessage } from '../../../../../changeRequest/ChangeRequestConfirmDialog/ChangeRequestMessages/UpdateEnabledMessage'; import { UpdateEnabledMessage } from 'component/changeRequest/ChangeRequestConfirmDialog/ChangeRequestMessages/UpdateEnabledMessage';
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
import { styled } from '@mui/material'; import { styled } from '@mui/material';
import { FeatureOverviewSidePanelEnvironmentHider } from '../../FeatureOverviewSidePanel/FeatureOverviewSidePanelEnvironmentSwitches/FeatureOverviewSidePanelEnvironmentSwitch/FeatureOverviewSidePanelEnvironmentHider';
interface IFeatureOverviewEnvSwitchProps { interface IFeatureOverviewEnvSwitchProps {
env: IFeatureEnvironment; env: IFeatureEnvironment;
callback?: () => void; callback?: () => void;
text?: string; text?: string;
showInfoBox: () => void; showInfoBox: () => void;
hiddenEnvironments: Set<String>;
setHiddenEnvironments: (environment: string) => void;
} }
const StyledContainer = styled('div')(({ theme }) => ({
display: 'flex',
}));
const StyledLabel = styled('label')({ const StyledLabel = styled('label')({
display: 'inline-flex', display: 'inline-flex',
alignItems: 'center', alignItems: 'center',
@ -33,6 +40,8 @@ const FeatureOverviewEnvSwitch = ({
callback, callback,
text, text,
showInfoBox, showInfoBox,
hiddenEnvironments,
setHiddenEnvironments,
}: IFeatureOverviewEnvSwitchProps) => { }: IFeatureOverviewEnvSwitchProps) => {
const projectId = useRequiredPathParam('projectId'); const projectId = useRequiredPathParam('projectId');
const featureId = useRequiredPathParam('featureId'); const featureId = useRequiredPathParam('featureId');
@ -114,7 +123,7 @@ const FeatureOverviewEnvSwitch = ({
); );
return ( return (
<div> <StyledContainer>
<StyledLabel> <StyledLabel>
<PermissionSwitch <PermissionSwitch
permission={UPDATE_FEATURE_ENVIRONMENT} permission={UPDATE_FEATURE_ENVIRONMENT}
@ -125,6 +134,11 @@ const FeatureOverviewEnvSwitch = ({
/> />
{content} {content}
</StyledLabel> </StyledLabel>
<FeatureOverviewSidePanelEnvironmentHider
environment={env}
hiddenEnvironments={hiddenEnvironments}
setHiddenEnvironments={setHiddenEnvironments}
/>
<ChangeRequestDialogue <ChangeRequestDialogue
isOpen={changeRequestDialogDetails.isOpen} isOpen={changeRequestDialogDetails.isOpen}
onClose={onChangeRequestToggleClose} onClose={onChangeRequestToggleClose}
@ -138,7 +152,7 @@ const FeatureOverviewEnvSwitch = ({
/> />
} }
/> />
</div> </StyledContainer>
); );
}; };

View File

@ -6,6 +6,7 @@ import FeatureOverviewEnvSwitch from './FeatureOverviewEnvSwitch/FeatureOverview
import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { HelpIcon } from 'component/common/HelpIcon/HelpIcon'; import { HelpIcon } from 'component/common/HelpIcon/HelpIcon';
import { styled } from '@mui/material'; import { styled } from '@mui/material';
import { IFeatureToggle } from '../../../../../interfaces/featureToggle';
const StyledContainer = styled('div')(({ theme }) => ({ const StyledContainer = styled('div')(({ theme }) => ({
borderRadius: theme.shape.borderRadiusLarge, borderRadius: theme.shape.borderRadiusLarge,
@ -41,7 +42,15 @@ const StyledHeader = styled('h3')(({ theme }) => ({
}, },
})); }));
const FeatureOverviewEnvSwitches = () => { interface IFeatureOverviewEnvSwitchesProps {
hiddenEnvironments: Set<String>;
setHiddenEnvironments: (environment: string) => void;
}
const FeatureOverviewEnvSwitches = ({
hiddenEnvironments,
setHiddenEnvironments,
}: IFeatureOverviewEnvSwitchesProps) => {
const projectId = useRequiredPathParam('projectId'); const projectId = useRequiredPathParam('projectId');
const featureId = useRequiredPathParam('featureId'); const featureId = useRequiredPathParam('featureId');
const { feature } = useFeature(projectId, featureId); const { feature } = useFeature(projectId, featureId);
@ -60,6 +69,8 @@ const FeatureOverviewEnvSwitches = () => {
<FeatureOverviewEnvSwitch <FeatureOverviewEnvSwitch
key={env.name} key={env.name}
env={env} env={env}
hiddenEnvironments={hiddenEnvironments}
setHiddenEnvironments={setHiddenEnvironments}
showInfoBox={() => { showInfoBox={() => {
setEnvironmentName(env.name); setEnvironmentName(env.name);
setShowInfoBox(true); setShowInfoBox(true);

View File

@ -6,7 +6,8 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit
const Visible = styled(Visibility)(({ theme }) => ({ const Visible = styled(Visibility)(({ theme }) => ({
cursor: 'pointer', cursor: 'pointer',
marginLeft: 'auto', marginLeft: 'auto',
color: theme.palette.grey[700], marginTop: theme.spacing(0.5),
color: theme.palette.neutral.main,
'&:hover': { '&:hover': {
opacity: 1, opacity: 1,
}, },
@ -16,7 +17,7 @@ const Visible = styled(Visibility)(({ theme }) => ({
const VisibleOff = styled(VisibilityOff)(({ theme }) => ({ const VisibleOff = styled(VisibilityOff)(({ theme }) => ({
cursor: 'pointer', cursor: 'pointer',
marginLeft: 'auto', marginLeft: 'auto',
color: theme.palette.grey[700], color: theme.palette.neutral.main,
})); }));
interface IFeatureOverviewSidePanelEnvironmentHiderProps { interface IFeatureOverviewSidePanelEnvironmentHiderProps {

View File

@ -30,12 +30,6 @@ const StyledLabel = styled('label')(() => ({
cursor: 'pointer', cursor: 'pointer',
})); }));
const HideButton = styled(RemoveRedEye)(({ theme }) => ({
cursor: 'pointer',
marginLeft: 'auto',
color: theme.palette.grey[700],
}));
interface IFeatureOverviewSidePanelEnvironmentSwitchProps { interface IFeatureOverviewSidePanelEnvironmentSwitchProps {
environment: IFeatureEnvironment; environment: IFeatureEnvironment;
callback?: () => void; callback?: () => void;