-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add "Parents" Columns #4691
Add "Parents" Columns #4691
Changes from 12 commits
0a92bf1
04a7667
44e4f75
2380be6
274569f
f8a64e3
e9668bf
d1e788d
3a2c218
6addc80
843c460
8306b21
4972d12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
} from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import tableDataFixture from 'dvc/src/test/fixtures/expShow/base/tableData' | ||
import sortedTableData from 'dvc/src/test/fixtures/expShow/sorted/tableData' | ||
import { MessageFromWebviewType } from 'dvc/src/webview/contract' | ||
import { | ||
Column, | ||
|
@@ -25,7 +26,7 @@ import { vsCodeApi } from '../../shared/api' | |
import { | ||
commonColumnFields, | ||
expectHeaders, | ||
tableData as sortingTableDataFixture | ||
tableData as simplifiedSortedTableDataFixture | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed this to differentiate from the |
||
} from '../../test/sort' | ||
import { | ||
NORMAL_TOOLTIP_DELAY, | ||
|
@@ -61,6 +62,11 @@ const tableStateFixture = { | |
columnData: collectColumnData(tableDataFixture.columns) | ||
} | ||
|
||
const sortedTableDataFixture = { | ||
julieg18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
...sortedTableData, | ||
columnData: collectColumnData(sortedTableData.columns) | ||
} | ||
|
||
jest.mock('../../shared/api') | ||
jest.mock('../../util/styles') | ||
jest.mock('./overflowHoverTooltip/useIsFullyContained', () => ({ | ||
|
@@ -99,6 +105,19 @@ describe('App', () => { | |
expect(noColumnsState).toBeInTheDocument() | ||
}) | ||
|
||
it('should show the no columns selected empty state when there are no columns provided and the table is sorted', () => { | ||
const { columns } = tableStateFixture | ||
const sortPath = columns[columns.length - 1].path | ||
renderTable({ | ||
...tableDataFixture, | ||
columns: [], | ||
sorts: [{ descending: true, path: sortPath }] | ||
}) | ||
|
||
const noColumnsState = screen.queryByText('No Columns Selected.') | ||
expect(noColumnsState).toBeInTheDocument() | ||
}) | ||
|
||
it('should not show the no columns selected empty state when only the timestamp column is provided', () => { | ||
renderTable({ | ||
...tableStateFixture, | ||
|
@@ -144,9 +163,9 @@ describe('App', () => { | |
const { getDraggableHeaderFromText } = renderTableWithSortingData() | ||
|
||
setTableData({ | ||
...sortingTableDataFixture, | ||
...simplifiedSortedTableDataFixture, | ||
columns: [ | ||
...sortingTableDataFixture.columns, | ||
...simplifiedSortedTableDataFixture.columns, | ||
{ | ||
...commonColumnFields, | ||
id: 'D', | ||
|
@@ -164,6 +183,48 @@ describe('App', () => { | |
await expectHeaders(['A', 'C', 'D', 'B']) | ||
}) | ||
|
||
it('should add a "branch/tags" column if the table is sorted', () => { | ||
renderTable(sortedTableDataFixture) | ||
|
||
const branchHeader = screen.getByTestId('header-branch') | ||
expect(branchHeader).toBeInTheDocument() | ||
|
||
const branchHeaderTextContent = | ||
within(branchHeader).getByText('Branch/Tags') | ||
expect(branchHeader).toBeInTheDocument() | ||
|
||
fireEvent.mouseEnter(branchHeaderTextContent, { bubbles: true }) | ||
expect(screen.getByRole('tooltip')).toBeInTheDocument() | ||
expect(screen.getByRole('tooltip')).toHaveTextContent( | ||
'The table has limited functionality while sorted. Clear all sorts to have nested rows and increase/decrease commits.' | ||
) | ||
|
||
expect(screen.getByTestId('branch___main').textContent).toStrictEqual( | ||
'main' | ||
) | ||
}) | ||
|
||
it('should add a "parents" column if the table is sorted', () => { | ||
julieg18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
renderTable(sortedTableDataFixture) | ||
|
||
const commitHeader = screen.getByTestId('header-commit') | ||
expect(commitHeader).toBeInTheDocument() | ||
|
||
const commitHeaderTextContent = within(commitHeader).getByText('Parent') | ||
expect(commitHeader).toBeInTheDocument() | ||
|
||
fireEvent.mouseEnter(commitHeaderTextContent, { bubbles: true }) | ||
expect(screen.getByRole('tooltip')).toBeInTheDocument() | ||
expect(screen.getByRole('tooltip')).toHaveTextContent( | ||
'The table has limited functionality while sorted. Clear all sorts to have nested rows and increase/decrease commits.' | ||
) | ||
|
||
expect(screen.getByTestId('commit___main').textContent).toStrictEqual('') | ||
expect(screen.getByTestId('commit___exp-83425').textContent).toStrictEqual( | ||
'53c3851' | ||
) | ||
}) | ||
|
||
describe('Row expansion', () => { | ||
const experimentLabel = '4fb124a' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import { WebviewWrapper } from '../../shared/components/webviewWrapper/WebviewWr | |
import { EmptyState } from '../../shared/components/emptyState/EmptyState' | ||
import { ExperimentsState } from '../store' | ||
import { resizeColumn } from '../util/messages' | ||
import { isDefaultColumn } from '../util/columns' | ||
|
||
const DEFAULT_COLUMN_WIDTH = 90 | ||
const MINIMUM_COLUMN_WIDTH = 90 | ||
|
@@ -56,12 +57,15 @@ export const ExperimentsTable: React.FC = () => { | |
columnOrder: columnOrderData, | ||
columnWidths, | ||
hasConfig, | ||
rows: data | ||
rows: data, | ||
sorts | ||
} = useSelector((state: ExperimentsState) => state.tableData) | ||
|
||
const [expanded, setExpanded] = useState({}) | ||
|
||
const [columns, setColumns] = useState(buildColumns(columnData)) | ||
const [columns, setColumns] = useState( | ||
buildColumns(columnData, sorts.length > 0) | ||
) | ||
const [columnSizing, setColumnSizing] = | ||
useState<ColumnSizingState>(columnWidths) | ||
const [columnOrder, setColumnOrder] = useState(columnOrderData) | ||
|
@@ -72,8 +76,8 @@ export const ExperimentsTable: React.FC = () => { | |
}, [columnSizing, columnWidths]) | ||
|
||
useEffect(() => { | ||
setColumns(buildColumns(columnData)) | ||
}, [columnData]) | ||
setColumns(buildColumns(columnData, sorts.length > 0)) | ||
}, [columnData, sorts]) | ||
|
||
const getRowId = useCallback( | ||
(experiment: Commit, relativeIndex: number, parent?: TableRow<Commit>) => | ||
|
@@ -108,7 +112,9 @@ export const ExperimentsTable: React.FC = () => { | |
toggleAllRowsExpanded() | ||
}, [toggleAllRowsExpanded]) | ||
|
||
const hasOnlyDefaultColumns = columns.length <= 1 | ||
const hasOnlyDefaultColumns = columns.every( | ||
({ id }) => id && isDefaultColumn(id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated this to check for the column ids since there are now 1 or 3 default columns depending on if the table is sorted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Q] Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it does :) |
||
) | ||
if (hasOnlyDefaultColumns) { | ||
return <AddColumns /> | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added two more default columns (ids are commt and branch). These always stay in the order on the backend and appear on the frontend if the table is sorted. Similar to the
id
column, they are not draggable and can't be unselected.