1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-13 11:17:26 +02:00
unleash.unleash/frontend/src/component/changeRequest/ProjectChangeRequests/ChangeRequestsTabs/FeaturesCell.tsx
Thomas Heartman 509dd80f86
chore: Update from "toggles" to "flags" (#10647)
Updates the features cell text when you have lots of flags affected.

Looks like we missed this one in a previous renaming attempt.

Before:
<img width="245" height="154" alt="image"
src="https://github.com/user-attachments/assets/922334f4-a0f1-4dee-9d14-3c9b3f77f32c"
/>

After:
<img width="275" height="170" alt="image"
src="https://github.com/user-attachments/assets/7fa0f454-e695-46aa-918b-c22b97e94187"
/>
2025-09-10 16:05:18 +02:00

94 lines
3.5 KiB
TypeScript

import { Box, styled } from '@mui/material';
import { Link } from 'react-router-dom';
import type { VFC } from 'react';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { TooltipLink } from 'component/common/TooltipLink/TooltipLink';
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
import { Highlighter } from 'component/common/Highlighter/Highlighter';
import { Truncator } from 'component/common/Truncator/Truncator';
const StyledBox = styled(Box)(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
width: '300px',
padding: theme.spacing(1, 0, 1, 2),
}));
const StyledLink = styled(Link)(() => ({
textDecoration: 'none',
'&:hover, &:focus': {
textDecoration: 'underline',
},
}));
const StyledTooltipLink = styled(Link)(({ theme }) => ({
textDecoration: 'none',
'&:hover, &:focus': {
textDecoration: 'underline',
},
}));
const StyledTooltipContainer = styled(Box)(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
fontSize: theme.fontSizes.smallBody,
width: '100%',
whiteSpace: 'nowrap',
}));
interface FeaturesCellProps {
value: any;
project: string;
}
export const FeaturesCell: VFC<FeaturesCellProps> = ({ value, project }) => {
const { searchQuery } = useSearchHighlightContext();
const featureNames = value?.map((feature: any) => feature.name);
return (
<StyledBox>
<ConditionallyRender
condition={featureNames?.length < 3}
show={featureNames?.map((featureName: string) => (
<StyledLink
key={featureName}
to={`/projects/${project}/features/${featureName}`}
>
<Truncator lines={1} title={featureName} arrow>
<Highlighter search={searchQuery}>
{featureName}
</Highlighter>
</Truncator>
</StyledLink>
))}
elseShow={
<TooltipLink
tooltipProps={{ maxWidth: '800px' }}
tooltip={
<StyledTooltipContainer>
{featureNames?.map((featureName: string) => (
<StyledTooltipLink
key={featureName}
to={`/projects/${project}/features/${featureName}`}
>
<Truncator
lines={1}
title={featureName}
arrow
>
<Highlighter search={searchQuery}>
{featureName}
</Highlighter>
</Truncator>
</StyledTooltipLink>
))}
</StyledTooltipContainer>
}
>
{featureNames?.length} flags
</TooltipLink>
}
/>
</StyledBox>
);
};