mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
fix: improve UI, simplify code (#2505)
https://linear.app/unleash/issue/2-446/ui-simplify-design-with-some-improvements
This commit is contained in:
parent
543f07104c
commit
9bf3e09d5a
@ -1,13 +1,11 @@
|
|||||||
import { Add, CloudCircle } from '@mui/icons-material';
|
import { CloudCircle } from '@mui/icons-material';
|
||||||
import { Divider, styled } from '@mui/material';
|
import { styled } from '@mui/material';
|
||||||
import { IFeatureEnvironment, IFeatureVariant } from 'interfaces/featureToggle';
|
import { IFeatureEnvironment, IFeatureVariant } from 'interfaces/featureToggle';
|
||||||
import { EnvironmentVariantsTable } from './EnvironmentVariantsTable/EnvironmentVariantsTable';
|
import { EnvironmentVariantsTable } from './EnvironmentVariantsTable/EnvironmentVariantsTable';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import GeneralSelect from 'component/common/GeneralSelect/GeneralSelect';
|
import GeneralSelect from 'component/common/GeneralSelect/GeneralSelect';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext';
|
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext';
|
||||||
import PermissionButton from 'component/common/PermissionButton/PermissionButton';
|
|
||||||
import { UPDATE_FEATURE_ENVIRONMENT_VARIANTS } from 'component/providers/AccessProvider/permissions';
|
|
||||||
|
|
||||||
const StyledCard = styled('div')(({ theme }) => ({
|
const StyledCard = styled('div')(({ theme }) => ({
|
||||||
padding: theme.spacing(3),
|
padding: theme.spacing(3),
|
||||||
@ -45,10 +43,6 @@ const StyledName = styled('span', {
|
|||||||
marginLeft: theme.spacing(1.25),
|
marginLeft: theme.spacing(1.25),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const StyledDivider = styled(Divider)(({ theme }) => ({
|
|
||||||
margin: theme.spacing(3, 0),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const StyledDescription = styled('p')(({ theme }) => ({
|
const StyledDescription = styled('p')(({ theme }) => ({
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
color: theme.palette.text.secondary,
|
color: theme.palette.text.secondary,
|
||||||
@ -60,10 +54,8 @@ const StyledGeneralSelect = styled(GeneralSelect)(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
interface IEnvironmentVariantsCardProps {
|
interface IEnvironmentVariantsCardProps {
|
||||||
projectId: string;
|
|
||||||
environment: IFeatureEnvironment;
|
environment: IFeatureEnvironment;
|
||||||
searchValue: string;
|
searchValue: string;
|
||||||
onAddVariant: () => void;
|
|
||||||
onEditVariant: (variant: IFeatureVariant) => void;
|
onEditVariant: (variant: IFeatureVariant) => void;
|
||||||
onDeleteVariant: (variant: IFeatureVariant) => void;
|
onDeleteVariant: (variant: IFeatureVariant) => void;
|
||||||
onUpdateStickiness: (variant: IFeatureVariant[]) => void;
|
onUpdateStickiness: (variant: IFeatureVariant[]) => void;
|
||||||
@ -71,10 +63,8 @@ interface IEnvironmentVariantsCardProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const EnvironmentVariantsCard = ({
|
export const EnvironmentVariantsCard = ({
|
||||||
projectId,
|
|
||||||
environment,
|
environment,
|
||||||
searchValue,
|
searchValue,
|
||||||
onAddVariant,
|
|
||||||
onEditVariant,
|
onEditVariant,
|
||||||
onDeleteVariant,
|
onDeleteVariant,
|
||||||
onUpdateStickiness,
|
onUpdateStickiness,
|
||||||
@ -131,21 +121,10 @@ export const EnvironmentVariantsCard = ({
|
|||||||
onEditVariant={onEditVariant}
|
onEditVariant={onEditVariant}
|
||||||
onDeleteVariant={onDeleteVariant}
|
onDeleteVariant={onDeleteVariant}
|
||||||
/>
|
/>
|
||||||
<PermissionButton
|
|
||||||
permission={UPDATE_FEATURE_ENVIRONMENT_VARIANTS}
|
|
||||||
projectId={projectId}
|
|
||||||
environmentId={environment.name}
|
|
||||||
onClick={onAddVariant}
|
|
||||||
variant="text"
|
|
||||||
startIcon={<Add />}
|
|
||||||
>
|
|
||||||
add variant
|
|
||||||
</PermissionButton>
|
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={variants.length > 1}
|
condition={variants.length > 1}
|
||||||
show={
|
show={
|
||||||
<>
|
<>
|
||||||
<StyledDivider />
|
|
||||||
<p>Stickiness</p>
|
<p>Stickiness</p>
|
||||||
<StyledDescription>
|
<StyledDescription>
|
||||||
By overriding the stickiness you can
|
By overriding the stickiness you can
|
||||||
|
@ -34,9 +34,13 @@ export const EnvironmentVariantsCopyFrom = ({
|
|||||||
useState<null | HTMLElement>(null);
|
useState<null | HTMLElement>(null);
|
||||||
const copyFromOpen = Boolean(copyFromAnchorEl);
|
const copyFromOpen = Boolean(copyFromAnchorEl);
|
||||||
|
|
||||||
|
const variants = environment.variants ?? [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={otherEnvsWithVariants.length > 0}
|
condition={
|
||||||
|
otherEnvsWithVariants.length > 0 && variants.length === 0
|
||||||
|
}
|
||||||
show={
|
show={
|
||||||
<>
|
<>
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
|
@ -232,10 +232,8 @@ export const FeatureEnvironmentVariants = () => {
|
|||||||
return (
|
return (
|
||||||
<EnvironmentVariantsCard
|
<EnvironmentVariantsCard
|
||||||
key={environment.name}
|
key={environment.name}
|
||||||
projectId={projectId}
|
|
||||||
environment={environment}
|
environment={environment}
|
||||||
searchValue={searchValue}
|
searchValue={searchValue}
|
||||||
onAddVariant={() => addVariant(environment)}
|
|
||||||
onEditVariant={(variant: IFeatureVariant) =>
|
onEditVariant={(variant: IFeatureVariant) =>
|
||||||
editVariant(environment, variant)
|
editVariant(environment, variant)
|
||||||
}
|
}
|
||||||
@ -246,36 +244,25 @@ export const FeatureEnvironmentVariants = () => {
|
|||||||
onUpdateStickiness(environment, variants)
|
onUpdateStickiness(environment, variants)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ConditionallyRender
|
|
||||||
condition={environment.variants?.length === 0}
|
|
||||||
show={
|
|
||||||
<StyledButtonContainer>
|
<StyledButtonContainer>
|
||||||
|
<EnvironmentVariantsCopyFrom
|
||||||
|
environment={environment}
|
||||||
|
permission={UPDATE_FEATURE_ENVIRONMENT_VARIANTS}
|
||||||
|
projectId={projectId}
|
||||||
|
environmentId={environment.name}
|
||||||
|
onCopyVariantsFrom={onCopyVariantsFrom}
|
||||||
|
otherEnvsWithVariants={otherEnvsWithVariants}
|
||||||
|
/>
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
onClick={() => addVariant(environment)}
|
onClick={() => addVariant(environment)}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
permission={
|
permission={UPDATE_FEATURE_ENVIRONMENT_VARIANTS}
|
||||||
UPDATE_FEATURE_ENVIRONMENT_VARIANTS
|
|
||||||
}
|
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
environmentId={environment.name}
|
environmentId={environment.name}
|
||||||
>
|
>
|
||||||
Add variant
|
Add variant
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
<EnvironmentVariantsCopyFrom
|
|
||||||
environment={environment}
|
|
||||||
permission={
|
|
||||||
UPDATE_FEATURE_ENVIRONMENT_VARIANTS
|
|
||||||
}
|
|
||||||
projectId={projectId}
|
|
||||||
environmentId={environment.name}
|
|
||||||
onCopyVariantsFrom={onCopyVariantsFrom}
|
|
||||||
otherEnvsWithVariants={
|
|
||||||
otherEnvsWithVariants
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</StyledButtonContainer>
|
</StyledButtonContainer>
|
||||||
}
|
|
||||||
/>
|
|
||||||
</EnvironmentVariantsCard>
|
</EnvironmentVariantsCard>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
Loading…
Reference in New Issue
Block a user