mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-04 01:18:20 +02:00
In doing so, we extract the shared conflict marker component from the feature change and reuse it for both feature and segment changes. Here's what it looks like:  Update: also straightened out the borders of the conflict warning: 
This commit is contained in:
parent
17798408a4
commit
e7ae1ff714
@ -0,0 +1,25 @@
|
|||||||
|
import { Alert } from '@mui/material';
|
||||||
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
|
|
||||||
|
export const ConflictWarning: React.FC<{
|
||||||
|
conflict: string | null | undefined;
|
||||||
|
}> = ({ conflict }) => (
|
||||||
|
<ConditionallyRender
|
||||||
|
condition={Boolean(conflict)}
|
||||||
|
show={
|
||||||
|
<Alert
|
||||||
|
severity="warning"
|
||||||
|
sx={{
|
||||||
|
px: 3,
|
||||||
|
mb: 2,
|
||||||
|
'&.MuiAlert-standardWarning': {
|
||||||
|
borderStyle: 'none',
|
||||||
|
},
|
||||||
|
borderRadius: '0px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<strong>Conflict!</strong> {conflict}.
|
||||||
|
</Alert>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
@ -3,6 +3,7 @@ import { Link as RouterLink } from 'react-router-dom';
|
|||||||
import { Box, Card, Typography, Link } from '@mui/material';
|
import { Box, Card, Typography, Link } from '@mui/material';
|
||||||
import { ISegmentChange } from '../../../changeRequest.types';
|
import { ISegmentChange } from '../../../changeRequest.types';
|
||||||
import { SegmentChangeDetails } from './SegmentChangeDetails';
|
import { SegmentChangeDetails } from './SegmentChangeDetails';
|
||||||
|
import { ConflictWarning } from './ConflictWarning';
|
||||||
|
|
||||||
interface ISegmentChangeProps {
|
interface ISegmentChangeProps {
|
||||||
segmentChange: ISegmentChange;
|
segmentChange: ISegmentChange;
|
||||||
@ -27,11 +28,15 @@ export const SegmentChange: FC<ISegmentChangeProps> = ({
|
|||||||
borderRadius: theme =>
|
borderRadius: theme =>
|
||||||
`${theme.shape.borderRadiusLarge}px ${theme.shape.borderRadiusLarge}px 0 0`,
|
`${theme.shape.borderRadiusLarge}px ${theme.shape.borderRadiusLarge}px 0 0`,
|
||||||
border: '1px solid',
|
border: '1px solid',
|
||||||
borderColor: theme => theme.palette.divider,
|
borderColor: theme =>
|
||||||
|
segmentChange.conflict
|
||||||
|
? theme.palette.warning.border
|
||||||
|
: theme.palette.divider,
|
||||||
borderBottom: 'none',
|
borderBottom: 'none',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
<ConflictWarning conflict={segmentChange.conflict} />
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
@ -30,12 +30,16 @@ const ChangeItemInfo: FC = styled(Box)(({ theme }) => ({
|
|||||||
gap: theme.spacing(1),
|
gap: theme.spacing(1),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const SegmentContainer = styled(Box)(({ theme }) => ({
|
const SegmentContainer = styled(Box, {
|
||||||
|
shouldForwardProp: prop => prop !== 'conflict',
|
||||||
|
})<{ conflict: string | undefined }>(({ theme, conflict }) => ({
|
||||||
borderLeft: '1px solid',
|
borderLeft: '1px solid',
|
||||||
borderRight: '1px solid',
|
borderRight: '1px solid',
|
||||||
borderTop: '1px solid',
|
borderTop: '1px solid',
|
||||||
borderBottom: '1px solid',
|
borderBottom: '1px solid',
|
||||||
borderColor: theme.palette.divider,
|
borderColor: conflict
|
||||||
|
? theme.palette.warning.border
|
||||||
|
: theme.palette.divider,
|
||||||
borderTopColor: theme.palette.divider,
|
borderTopColor: theme.palette.divider,
|
||||||
padding: theme.spacing(3),
|
padding: theme.spacing(3),
|
||||||
borderRadius: `0 0 ${theme.shape.borderRadiusLarge}px ${theme.shape.borderRadiusLarge}px`,
|
borderRadius: `0 0 ${theme.shape.borderRadiusLarge}px ${theme.shape.borderRadiusLarge}px`,
|
||||||
@ -48,7 +52,7 @@ export const SegmentChangeDetails: VFC<{
|
|||||||
const { segment: currentSegment } = useSegment(change.payload.id);
|
const { segment: currentSegment } = useSegment(change.payload.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SegmentContainer>
|
<SegmentContainer conflict={change.conflict}>
|
||||||
{change.action === 'deleteSegment' && (
|
{change.action === 'deleteSegment' && (
|
||||||
<ChangeItemWrapper>
|
<ChangeItemWrapper>
|
||||||
<ChangeItemInfo>
|
<ChangeItemInfo>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { Link as RouterLink } from 'react-router-dom';
|
import { Link as RouterLink } from 'react-router-dom';
|
||||||
import { Alert, Box, Card, Typography, Link } from '@mui/material';
|
import { Box, Card, Typography, Link } from '@mui/material';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConflictWarning } from './Change/ConflictWarning';
|
||||||
|
|
||||||
interface IFeatureToggleChanges {
|
interface IFeatureToggleChanges {
|
||||||
featureName: string;
|
featureName: string;
|
||||||
@ -40,23 +40,7 @@ export const FeatureToggleChanges: FC<IFeatureToggleChanges> = ({
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<ConditionallyRender
|
<ConflictWarning conflict={conflict} />
|
||||||
condition={Boolean(conflict)}
|
|
||||||
show={
|
|
||||||
<Alert
|
|
||||||
severity="warning"
|
|
||||||
sx={{
|
|
||||||
px: 3,
|
|
||||||
mb: 2,
|
|
||||||
'&.MuiAlert-standardWarning': {
|
|
||||||
borderStyle: 'none',
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<strong>Conflict!</strong> {conflict}.
|
|
||||||
</Alert>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
@ -111,6 +111,7 @@ export interface IChangeRequestReorderStrategy
|
|||||||
|
|
||||||
export interface IChangeRequestUpdateSegment {
|
export interface IChangeRequestUpdateSegment {
|
||||||
action: 'updateSegment';
|
action: 'updateSegment';
|
||||||
|
conflict?: string;
|
||||||
payload: {
|
payload: {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
@ -122,6 +123,7 @@ export interface IChangeRequestUpdateSegment {
|
|||||||
|
|
||||||
export interface IChangeRequestDeleteSegment {
|
export interface IChangeRequestDeleteSegment {
|
||||||
action: 'deleteSegment';
|
action: 'deleteSegment';
|
||||||
|
conflict?: string;
|
||||||
payload: {
|
payload: {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user