mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-29 01:15:48 +02:00
fix: small fixes on variants push to env UI (#2991)
https://linear.app/unleash/issue/2-652/slight-improvements-and-fixes-on-the-push-to-environment-feature Includes: - Hover effect on the items should cover the full width of the menu; - Clicking anywhere on the item should toggle the check; - Small refactoring 
This commit is contained in:
parent
436849edf3
commit
7d814a623f
@ -2,7 +2,6 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Divider,
|
Divider,
|
||||||
FormControlLabel,
|
|
||||||
Menu,
|
Menu,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
styled,
|
styled,
|
||||||
@ -17,15 +16,18 @@ const StyledMenu = styled(Menu)(({ theme }) => ({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
padding: theme.spacing(2),
|
|
||||||
'& > li': {
|
'& > li': {
|
||||||
padding: theme.spacing(0),
|
padding: theme.spacing(0, 1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const StyledActions = styled('div')(({ theme }) => ({
|
||||||
|
margin: theme.spacing(1, 2),
|
||||||
|
}));
|
||||||
|
|
||||||
const StyledButton = styled(Button)(({ theme }) => ({
|
const StyledButton = styled(Button)(({ theme }) => ({
|
||||||
marginTop: theme.spacing(1),
|
marginTop: theme.spacing(2),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
interface IPushVariantsButtonProps {
|
interface IPushVariantsButtonProps {
|
||||||
@ -77,6 +79,16 @@ export const PushVariantsButton = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleSelectedEnvironment = (
|
||||||
|
environment: IFeatureEnvironmentWithCrEnabled
|
||||||
|
) => {
|
||||||
|
if (selectedEnvironments.includes(environment)) {
|
||||||
|
removeSelectedEnvironment(environment);
|
||||||
|
} else {
|
||||||
|
addSelectedEnvironment(environment);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const cleanupState = () => {
|
const cleanupState = () => {
|
||||||
setSelectedEnvironments([]);
|
setSelectedEnvironments([]);
|
||||||
setPushToAnchorEl(null);
|
setPushToAnchorEl(null);
|
||||||
@ -115,36 +127,27 @@ export const PushVariantsButton = ({
|
|||||||
{environments
|
{environments
|
||||||
.filter(environment => environment.name !== current)
|
.filter(environment => environment.name !== current)
|
||||||
.map(otherEnvironment => (
|
.map(otherEnvironment => (
|
||||||
<MenuItem key={otherEnvironment.name}>
|
<MenuItem
|
||||||
<FormControlLabel
|
key={otherEnvironment.name}
|
||||||
disabled={
|
disabled={
|
||||||
!hasAccessTo[
|
!hasAccessTo[otherEnvironment.name] ??
|
||||||
otherEnvironment.name
|
false
|
||||||
] ?? false
|
|
||||||
}
|
}
|
||||||
control={
|
onClick={() =>
|
||||||
|
toggleSelectedEnvironment(
|
||||||
|
otherEnvironment
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
onChange={event => {
|
|
||||||
if (event.target.checked) {
|
|
||||||
addSelectedEnvironment(
|
|
||||||
otherEnvironment
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
removeSelectedEnvironment(
|
|
||||||
otherEnvironment
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
checked={selectedEnvironments.includes(
|
checked={selectedEnvironments.includes(
|
||||||
otherEnvironment
|
otherEnvironment
|
||||||
)}
|
)}
|
||||||
value={otherEnvironment.name}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label={otherEnvironment.name}
|
|
||||||
/>
|
/>
|
||||||
|
{otherEnvironment.name}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
|
<StyledActions>
|
||||||
<Divider />
|
<Divider />
|
||||||
<StyledButton
|
<StyledButton
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@ -156,6 +159,7 @@ export const PushVariantsButton = ({
|
|||||||
>
|
>
|
||||||
Push to selected ({selectedEnvironments.length})
|
Push to selected ({selectedEnvironments.length})
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
|
</StyledActions>
|
||||||
</StyledMenu>
|
</StyledMenu>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user