Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b575781
Use @storybook/testing-library for Storybook play functions
rogermparent Jul 8, 2022
22b2546
Stop using screen
rogermparent Jul 8, 2022
0891df3
Make header shadow only appear when scrolled
rogermparent Jul 10, 2022
7ac8f5e
Merge branch 'storybook-testing-library' into conditional-table-shadows
rogermparent Jul 11, 2022
09b68c2
Add story for scrolled table
rogermparent Jul 11, 2022
5c121b1
Merge branch 'main' into conditional-table-shadows
rogermparent Jul 11, 2022
2292037
Remove chromatic delay on MultiView Zoomed plot
rogermparent Jul 12, 2022
b20d192
Remove chromatic delays
rogermparent Jul 12, 2022
db47df5
Await multiview plot
rogermparent Jul 12, 2022
31838ba
Merge branch 'main' into storybook-testing-library
rogermparent Jul 12, 2022
284f11a
Merge branch 'storybook-testing-library' of github.com:iterative/vsco…
rogermparent Jul 12, 2022
8f48881
Remove react call to findByText
rogermparent Jul 12, 2022
40eab16
Add chromatic viewport
rogermparent Jul 12, 2022
535d769
Use scrollable viewport for chromatic
rogermparent Jul 12, 2022
278adbb
Add wrapper element to scrolled story for chromatic
rogermparent Jul 12, 2022
a03256f
Merge branch 'main' of github.com:iterative/vscode-dvc into condition…
rogermparent Jul 12, 2022
63136af
Actually export the scrolled story
rogermparent Jul 12, 2022
e7ca0ac
rename variable and class
rogermparent Jul 13, 2022
5a20636
Merge branch 'main' into conditional-table-shadows
rogermparent Jul 13, 2022
60c1b5d
Merge branch 'main' into conditional-table-shadows
rogermparent Jul 14, 2022
327e456
Merge branch 'main' into conditional-table-shadows
rogermparent Jul 14, 2022
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
1 change: 1 addition & 0 deletions webview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"lodash.merge": "^4.6.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intersection-observer": "^9.3.5",
"react-redux": "^8.0.2",
"react-table": "^7.8.0",
"react-vega": "^7.4.4",
Expand Down
9 changes: 9 additions & 0 deletions webview/setup-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ const mutationObserverMock = jest.fn().mockImplementation(() => {
})
global.MutationObserver = mutationObserverMock

const intersectionObserverMock = jest.fn().mockImplementation(() => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

return {
disconnect: jest.fn(),
observe: jest.fn(),
unobserve: jest.fn()
}
})
global.IntersectionObserver = intersectionObserverMock
Comment on lines +18 to +25
Copy link
Contributor Author

@rogermparent rogermparent Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the job of keeping things from breaking and not much more. Could be made better if we wanted to actually puppet the observer, but I think we have better ways to test most scenarios it would apply to.


StyleUtils.getThemeValue = jest.fn().mockImplementation(() => '#ffffff')
1 change: 1 addition & 0 deletions webview/src/experiments/components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export const Table: React.FC<TableProps & WithChanges> = ({
filteredCounts={filteredCounts}
filters={filters}
columns={columns}
root={tableRef.current}
/>
{rows.map(row => (
<TableBody
Expand Down
18 changes: 15 additions & 3 deletions webview/src/experiments/components/table/TableHead.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { SortDefinition } from 'dvc/src/experiments/model/sortBy'
import { Experiment, Column } from 'dvc/src/experiments/webview/contract'
import cx from 'classnames'
import React, { useRef } from 'react'
import { HeaderGroup, TableInstance } from 'react-table'
import { MessageFromWebviewType } from 'dvc/src/webview/contract'
import { FilteredCounts } from 'dvc/src/experiments/model/filterBy/collect'
import { useInView } from 'react-intersection-observer'
import styles from './styles.module.scss'
import { MergedHeaderGroups } from './MergeHeaderGroups'
import { Indicators } from './Indicators'
Expand All @@ -21,20 +23,22 @@ interface TableHeadProps {
sorts: SortDefinition[]
filteredCounts: FilteredCounts
filters: string[]
root: HTMLElement | null
}

export const TableHead: React.FC<TableHeadProps> = ({
export const TableHead = ({
instance: {
headerGroups,
setColumnOrder,
state: { columnOrder },
allColumns
},
root,
filteredCounts,
filters,
columns,
sorts
}) => {
}: TableHeadProps) => {
const orderedColumns = useColumnOrder(columns, columnOrder)
const allHeaders: HeaderGroup<Experiment>[] = []
for (const headerGroup of headerGroups) {
Expand Down Expand Up @@ -85,9 +89,17 @@ export const TableHead: React.FC<TableHeadProps> = ({
type: MessageFromWebviewType.REORDER_COLUMNS
})
}
const [ref, needsShadow] = useInView({
root,
rootMargin: '-15px 0px 0px 0px',
threshold: 1
})

return (
<div className={styles.thead}>
<div
className={cx(styles.thead, needsShadow && styles.headWithShadow)}
ref={ref}
>
<Indicators
sorts={sorts}
filters={filters}
Expand Down
7 changes: 6 additions & 1 deletion webview/src/experiments/components/table/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,15 @@ $workspace-row-edge-margin: $edge-padding - $cell-padding;
.thead {
background-color: $bg-color;
border-bottom: $row-border;
box-shadow: 0 5px 8px -2px var(--vscode-widget-shadow);
transition: 0.25s all;
box-shadow: none;
position: sticky;
top: 0;
z-index: 4;

&.headWithShadow {
box-shadow: 0 5px 8px -2px var(--vscode-widget-shadow);
}
}

.tableIndicators {
Expand Down
46 changes: 43 additions & 3 deletions webview/src/stories/Table.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import React from 'react'
import { Story, Meta } from '@storybook/react/types-6-0'
import { ComponentStory } from '@storybook/react'
import { Meta } from '@storybook/react/types-6-0'
import rowsFixture from 'dvc/src/test/fixtures/expShow/rows'
import columnsFixture from 'dvc/src/test/fixtures/expShow/columns'
import { TableData } from 'dvc/src/experiments/webview/contract'
import workspaceChangesFixture from 'dvc/src/test/fixtures/expShow/workspaceChanges'
import deeplyNestedTableData from 'dvc/src/test/fixtures/expShow/deeplyNested'
import { dataTypesTableData } from 'dvc/src/test/fixtures/expShow/dataTypes'
import { within, userEvent } from '@storybook/testing-library'
import {
within,
userEvent,
findByText,
getAllByRole
} from '@storybook/testing-library'
import Experiments from '../experiments/components/Experiments'

import './test-vscode-styles.scss'
Expand Down Expand Up @@ -56,7 +62,7 @@ export default {
title: 'Table'
} as Meta

const Template: Story<{ tableData: TableData }> = ({ tableData }) => {
const Template: ComponentStory<typeof Experiments> = ({ tableData }) => {
return <Experiments tableData={tableData} />
}

Expand Down Expand Up @@ -116,3 +122,37 @@ WithNoSortsOrFilters.args = {
sorts: []
}
}

export const Scrolled: ComponentStory<typeof Experiments> = ({ tableData }) => {
return (
<div style={{ height: 400, width: 600 }}>
<Experiments tableData={tableData} />
</div>
)
}
Scrolled.play = async ({ canvasElement }) => {
await findByText(canvasElement, '90aea7f')
const rows = getAllByRole(canvasElement, 'row')
const lastRow = rows[rows.length - 1]
const lastRowCells = within(lastRow).getAllByRole('cell')
const lastCell = lastRowCells[lastRowCells.length - 1]
lastCell.scrollIntoView()
}
Scrolled.parameters = {
chromatic: {
viewports: [400]
},
viewport: {
defaultViewport: 'scrollable',
viewports: {
scrollable: {
name: 'Scrollable',
styles: {
height: '400px',
width: '600px'
},
type: 'desktop'
}
}
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14300,6 +14300,11 @@ react-inspector@^5.1.0:
is-dom "^1.0.0"
prop-types "^15.0.0"

react-intersection-observer@^9.3.5:
version "9.3.5"
resolved "https://registry.yarnpkg.com/react-intersection-observer/-/react-intersection-observer-9.3.5.tgz#df97584c1ef1549a47d4af6380db2fb4b76d7bba"
integrity sha512-TiJXVUapzAaIrZCAMBLjyWvwGYNGm0Xpkcwm3NY23b9PsJEBavul0hRFmrwc/LOmBUA/8TlkjCj7lCvjM0q1Hg==

react-is@17.0.2, react-is@^17.0.1:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
Expand Down