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