1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-10 01:19:53 +01:00
unleash.unleash/frontend/src/component/environments/EnvironmentTable/EnvironmentNameCell/EnvironmentNameCell.tsx
Nuno Góis 63622618b4
fix: environment name cell (#10474)
https://linear.app/unleash/issue/2-3758/fix-environment-name-cell-after-the-latest-changes-to-textcell

Noticed the environment name cell acted differently after
[adjusting](https://github.com/Unleash/unleash/pull/10466/files#diff-485a5be6a3a5d639b56c3b29488125db051ce6b8a0e3561368d657d62dee4975R28)
the span inside TextCell to be `display: inline-flex`.

By wrapping the contents of our TextCell here into a single div we
explicitly declare this to be a single row of elements.
2025-08-07 11:32:06 +01:00

79 lines
2.9 KiB
TypeScript

import { TextCell } from 'component/common/Table/cells/TextCell/TextCell';
import type { IEnvironment } from 'interfaces/environments';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { Badge } from 'component/common/Badge/Badge';
import { Highlighter } from 'component/common/Highlighter/Highlighter';
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
import { styled, Typography } from '@mui/material';
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
const StyledTooltipTitle = styled(Typography)(({ theme }) => ({
fontWeight: 'bold',
fontSize: theme.fontSizes.smallerBody,
}));
const StyledTooltipDescription = styled(Typography)(({ theme }) => ({
fontSize: theme.fontSizes.smallerBody,
}));
const StyledBadge = styled(Badge)(({ theme }) => ({
marginLeft: theme.spacing(1),
}));
interface IEnvironmentNameCellProps {
environment: IEnvironment;
}
export const EnvironmentNameCell = ({
environment,
}: IEnvironmentNameCellProps) => {
const { searchQuery } = useSearchHighlightContext();
return (
<TextCell
sx={(theme) => ({
[theme.breakpoints.up('sm')]: {
minWidth: '350px',
},
})}
>
<div>
<Highlighter search={searchQuery}>
{environment.name}
</Highlighter>
<ConditionallyRender
condition={environment.protected}
show={<StyledBadge color='success'>Predefined</StyledBadge>}
/>
<ConditionallyRender
condition={!environment.enabled}
show={
<HtmlTooltip
maxWidth='270px'
title={
<>
<StyledTooltipTitle>
Deprecated environment
</StyledTooltipTitle>
<StyledTooltipDescription>
This environment is not auto-enabled for
new projects. The project owner will
need to manually enable it in the
project.
</StyledTooltipDescription>
</>
}
describeChild
arrow
>
<StyledBadge color='neutral'>
Deprecated
</StyledBadge>
</HtmlTooltip>
}
/>
</div>
</TextCell>
);
};