mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
4167a60588
Follows up on https://github.com/Unleash/unleash/pull/4853 to add Biome to the frontend as well. ![image](https://github.com/Unleash/unleash/assets/14320932/1906faf1-fc29-4172-a4d4-b2716d72cd65) Added a few `biome-ignore` to speed up the process but we may want to check and fix them in the future.
99 lines
2.8 KiB
TypeScript
99 lines
2.8 KiB
TypeScript
import {
|
|
IChangeRequestAddStrategy,
|
|
IChangeRequestDeleteStrategy,
|
|
IChangeRequestUpdateStrategy,
|
|
} from 'component/changeRequest/changeRequest.types';
|
|
import { FC } from 'react';
|
|
import {
|
|
formatStrategyName,
|
|
GetFeatureStrategyIcon,
|
|
} from 'utils/strategyNames';
|
|
import EventDiff from 'component/events/EventDiff/EventDiff';
|
|
import omit from 'lodash.omit';
|
|
import { TooltipLink } from 'component/common/TooltipLink/TooltipLink';
|
|
import { Typography, styled } from '@mui/material';
|
|
import { IFeatureStrategy } from 'interfaces/strategy';
|
|
import { textTruncated } from 'themes/themeStyles';
|
|
import { NameWithChangeInfo } from '../NameWithChangeInfo/NameWithChangeInfo';
|
|
|
|
const StyledCodeSection = styled('div')(({ theme }) => ({
|
|
overflowX: 'auto',
|
|
'& code': {
|
|
wordWrap: 'break-word',
|
|
whiteSpace: 'pre-wrap',
|
|
fontFamily: 'monospace',
|
|
lineHeight: 1.5,
|
|
fontSize: theme.fontSizes.smallBody,
|
|
},
|
|
}));
|
|
|
|
export const StrategyDiff: FC<{
|
|
change:
|
|
| IChangeRequestAddStrategy
|
|
| IChangeRequestUpdateStrategy
|
|
| IChangeRequestDeleteStrategy;
|
|
currentStrategy?: IFeatureStrategy;
|
|
}> = ({ change, currentStrategy }) => {
|
|
const changeRequestStrategy =
|
|
change.action === 'deleteStrategy' ? undefined : change.payload;
|
|
|
|
return (
|
|
<StyledCodeSection>
|
|
<EventDiff
|
|
entry={{
|
|
preData: omit(currentStrategy, 'sortOrder'),
|
|
data: changeRequestStrategy,
|
|
}}
|
|
/>
|
|
</StyledCodeSection>
|
|
);
|
|
};
|
|
|
|
interface IStrategyTooltipLinkProps {
|
|
change:
|
|
| IChangeRequestAddStrategy
|
|
| IChangeRequestUpdateStrategy
|
|
| IChangeRequestDeleteStrategy;
|
|
previousTitle?: string;
|
|
}
|
|
|
|
const StyledContainer: FC = styled('div')(({ theme }) => ({
|
|
display: 'grid',
|
|
gridAutoFlow: 'column',
|
|
gridTemplateColumns: 'auto 1fr',
|
|
gap: theme.spacing(1),
|
|
alignItems: 'center',
|
|
}));
|
|
|
|
const Truncated = styled('div')(() => ({
|
|
...textTruncated,
|
|
maxWidth: 500,
|
|
}));
|
|
|
|
export const StrategyTooltipLink: FC<IStrategyTooltipLinkProps> = ({
|
|
change,
|
|
previousTitle,
|
|
children,
|
|
}) => (
|
|
<StyledContainer>
|
|
<GetFeatureStrategyIcon strategyName={change.payload.name} />
|
|
<Truncated>
|
|
<TooltipLink
|
|
tooltip={children}
|
|
tooltipProps={{
|
|
maxWidth: 500,
|
|
maxHeight: 600,
|
|
}}
|
|
>
|
|
<Typography component='span'>
|
|
{formatStrategyName(change.payload.name)}
|
|
</Typography>
|
|
</TooltipLink>
|
|
<NameWithChangeInfo
|
|
newName={change.payload.title}
|
|
previousName={previousTitle}
|
|
/>
|
|
</Truncated>
|
|
</StyledContainer>
|
|
);
|