mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-13 13:48:59 +02:00
deprecate tooltip link, move pieces into separate files
This commit is contained in:
parent
6503deea9b
commit
362956f46f
@ -0,0 +1,14 @@
|
|||||||
|
import { styled, Typography } from '@mui/material';
|
||||||
|
|
||||||
|
export const Deleted = styled(Typography)(({ theme }) => ({
|
||||||
|
color: theme.palette.error.main,
|
||||||
|
'::before': { content: '"- "' },
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const Added = styled(Typography)(({ theme }) => ({
|
||||||
|
'::before': { content: '"+ "' },
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const Added = styled(Typography)(({ theme }) => ({
|
||||||
|
'::before': { content: '"+ "' },
|
||||||
|
}));
|
@ -40,12 +40,12 @@ const ChangeItemCreateEditDeleteWrapper = styled(Box)(({ theme }) => ({
|
|||||||
|
|
||||||
const ChangeItemInfo: FC<{ children?: React.ReactNode }> = styled(Box)(
|
const ChangeItemInfo: FC<{ children?: React.ReactNode }> = styled(Box)(
|
||||||
({ theme }) => ({
|
({ theme }) => ({
|
||||||
display: 'grid',
|
display: 'flex',
|
||||||
gridTemplateColumns: '150px auto',
|
flexFlow: 'row',
|
||||||
gridAutoFlow: 'column',
|
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
flexGrow: 1,
|
flex: 'auto',
|
||||||
gap: theme.spacing(1),
|
gap: theme.spacing(1),
|
||||||
|
'::before': { content: '"Change: "', fontWeight: 'bold' },
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -102,16 +102,16 @@ const EditHeader: FC<{
|
|||||||
}> = ({ wasDisabled = false, willBeDisabled = false }) => {
|
}> = ({ wasDisabled = false, willBeDisabled = false }) => {
|
||||||
if (wasDisabled && willBeDisabled) {
|
if (wasDisabled && willBeDisabled) {
|
||||||
return (
|
return (
|
||||||
<Typography color='action.disabled'>Editing strategy:</Typography>
|
<Typography color='action.disabled'>Editing strategy</Typography>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wasDisabled && willBeDisabled) {
|
if (!wasDisabled && willBeDisabled) {
|
||||||
return <Typography color='error.dark'>Editing strategy:</Typography>;
|
return <Typography color='error.dark'>Editing strategy</Typography>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasDisabled && !willBeDisabled) {
|
if (wasDisabled && !willBeDisabled) {
|
||||||
return <Typography color='success.dark'>Editing strategy:</Typography>;
|
return <Typography color='success.dark'>Editing strategy</Typography>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Typography>Editing strategy:</Typography>;
|
return <Typography>Editing strategy:</Typography>;
|
||||||
@ -146,16 +146,12 @@ const DeleteStrategy: FC<{
|
|||||||
<Typography
|
<Typography
|
||||||
sx={(theme) => ({
|
sx={(theme) => ({
|
||||||
color: theme.palette.error.main,
|
color: theme.palette.error.main,
|
||||||
|
'::before': { content: '"- "' },
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
- Deleting strategy:
|
Deleting strategy
|
||||||
</Typography>
|
</Typography>
|
||||||
<StrategyTooltipLink name={name || ''} title={title}>
|
<StrategyTooltipLink name={name || ''} title={title} />
|
||||||
<StrategyDiff
|
|
||||||
change={change}
|
|
||||||
currentStrategy={referenceStrategy}
|
|
||||||
/>
|
|
||||||
</StrategyTooltipLink>
|
|
||||||
</ChangeItemInfo>
|
</ChangeItemInfo>
|
||||||
{actions}
|
{actions}
|
||||||
</ChangeItemCreateEditDeleteWrapper>
|
</ChangeItemCreateEditDeleteWrapper>
|
||||||
@ -213,12 +209,7 @@ const UpdateStrategy: FC<{
|
|||||||
name={change.payload.name}
|
name={change.payload.name}
|
||||||
title={change.payload.title}
|
title={change.payload.title}
|
||||||
previousTitle={previousTitle}
|
previousTitle={previousTitle}
|
||||||
>
|
|
||||||
<StrategyDiff
|
|
||||||
change={change}
|
|
||||||
currentStrategy={referenceStrategy}
|
|
||||||
/>
|
/>
|
||||||
</StrategyTooltipLink>
|
|
||||||
</ChangeItemInfo>
|
</ChangeItemInfo>
|
||||||
{actions}
|
{actions}
|
||||||
</ChangeItemCreateEditDeleteWrapper>
|
</ChangeItemCreateEditDeleteWrapper>
|
||||||
@ -289,15 +280,14 @@ const AddStrategy: FC<{
|
|||||||
? 'action.disabled'
|
? 'action.disabled'
|
||||||
: 'success.dark'
|
: 'success.dark'
|
||||||
}
|
}
|
||||||
|
sx={{ '::before': { content: '"+ "' } }}
|
||||||
>
|
>
|
||||||
+ Adding strategy:
|
Adding strategy
|
||||||
</Typography>
|
</Typography>
|
||||||
<StrategyTooltipLink
|
<StrategyTooltipLink
|
||||||
name={change.payload.name}
|
name={change.payload.name}
|
||||||
title={change.payload.title}
|
title={change.payload.title}
|
||||||
>
|
/>
|
||||||
<StrategyDiff change={change} currentStrategy={undefined} />
|
|
||||||
</StrategyTooltipLink>
|
|
||||||
<div>
|
<div>
|
||||||
<DisabledEnabledState
|
<DisabledEnabledState
|
||||||
disabled
|
disabled
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
import type {
|
||||||
|
IChangeRequestAddStrategy,
|
||||||
|
IChangeRequestDeleteStrategy,
|
||||||
|
IChangeRequestUpdateStrategy,
|
||||||
|
} from 'component/changeRequest/changeRequest.types';
|
||||||
|
import type { FC } from 'react';
|
||||||
|
import { EventDiff } from 'component/events/EventDiff/EventDiff';
|
||||||
|
import omit from 'lodash.omit';
|
||||||
|
import type { IFeatureStrategy } from 'interfaces/strategy';
|
||||||
|
|
||||||
|
const sortSegments = <T extends { segments?: number[] }>(
|
||||||
|
item?: T,
|
||||||
|
): T | undefined => {
|
||||||
|
if (!item || !item.segments) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
segments: [...item.segments].sort((a, b) => a - b),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const omitIfDefined = (obj: any, keys: string[]) =>
|
||||||
|
obj ? omit(obj, keys) : obj;
|
||||||
|
|
||||||
|
export const StrategyDiff: FC<{
|
||||||
|
change:
|
||||||
|
| IChangeRequestAddStrategy
|
||||||
|
| IChangeRequestUpdateStrategy
|
||||||
|
| IChangeRequestDeleteStrategy;
|
||||||
|
currentStrategy?: IFeatureStrategy;
|
||||||
|
}> = ({ change, currentStrategy }) => {
|
||||||
|
const changeRequestStrategy =
|
||||||
|
change.action === 'deleteStrategy' ? undefined : change.payload;
|
||||||
|
|
||||||
|
const sortedCurrentStrategy = sortSegments(currentStrategy);
|
||||||
|
const sortedChangeRequestStrategy = sortSegments(changeRequestStrategy);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<EventDiff
|
||||||
|
entry={{
|
||||||
|
preData: omitIfDefined(sortedCurrentStrategy, ['sortOrder']),
|
||||||
|
data: omitIfDefined(sortedChangeRequestStrategy, ['snapshot']),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
@ -0,0 +1,29 @@
|
|||||||
|
import type { FC } from 'react';
|
||||||
|
import { formatStrategyName } from 'utils/strategyNames';
|
||||||
|
import { Typography, styled } from '@mui/material';
|
||||||
|
import { textTruncated } from 'themes/themeStyles';
|
||||||
|
import { NameWithChangeInfo } from './NameWithChangeInfo/NameWithChangeInfo.tsx';
|
||||||
|
|
||||||
|
interface IStrategyTooltipLinkProps {
|
||||||
|
name: string;
|
||||||
|
title?: string;
|
||||||
|
previousTitle?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Truncated = styled('div')(() => ({
|
||||||
|
...textTruncated,
|
||||||
|
maxWidth: 500,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const StrategyTooltipLink: FC<IStrategyTooltipLinkProps> = ({
|
||||||
|
name,
|
||||||
|
title,
|
||||||
|
previousTitle,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<Truncated>
|
||||||
|
<Typography component='span'>{formatStrategyName(name)}</Typography>
|
||||||
|
<NameWithChangeInfo newName={title} previousName={previousTitle} />
|
||||||
|
</Truncated>
|
||||||
|
);
|
||||||
|
};
|
@ -9,7 +9,7 @@ import { TooltipLink } from 'component/common/TooltipLink/TooltipLink';
|
|||||||
import { styled } from '@mui/material';
|
import { styled } from '@mui/material';
|
||||||
import { textTruncated } from 'themes/themeStyles';
|
import { textTruncated } from 'themes/themeStyles';
|
||||||
import type { ISegment } from 'interfaces/segment';
|
import type { ISegment } from 'interfaces/segment';
|
||||||
import { NameWithChangeInfo } from './NameWithChangeInfo/NameWithChangeInfo.tsx';
|
import { NameWithChangeInfo } from './Changes/Change/NameWithChangeInfo/NameWithChangeInfo.tsx';
|
||||||
import { EventDiff } from 'component/events/EventDiff/EventDiff.tsx';
|
import { EventDiff } from 'component/events/EventDiff/EventDiff.tsx';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag.ts';
|
import { useUiFlag } from 'hooks/useUiFlag.ts';
|
||||||
|
|
||||||
|
@ -1,33 +1,17 @@
|
|||||||
|
// deprecated. Remove with flag crDiffView
|
||||||
import type {
|
import type {
|
||||||
IChangeRequestAddStrategy,
|
IChangeRequestAddStrategy,
|
||||||
IChangeRequestDeleteStrategy,
|
IChangeRequestDeleteStrategy,
|
||||||
IChangeRequestUpdateStrategy,
|
IChangeRequestUpdateStrategy,
|
||||||
} from 'component/changeRequest/changeRequest.types';
|
} from 'component/changeRequest/changeRequest.types';
|
||||||
import type React from 'react';
|
import type { FC } from 'react';
|
||||||
import { Fragment, type FC } from 'react';
|
import { formatStrategyName } from 'utils/strategyNames';
|
||||||
import {
|
|
||||||
formatStrategyName,
|
|
||||||
GetFeatureStrategyIcon,
|
|
||||||
} from 'utils/strategyNames';
|
|
||||||
import { EventDiff } from 'component/events/EventDiff/EventDiff';
|
import { EventDiff } from 'component/events/EventDiff/EventDiff';
|
||||||
import omit from 'lodash.omit';
|
import omit from 'lodash.omit';
|
||||||
import { TooltipLink } from 'component/common/TooltipLink/TooltipLink';
|
|
||||||
import { Typography, styled } from '@mui/material';
|
import { Typography, styled } from '@mui/material';
|
||||||
import type { IFeatureStrategy } from 'interfaces/strategy';
|
import type { IFeatureStrategy } from 'interfaces/strategy';
|
||||||
import { textTruncated } from 'themes/themeStyles';
|
import { textTruncated } from 'themes/themeStyles';
|
||||||
import { NameWithChangeInfo } from '../NameWithChangeInfo/NameWithChangeInfo.tsx';
|
import { NameWithChangeInfo } from '../Changes/Change/NameWithChangeInfo/NameWithChangeInfo.tsx';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag.ts';
|
|
||||||
|
|
||||||
const StyledCodeSection = styled('div')(({ theme }) => ({
|
|
||||||
overflowX: 'auto',
|
|
||||||
'& code': {
|
|
||||||
wordWrap: 'break-word',
|
|
||||||
whiteSpace: 'pre-wrap',
|
|
||||||
fontFamily: 'monospace',
|
|
||||||
lineHeight: 1.5,
|
|
||||||
fontSize: theme.fontSizes.smallBody,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const sortSegments = <T extends { segments?: number[] }>(
|
const sortSegments = <T extends { segments?: number[] }>(
|
||||||
item?: T,
|
item?: T,
|
||||||
@ -51,28 +35,19 @@ export const StrategyDiff: FC<{
|
|||||||
| IChangeRequestDeleteStrategy;
|
| IChangeRequestDeleteStrategy;
|
||||||
currentStrategy?: IFeatureStrategy;
|
currentStrategy?: IFeatureStrategy;
|
||||||
}> = ({ change, currentStrategy }) => {
|
}> = ({ change, currentStrategy }) => {
|
||||||
const useNewDiff = useUiFlag('improvedJsonDiff');
|
|
||||||
const changeRequestStrategy =
|
const changeRequestStrategy =
|
||||||
change.action === 'deleteStrategy' ? undefined : change.payload;
|
change.action === 'deleteStrategy' ? undefined : change.payload;
|
||||||
|
|
||||||
const sortedCurrentStrategy = sortSegments(currentStrategy);
|
const sortedCurrentStrategy = sortSegments(currentStrategy);
|
||||||
const sortedChangeRequestStrategy = sortSegments(changeRequestStrategy);
|
const sortedChangeRequestStrategy = sortSegments(changeRequestStrategy);
|
||||||
|
|
||||||
const Wrapper = useNewDiff ? Fragment : StyledCodeSection;
|
|
||||||
const omissionFunction = useNewDiff ? omitIfDefined : omit;
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
|
||||||
<EventDiff
|
<EventDiff
|
||||||
entry={{
|
entry={{
|
||||||
preData: omissionFunction(sortedCurrentStrategy, [
|
preData: omitIfDefined(sortedCurrentStrategy, ['sortOrder']),
|
||||||
'sortOrder',
|
data: omitIfDefined(sortedChangeRequestStrategy, ['snapshot']),
|
||||||
]),
|
|
||||||
data: omissionFunction(sortedChangeRequestStrategy, [
|
|
||||||
'snapshot',
|
|
||||||
]),
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Wrapper>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -80,24 +55,8 @@ interface IStrategyTooltipLinkProps {
|
|||||||
name: string;
|
name: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
previousTitle?: string;
|
previousTitle?: string;
|
||||||
children?: React.ReactNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const StyledContainer: FC<{ children?: React.ReactNode }> = styled('div')(
|
|
||||||
({ theme }) => ({
|
|
||||||
display: 'grid',
|
|
||||||
gridAutoFlow: 'column',
|
|
||||||
gridTemplateColumns: 'auto 1fr',
|
|
||||||
gap: theme.spacing(1),
|
|
||||||
alignItems: 'center',
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
const ViewDiff = styled('span')(({ theme }) => ({
|
|
||||||
color: theme.palette.primary.main,
|
|
||||||
marginLeft: theme.spacing(1),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const Truncated = styled('div')(() => ({
|
const Truncated = styled('div')(() => ({
|
||||||
...textTruncated,
|
...textTruncated,
|
||||||
maxWidth: 500,
|
maxWidth: 500,
|
||||||
@ -107,29 +66,11 @@ export const StrategyTooltipLink: FC<IStrategyTooltipLinkProps> = ({
|
|||||||
name,
|
name,
|
||||||
title,
|
title,
|
||||||
previousTitle,
|
previousTitle,
|
||||||
children,
|
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<StyledContainer>
|
|
||||||
<GetFeatureStrategyIcon strategyName={name} />
|
|
||||||
<Truncated>
|
<Truncated>
|
||||||
<Typography component='span'>
|
<Typography component='span'>{formatStrategyName(name)}</Typography>
|
||||||
{formatStrategyName(name)}
|
<NameWithChangeInfo newName={title} previousName={previousTitle} />
|
||||||
</Typography>
|
|
||||||
<TooltipLink
|
|
||||||
tooltip={children}
|
|
||||||
tooltipProps={{
|
|
||||||
maxWidth: 500,
|
|
||||||
maxHeight: 600,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ViewDiff>View Diff</ViewDiff>
|
|
||||||
</TooltipLink>
|
|
||||||
<NameWithChangeInfo
|
|
||||||
newName={title}
|
|
||||||
previousName={previousTitle}
|
|
||||||
/>
|
|
||||||
</Truncated>
|
</Truncated>
|
||||||
</StyledContainer>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user