1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-26 01:17:00 +02:00
unleash.unleash/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestFeatureToggleChange/ChangeRequestFeatureToggleChange.tsx
Tymoteusz Czech 8b057a1466
Show conflicts in change requests (#2389)
## About the changes
Show warnings about incompatible changes in changesets.

Closes
[1-352/display-conflicts](https://linear.app/unleash/issue/1-352/display-conflicts)

Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#2251
2022-11-15 09:53:38 +01:00

80 lines
2.6 KiB
TypeScript

import { FC } from 'react';
import { Link } from 'react-router-dom';
import { Alert, Box, Card, Typography } from '@mui/material';
import ToggleOnIcon from '@mui/icons-material/ToggleOn';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
interface IChangeRequestToggleChange {
featureName: string;
projectId: string;
conflict?: string;
onNavigate?: () => void;
}
export const ChangeRequestFeatureToggleChange: FC<
IChangeRequestToggleChange
> = ({ featureName, projectId, conflict, onNavigate, children }) => (
<Card
elevation={0}
sx={theme => ({
marginTop: theme.spacing(2),
overflow: 'hidden',
})}
>
<Box
sx={theme => ({
backgroundColor: Boolean(conflict)
? theme.palette.warning.light
: theme.palette.tableHeaderBackground,
borderRadius: theme =>
`${theme.shape.borderRadiusLarge}px ${theme.shape.borderRadiusLarge}px 0 0`,
border: '1px solid',
borderColor: theme =>
conflict
? theme.palette.warning.border
: theme.palette.dividerAlternative,
borderBottom: 'none',
overflow: 'hidden',
})}
>
<ConditionallyRender
condition={Boolean(conflict)}
show={
<Alert
severity="warning"
sx={{
mx: 1,
'&.MuiAlert-standardWarning': {
borderStyle: 'none',
},
}}
>
<strong>Conflict!</strong> {conflict}.
</Alert>
}
/>
<Box
sx={{
display: 'flex',
gap: 1,
pt: conflict ? 0 : 2,
pb: 2,
px: 3,
}}
>
<ToggleOnIcon color="disabled" />
<Typography
component={Link}
to={`/projects/${projectId}/features/${featureName}`}
color="primary"
sx={{ textDecoration: 'none' }}
onClick={onNavigate}
>
{featureName}
</Typography>
</Box>
</Box>
<Box>{children}</Box>
</Card>
);