diff --git a/webview/src/experiments/components/table/Cell.tsx b/webview/src/experiments/components/table/Cell.tsx index 89726949c3..ef5cbf9623 100644 --- a/webview/src/experiments/components/table/Cell.tsx +++ b/webview/src/experiments/components/table/Cell.tsx @@ -1,10 +1,9 @@ import React from 'react' -import { useInView } from 'react-intersection-observer' import cx from 'classnames' import { VSCodeCheckbox } from '@vscode/webview-ui-toolkit/react' import { Indicator, IndicatorWithJustTheCounter } from './Indicators' import styles from './styles.module.scss' -import { CellProp, WithTableRoot, RowProp } from './interfaces' +import { CellProp, RowProp } from './interfaces' import ClockIcon from '../../../shared/components/icons/Clock' import { clickAndEnterProps } from '../../../util/props' import { StarFull, StarEmpty } from '../../../shared/components/icons' @@ -130,38 +129,27 @@ export const RowActions: React.FC = ({ export const FirstCell: React.FC< CellProp & - RowActionsProps & - WithTableRoot & { + RowActionsProps & { bulletColor?: string toggleExperiment: () => void - isRowSelected: boolean - toggleRowSelection: () => void - toggleStarred: () => void } -> = ({ cell, bulletColor, toggleExperiment, root, ...rowActionsProps }) => { +> = ({ cell, bulletColor, toggleExperiment, ...rowActionsProps }) => { const { row, isPlaceholder } = cell const { original: { queued } } = row + const { subRowStates: { plotSelections } } = rowActionsProps - const [ref, needsShadow] = useInView({ - root, - rootMargin: '0px 0px 0px -15px', - threshold: 1 - }) - return (
diff --git a/webview/src/experiments/components/table/MergeHeaderGroups.tsx b/webview/src/experiments/components/table/MergeHeaderGroups.tsx index 82ae2dd457..de16956044 100644 --- a/webview/src/experiments/components/table/MergeHeaderGroups.tsx +++ b/webview/src/experiments/components/table/MergeHeaderGroups.tsx @@ -5,25 +5,25 @@ import { Experiment, Column } from 'dvc/src/experiments/webview/contract' import { HeaderGroup } from 'react-table' import { TableHeader } from './TableHeader' import styles from './styles.module.scss' -import { WithTableRoot } from './interfaces' import { OnDragOver, OnDragStart, OnDrop } from '../../../shared/components/dragDrop/DragDropWorkbench' -export const MergedHeaderGroups: React.FC< - { - headerGroup: HeaderGroup - columns: HeaderGroup[] - sorts: SortDefinition[] - filters: string[] - orderedColumns: Column[] - onDragUpdate: OnDragOver - onDragStart: OnDragStart - onDragEnd: OnDrop - } & WithTableRoot -> = ({ +export const MergedHeaderGroups: React.FC<{ + headerGroup: HeaderGroup + columns: HeaderGroup[] + sorts: SortDefinition[] + filters: string[] + orderedColumns: Column[] + onDragUpdate: OnDragOver + onDragStart: OnDragStart + onDragEnd: OnDrop + isFirst: boolean + setExpColumnNeedsShadow: (needsShadow: boolean) => void + root: HTMLElement | null +}> = ({ headerGroup, sorts, filters, @@ -32,7 +32,9 @@ export const MergedHeaderGroups: React.FC< onDragUpdate, onDragEnd, onDragStart, - root + root, + isFirst, + setExpColumnNeedsShadow }) => { return (
{headerGroup.headers.map((column: HeaderGroup, ind) => ( = ({ row, className, @@ -317,8 +315,7 @@ export const RowContent: React.FC< contextMenuDisabled, projectHasCheckpoints, hasRunningExperiment, - batchRowSelection, - root + batchRowSelection }): JSX.Element => { const { getRowProps, @@ -409,7 +406,6 @@ export const RowContent: React.FC< data-testid={isWorkspace && 'workspace-row'} > = ({ row, instance, contextMenuDisabled, projectHasCheckpoints, hasRunningExperiment, - batchRowSelection, - root + batchRowSelection }) => { instance.prepareRow(row) return ( = ({ row, instance, contextMenuDisabled, projectHasCheckpoints, hasRunningExperiment, - batchRowSelection, - root + batchRowSelection }) => { instance.prepareRow(row) return ( @@ -58,7 +49,6 @@ export const ExperimentGroup: React.FC< )} > ( = ({ row, instance, @@ -92,8 +81,7 @@ export const TableBody: React.FC< contextMenuDisabled, projectHasCheckpoints, hasRunningExperiment, - batchRowSelection, - root + batchRowSelection }) => { instance.prepareRow(row) return ( @@ -109,7 +97,6 @@ export const TableBody: React.FC< })} > ( = ({ const { clearSelectedRows, batchSelection, lastSelectedRow } = React.useContext(RowSelectionContext) + const [expColumnNeedsShadow, setExpColumnNeedsShadow] = useState(false) const tableRef = useRef(null) @@ -192,7 +179,12 @@ export const Table: React.FC = ({ return (
= ({ filters={filters} columns={columns} root={tableRef.current} + setExpColumnNeedsShadow={setExpColumnNeedsShadow} /> {rows.map(row => ( = ({ hasRunningExperiment={hasRunningExperiment} projectHasCheckpoints={hasCheckpoints} batchRowSelection={batchRowSelection} - root={tableRef.current} /> ))}
diff --git a/webview/src/experiments/components/table/TableHead.tsx b/webview/src/experiments/components/table/TableHead.tsx index 27f8c8c70a..a5542012fd 100644 --- a/webview/src/experiments/components/table/TableHead.tsx +++ b/webview/src/experiments/components/table/TableHead.tsx @@ -24,6 +24,7 @@ interface TableHeadProps { filteredCounts: FilteredCounts filters: string[] root: HTMLElement | null + setExpColumnNeedsShadow: (needsShadow: boolean) => void } export const TableHead = ({ @@ -37,7 +38,8 @@ export const TableHead = ({ filteredCounts, filters, columns, - sorts + sorts, + setExpColumnNeedsShadow }: TableHeadProps) => { const orderedColumns = useColumnOrder(columns, columnOrder) const allHeaders: HeaderGroup[] = [] @@ -105,7 +107,7 @@ export const TableHead = ({ filters={filters} filteredCounts={filteredCounts} /> - {headerGroups.map(headerGroup => ( + {headerGroups.map((headerGroup, ind) => ( // eslint-disable-next-line react/jsx-key ))}
diff --git a/webview/src/experiments/components/table/TableHeader.tsx b/webview/src/experiments/components/table/TableHeader.tsx index 9482240604..8b730cba0b 100644 --- a/webview/src/experiments/components/table/TableHeader.tsx +++ b/webview/src/experiments/components/table/TableHeader.tsx @@ -4,14 +4,13 @@ import { Column, ColumnType } from 'dvc/src/experiments/webview/contract' -import React from 'react' +import React, { useEffect } from 'react' import { HeaderGroup } from 'react-table' import cx from 'classnames' import { useInView } from 'react-intersection-observer' import { MessageFromWebviewType } from 'dvc/src/webview/contract' import { VSCodeDivider } from '@vscode/webview-ui-toolkit/react' import styles from './styles.module.scss' -import { WithTableRoot } from './interfaces' import { countUpperLevels, isFirstLevelHeader } from '../../util/columns' import { ContextMenu } from '../../../shared/components/contextMenu/ContextMenu' import { @@ -131,30 +130,22 @@ const getIconMenuItems = ( } ] -const FirstTableHeaderCellWrapper: React.FC< - { - cellProps: React.HTMLAttributes - children: React.ReactNode - } & WithTableRoot -> = ({ root, cellProps, children }) => { +const FirstTableHeaderCellWrapper: React.FC<{ + children: React.ReactNode + setExpColumnNeedsShadow: (needsShadow: boolean) => void + root: HTMLElement | null +}> = ({ root, setExpColumnNeedsShadow, children }) => { const [ref, needsShadow] = useInView({ root, rootMargin: '0px 0px 0px -15px', threshold: 1 }) - return ( -
- {children} -
- ) + useEffect(() => { + setExpColumnNeedsShadow(needsShadow) + }, [needsShadow, setExpColumnNeedsShadow]) + + return
{children}
} const TableHeaderCellContents: React.FC<{ @@ -209,22 +200,22 @@ const TableHeaderCellContents: React.FC<{ ) } -const TableHeaderCell: React.FC< - { - column: HeaderGroup - columns: HeaderGroup[] - hasFilter: boolean - orderedColumns: Column[] - sortOrder: SortOrder - sortEnabled: boolean - menuDisabled?: boolean - menuContent?: React.ReactNode - onDragOver: OnDragOver - onDragStart: OnDragStart - onDrop: OnDrop - isFirst: boolean - } & WithTableRoot -> = ({ +const TableHeaderCell: React.FC<{ + column: HeaderGroup + columns: HeaderGroup[] + hasFilter: boolean + orderedColumns: Column[] + sortOrder: SortOrder + sortEnabled: boolean + menuDisabled?: boolean + menuContent?: React.ReactNode + onDragOver: OnDragOver + onDragStart: OnDragStart + onDrop: OnDrop + isFirst: boolean + setExpColumnNeedsShadow: (needsShadow: boolean) => void + root: HTMLElement | null +}> = ({ column, columns, orderedColumns, @@ -237,7 +228,8 @@ const TableHeaderCell: React.FC< onDragStart, onDrop, root, - isFirst + isFirst, + setExpColumnNeedsShadow }) => { const [menuSuppressed, setMenuSuppressed] = React.useState(false) const isDraggable = @@ -252,16 +244,6 @@ const TableHeaderCell: React.FC< columns ) - const cellProps = { - ...column.getHeaderProps( - getHeaderPropsArgs(column, sortEnabled, sortOrder) - ), - 'data-testid': `header-${column.id}`, - key: column.id, - role: 'columnheader', - tabIndex: 0 - } - const cellContents = ( - {isFirst ? ( - - {cellContents} - - ) : ( -
{cellContents}
- )} +
+ {isFirst ? ( + + {cellContents} + + ) : ( + cellContents + )} +
) } @@ -306,9 +301,11 @@ interface TableHeaderProps { onDragStart: OnDragStart onDrop: OnDrop isFirst: boolean + setExpColumnNeedsShadow: (needsShadow: boolean) => void + root: HTMLElement | null } -export const TableHeader: React.FC = ({ +export const TableHeader: React.FC = ({ column, columns, filters, @@ -318,7 +315,8 @@ export const TableHeader: React.FC = ({ onDragStart, onDrop, root, - isFirst + isFirst, + setExpColumnNeedsShadow }) => { const baseColumn = column.placeholderOf || column const sort = sorts.find(sort => sort.path === baseColumn.id) @@ -370,6 +368,7 @@ export const TableHeader: React.FC = ({ menuDisabled={!isSortable && column.group !== ColumnType.PARAMS} root={root} isFirst={isFirst} + setExpColumnNeedsShadow={setExpColumnNeedsShadow} menuContent={
diff --git a/webview/src/experiments/components/table/interfaces.ts b/webview/src/experiments/components/table/interfaces.ts index 8712c9326b..8dc2626d3e 100644 --- a/webview/src/experiments/components/table/interfaces.ts +++ b/webview/src/experiments/components/table/interfaces.ts @@ -13,10 +13,6 @@ export interface WithChanges { changes?: string[] } -export interface WithTableRoot { - root: HTMLElement | null -} - export interface RowProp { row: Row contextMenuDisabled?: boolean diff --git a/webview/src/experiments/components/table/styles.module.scss b/webview/src/experiments/components/table/styles.module.scss index 782ff3b07d..b95620f6f4 100644 --- a/webview/src/experiments/components/table/styles.module.scss +++ b/webview/src/experiments/components/table/styles.module.scss @@ -8,7 +8,6 @@ $row-border: 1px solid $border-color; $edge-padding: 0.8rem; $cell-padding: 0.5rem; $workspace-row-edge-margin: $edge-padding - $cell-padding; -$exp-cell-shadow: 3px 0px 0px var(--vscode-widget-shadow); // Extendable Silent Rules %expandableRowArrow { @@ -283,6 +282,14 @@ $exp-cell-shadow: 3px 0px 0px var(--vscode-widget-shadow); } } + .table.withExpColumnShadow { + .tr:not(.rowSelected) { + & > *:first-child { + box-shadow: 3px 0px 0px var(--vscode-widget-shadow); + } + } + } + .bodyRow { &:not(.rowSelected) { & > *:first-child { @@ -419,15 +426,9 @@ $exp-cell-shadow: 3px 0px 0px var(--vscode-widget-shadow); min-width: 0; position: relative; } - .th { height: auto; - - &.withExpCellShadow { - box-shadow: $exp-cell-shadow; - } } - .td { height: auto; font-size: 0.8rem; @@ -449,11 +450,6 @@ $exp-cell-shadow: 3px 0px 0px var(--vscode-widget-shadow); display: flex; flex-flow: row nowrap; text-align: left; - - &.withExpCellShadow { - box-shadow: $exp-cell-shadow; - } - .innerCell { justify-content: flex-start;