1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00
unleash.unleash/frontend/src/component/environments/EnvironmentTable/EnvironmentNameCell/EnvironmentNameCell.tsx
Nuno Góis 4167a60588
feat: biome lint frontend (#4903)
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.
2023-10-02 13:25:46 +01:00

72 lines
2.6 KiB
TypeScript

import { TextCell } from 'component/common/Table/cells/TextCell/TextCell';
import { 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',
},
})}
>
<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>
}
/>
</TextCell>
);
};