Skip to content

Commit

Permalink
[RHOAIENG-7481] Add metrics columns to pipeline run table and modal p…
Browse files Browse the repository at this point in the history
…aram selector
  • Loading branch information
jpuzz0 committed Jun 8, 2024
1 parent 34187a9 commit 1391bbd
Show file tree
Hide file tree
Showing 16 changed files with 723 additions and 64 deletions.
112 changes: 97 additions & 15 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@patternfly/react-charts": "^7.1.1",
"@patternfly/react-code-editor": "^5.2.1",
"@patternfly/react-core": "^5.2.1",
"@patternfly/react-drag-drop": "^5.3.3",
"@patternfly/react-icons": "^5.2.1",
"@patternfly/react-log-viewer": "^5.2.0",
"@patternfly/react-styles": "^5.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CompareRunParamsTable {
}

findEmptyState() {
return this.find().parent().findByTestId('compare-runs-params-empty-state');
return this.find().parent().parent().findByTestId('compare-runs-params-empty-state');
}

findColumnByName(name: string) {
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/table/CheckboxTd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ type CheckboxTrProps = {
onToggle: () => void;
isDisabled?: boolean;
tooltip?: string;
};
} & React.ComponentProps<typeof Td>;

const CheckboxTd: React.FC<CheckboxTrProps> = ({
id,
isChecked,
onToggle,
isDisabled,
tooltip,
...props
}) => {
let content = (
<Checkbox
Expand All @@ -31,7 +32,11 @@ const CheckboxTd: React.FC<CheckboxTrProps> = ({
content = <Tooltip content={tooltip}>{content}</Tooltip>;
}

return <Td dataLabel="Checkbox">{content}</Td>;
return (
<Td dataLabel="Checkbox" {...props}>
{content}
</Td>
);
};

export default CheckboxTd;
35 changes: 24 additions & 11 deletions frontend/src/components/table/TableBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Tbody,
Td,
TbodyProps,
InnerScrollContainer,
} from '@patternfly/react-table';
import { EitherNotBoth } from '~/typeHelpers';
import { GetColumnSort, SortableData } from './types';
Expand Down Expand Up @@ -47,6 +48,7 @@ type Props<DataType> = {
};
getColumnSort?: GetColumnSort;
disableItemCount?: boolean;
hasStickyColumns?: boolean;
} & EitherNotBoth<
{ disableRowRenderSupport?: boolean },
{ tbodyProps?: TbodyProps & { ref?: React.Ref<HTMLTableSectionElement> } }
Expand Down Expand Up @@ -109,6 +111,7 @@ const TableBase = <T,>({
loading,
toggleTemplate,
disableItemCount = false,
hasStickyColumns,
...props
}: Props<T>): React.ReactElement => {
const selectAllRef = React.useRef(null);
Expand Down Expand Up @@ -159,6 +162,8 @@ const TableBase = <T,>({
ref={selectAllRef}
colSpan={col.colSpan}
rowSpan={col.rowSpan}
isStickyColumn={col.isStickyColumn}
stickyMinWidth={col.stickyMinWidth}
select={{
isSelected: selectAll.selected,
onSelect: (e, value) => selectAll.onSelect(value),
Expand All @@ -182,6 +187,8 @@ const TableBase = <T,>({
info={col.info}
isSubheader={isSubheader}
isStickyColumn={col.isStickyColumn}
stickyMinWidth={col.stickyMinWidth}
stickyLeftOffset={col.stickyLeftOffset}
hasRightBorder={col.hasRightBorder}
modifier={col.modifier}
className={col.className}
Expand Down Expand Up @@ -246,6 +253,20 @@ const TableBase = <T,>({
})
: data.map((row, rowIndex) => rowRenderer(row, rowIndex));

const table = (
<Table {...props} {...(hasStickyColumns && { gridBreakPoint: '' })} ref={tableRef}>
{caption && <Caption>{caption}</Caption>}
<Thead noWrap hasNestedHeader={hasNestedHeader}>
<Tr>{columns.map((col, i) => renderColumnHeader(col, i))}</Tr>
{subColumns?.length ? (
<Tr>{subColumns.map((col, i) => renderColumnHeader(col, columns.length + i, true))}</Tr>
) : null}
</Thead>
{disableRowRenderSupport ? renderRows() : <Tbody {...tbodyProps}>{renderRows()}</Tbody>}
{footerRow && footerRow(page)}
</Table>
);

return (
<>
{(toolbarContent || showPagination) && (
Expand All @@ -268,17 +289,9 @@ const TableBase = <T,>({
</ToolbarContent>
</Toolbar>
)}
<Table {...props} ref={tableRef}>
{caption && <Caption>{caption}</Caption>}
<Thead noWrap hasNestedHeader={hasNestedHeader}>
<Tr>{columns.map((col, i) => renderColumnHeader(col, i))}</Tr>
{subColumns?.length ? (
<Tr>{subColumns.map((col, i) => renderColumnHeader(col, columns.length + i, true))}</Tr>
) : null}
</Thead>
{disableRowRenderSupport ? renderRows() : <Tbody {...tbodyProps}>{renderRows()}</Tbody>}
{footerRow && footerRow(page)}
</Table>

{hasStickyColumns ? <InnerScrollContainer>{table}</InnerScrollContainer> : table}

{!loading && emptyTableView && data.length === 0 && (
<div style={{ padding: 'var(--pf-global--spacer--2xl) 0', textAlign: 'center' }}>
{emptyTableView}
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/components/table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ export type GetColumnSort = (columnIndex: number) => ThProps['sort'];

export type SortableData<T> = Pick<
ThProps,
'hasRightBorder' | 'isStickyColumn' | 'modifier' | 'width' | 'info' | 'className'
| 'hasRightBorder'
| 'isStickyColumn'
| 'stickyMinWidth'
| 'stickyLeftOffset'
| 'modifier'
| 'width'
| 'info'
| 'className'
> & {
label: string;
field: string;
Expand Down
Loading

0 comments on commit 1391bbd

Please sign in to comment.