Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate long connection type description #3159

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion frontend/src/components/table/TableRowTitleDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import { K8sResourceCommon } from '@openshift/dynamic-plugin-sdk-utils';
import MarkdownView from '~/components/MarkdownView';
import ResourceNameTooltip from '~/components/ResourceNameTooltip';
import TruncatedText from '~/components/TruncatedText';

type TableRowTitleDescriptionProps = {
title: React.ReactNode;
resource?: K8sResourceCommon;
subtitle?: React.ReactNode;
description?: string;
descriptionAsMarkdown?: boolean;
truncateDescriptionLines?: number;
label?: React.ReactNode;
};

Expand All @@ -19,6 +21,7 @@
resource,
subtitle,
descriptionAsMarkdown,
truncateDescriptionLines,
label,
}) => {
let descriptionNode: React.ReactNode;
Expand All @@ -30,7 +33,11 @@
data-testid="table-row-title-description"
style={{ color: 'var(--pf-v5-global--Color--200)' }}
>
{description}
{truncateDescriptionLines !== undefined ? (
<TruncatedText maxLines={truncateDescriptionLines} content={description} />
) : (
description

Check warning on line 39 in frontend/src/components/table/TableRowTitleDescription.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/components/table/TableRowTitleDescription.tsx#L39

Added line #L39 was not covered by tests
)}
</Text>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/>
<HelperText>
{connectionTypeDescription ? (
<HelperTextItem>
<HelperTextItem style={{ overflowWrap: 'anywhere' }}>

Check warning on line 49 in frontend/src/concepts/connectionTypes/ConnectionTypePreview.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/connectionTypes/ConnectionTypePreview.tsx#L49

Added line #L49 was not covered by tests
<TruncatedText maxLines={2} content={connectionTypeDescription} />
</HelperTextItem>
) : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const ConnectionTypesTable: React.FC<Props> = ({ connectionTypes, onUpdate }) =>
<Table
isStriped
variant="compact"
style={{ tableLayout: 'fixed' }}
data={filteredConnectionTypes}
columns={connectionTypeColumns}
defaultSortColumn={0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ const ConnectionTypesTableRow: React.FC<ConnectionTypesTableRowProps> = ({

return (
<Tr>
<Td dataLabel={connectionTypeColumns[0].label} width={30}>
<Td dataLabel={connectionTypeColumns[0].label}>
<TableRowTitleDescription
title={getDisplayNameFromK8sResource(obj)}
description={getDescriptionFromK8sResource(obj)}
truncateDescriptionLines={2}
/>
</Td>
<Td dataLabel={connectionTypeColumns[1].label}>
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/pages/connectionTypes/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,25 @@ export const connectionTypeColumns: SortableData<ConnectionTypeConfigMapObj>[] =
label: 'Name',
field: 'name',
sortable: sorter,
width: 30,
},
{
label: 'Category',
field: 'category',
sortable: false,
width: 25,
},
{
label: 'Creator',
field: 'creator',
sortable: sorter,
width: 15,
},
{
label: 'Created',
field: 'created',
sortable: sorter,
width: 15,
},
{
label: 'Enable',
Expand All @@ -74,5 +78,6 @@ export const connectionTypeColumns: SortableData<ConnectionTypeConfigMapObj>[] =
headerContent: 'Enable',
},
},
width: 10,
},
];
Loading