mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-27 11:02:16 +01:00
chore: never wrap other text fields in global change requests table
This commit is contained in:
parent
feed9ea3c9
commit
6becea2842
@ -1,5 +1,5 @@
|
||||
import type { FC } from 'react';
|
||||
import { Badge } from 'component/common/Badge/Badge';
|
||||
import { Badge as MuiBadge } from 'component/common/Badge/Badge';
|
||||
import AccessTime from '@mui/icons-material/AccessTime';
|
||||
import Check from '@mui/icons-material/Check';
|
||||
import CircleOutlined from '@mui/icons-material/CircleOutlined';
|
||||
@ -12,6 +12,11 @@ import type {
|
||||
ScheduledChangeRequest,
|
||||
UnscheduledChangeRequest,
|
||||
} from '../changeRequest.types';
|
||||
import { styled } from '@mui/material';
|
||||
|
||||
const Badge = styled(MuiBadge)({
|
||||
whiteSpace: 'nowrap',
|
||||
});
|
||||
|
||||
export interface IChangeRequestStatusBadgeProps {
|
||||
changeRequest:
|
||||
|
||||
@ -39,6 +39,10 @@ const columnHelper = createColumnHelper<ChangeRequestSearchItemSchema>();
|
||||
const StyledPaginatedTable = styled(
|
||||
PaginatedTable<ChangeRequestSearchItemSchema>,
|
||||
)(() => ({
|
||||
th: {
|
||||
whiteSpace: 'nowrap',
|
||||
},
|
||||
|
||||
td: {
|
||||
verticalAlign: 'top',
|
||||
},
|
||||
@ -98,17 +102,14 @@ const ChangeRequestsInner = () => {
|
||||
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
columnHelper.accessor('title', {
|
||||
{
|
||||
id: 'Title',
|
||||
header: 'Title',
|
||||
meta: { width: '300px' },
|
||||
cell: ({ getValue, row }) => (
|
||||
<GlobalChangeRequestTitleCell
|
||||
value={getValue()}
|
||||
row={row}
|
||||
/>
|
||||
cell: ({ row }) => (
|
||||
<GlobalChangeRequestTitleCell {...row.original} />
|
||||
),
|
||||
}),
|
||||
},
|
||||
columnHelper.accessor('features', {
|
||||
id: 'Updated feature flags',
|
||||
header: 'Updated feature flags',
|
||||
@ -149,7 +150,9 @@ const ChangeRequestsInner = () => {
|
||||
id: 'Environment',
|
||||
header: 'Environment',
|
||||
meta: { width: '100px' },
|
||||
cell: ({ getValue }) => <HighlightCell value={getValue()} />,
|
||||
cell: ({ getValue }) => (
|
||||
<HighlightCell maxTitleLines={1} value={getValue()} />
|
||||
),
|
||||
}),
|
||||
columnHelper.accessor('state', {
|
||||
id: 'Status',
|
||||
|
||||
@ -2,27 +2,27 @@ import { TextCell } from 'component/common/Table/cells/TextCell/TextCell';
|
||||
import { Link, styled, Typography } from '@mui/material';
|
||||
import { Link as RouterLink, type LinkProps } from 'react-router-dom';
|
||||
import { useProjectOverviewNameOrId } from 'hooks/api/getters/useProjectOverview/useProjectOverview';
|
||||
|
||||
type IGlobalChangeRequestTitleCellProps = {
|
||||
value?: any;
|
||||
row: { original: any };
|
||||
};
|
||||
import { Truncator } from 'component/common/Truncator/Truncator';
|
||||
import type { ChangeRequestSearchItemSchema } from 'openapi';
|
||||
|
||||
const LinkContainer = styled('div')(({ theme }) => ({
|
||||
color: theme.palette.text.secondary,
|
||||
display: 'flex',
|
||||
columnGap: theme.spacing(0.5),
|
||||
}));
|
||||
|
||||
const BaseLink = styled(({ children, ...props }: LinkProps) => (
|
||||
<Link component={RouterLink} {...props}>
|
||||
{children}
|
||||
</Link>
|
||||
))(({ theme }) => ({
|
||||
))({
|
||||
whiteSpace: 'nowrap',
|
||||
textDecoration: 'none',
|
||||
color: 'inherit',
|
||||
':hover': {
|
||||
textDecoration: 'underline',
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
const ChangeRequestLink = styled(BaseLink)(({ theme }) => ({
|
||||
color: theme.palette.primary.main,
|
||||
@ -35,32 +35,34 @@ const UpdateText = styled(Typography)(({ theme }) => ({
|
||||
}));
|
||||
|
||||
export const GlobalChangeRequestTitleCell = ({
|
||||
value,
|
||||
row: { original },
|
||||
}: IGlobalChangeRequestTitleCellProps) => {
|
||||
const {
|
||||
id,
|
||||
title,
|
||||
project,
|
||||
features: featureChanges,
|
||||
segments: segmentChanges,
|
||||
} = original;
|
||||
id,
|
||||
title,
|
||||
project,
|
||||
features: featureChanges,
|
||||
segments: segmentChanges,
|
||||
}: ChangeRequestSearchItemSchema) => {
|
||||
const projectName = useProjectOverviewNameOrId(project);
|
||||
const totalChanges =
|
||||
featureChanges?.length ?? 0 + segmentChanges?.length ?? 0;
|
||||
const projectPath = `/projects/${project}`;
|
||||
const crPath = `${projectPath}/change-requests/${id}`;
|
||||
|
||||
if (!value) {
|
||||
return <TextCell />;
|
||||
}
|
||||
|
||||
return (
|
||||
<TextCell sx={{ minWidth: '300px' }}>
|
||||
<LinkContainer>
|
||||
<BaseLink to={projectPath}>{projectName}</BaseLink>
|
||||
<span aria-hidden='true'> / </span>
|
||||
<ChangeRequestLink to={crPath}>{title}</ChangeRequestLink>
|
||||
<Truncator title={projectName}>
|
||||
<BaseLink to={projectPath}>{projectName}</BaseLink>
|
||||
</Truncator>
|
||||
<span aria-hidden='true'>/</span>
|
||||
{title ? (
|
||||
<Truncator title={title}>
|
||||
<ChangeRequestLink to={crPath}>
|
||||
{title}
|
||||
</ChangeRequestLink>
|
||||
</Truncator>
|
||||
) : (
|
||||
<ChangeRequestLink to={crPath}>#{id}</ChangeRequestLink>
|
||||
)}
|
||||
</LinkContainer>
|
||||
<UpdateText>
|
||||
{`${totalChanges}`} {totalChanges === 1 ? `update` : 'updates'}
|
||||
|
||||
@ -16,14 +16,13 @@ export const ChangeRequestStatusCell: FC<IChangeRequestStatusCellProps> = ({
|
||||
value,
|
||||
row: { original },
|
||||
}) => {
|
||||
const renderState = () => {
|
||||
if (!value) return null;
|
||||
return <ChangeRequestStatusBadge changeRequest={original} />;
|
||||
};
|
||||
|
||||
if (!value) {
|
||||
return <TextCell />;
|
||||
}
|
||||
|
||||
return <TextCell>{renderState()}</TextCell>;
|
||||
return (
|
||||
<TextCell>
|
||||
<ChangeRequestStatusBadge changeRequest={original} />
|
||||
</TextCell>
|
||||
);
|
||||
};
|
||||
|
||||
@ -12,6 +12,7 @@ interface IHighlightCellProps {
|
||||
subtitle?: string;
|
||||
afterTitle?: React.ReactNode;
|
||||
subtitleTooltip?: boolean;
|
||||
maxTitleLines?: number;
|
||||
}
|
||||
|
||||
const StyledContainer = styled(Box)(({ theme }) => ({
|
||||
@ -40,6 +41,7 @@ export const HighlightCell: FC<IHighlightCellProps> = ({
|
||||
subtitle,
|
||||
afterTitle,
|
||||
subtitleTooltip,
|
||||
maxTitleLines,
|
||||
}) => {
|
||||
const { searchQuery } = useSearchHighlightContext();
|
||||
|
||||
@ -68,7 +70,7 @@ export const HighlightCell: FC<IHighlightCellProps> = ({
|
||||
return (
|
||||
<StyledContainer>
|
||||
<Truncator
|
||||
lines={subtitle ? 1 : 2}
|
||||
lines={maxTitleLines ?? (subtitle ? 1 : 2)}
|
||||
title={value}
|
||||
arrow
|
||||
data-loading
|
||||
|
||||
Loading…
Reference in New Issue
Block a user