Skip to content

Commit

Permalink
Merge branch 'main' into no-toggle-on-link
Browse files Browse the repository at this point in the history
  • Loading branch information
sroy3 authored Oct 19, 2022
2 parents a981f3f + 5a382de commit b31475e
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 70 deletions.
2 changes: 1 addition & 1 deletion languageServer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"format": "prettier --write '**/*.{js,json,jsx,md,scss,ts,tsx,yaml,yml}'",
"lint:prettier": "prettier -c '**/*.{js,json,jsx,md,scss,ts,tsx,yaml,yml}'",
"lint:eslint": "eslint --cache '**/*.{js,ts,jsx,tsx}'",
"lint:tsc": "tsc --noEmit",
"lint:compile": "webpack --mode development",
"lint": "run-p 'lint:*'",
"dev": "webpack watch --mode development",
"test": "jest --collect-coverage"
Expand Down
2 changes: 1 addition & 1 deletion webview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"format": "prettier --write '**/*.{js,json,jsx,md,scss,ts,tsx,yaml,yml}'",
"lint:prettier": "prettier -c '**/*.{js,json,jsx,md,scss,ts,tsx,yaml,yml}'",
"lint:eslint": "eslint --cache '**/*.{js,ts,jsx,tsx}'",
"lint:tsc": "tsc --noEmit",
"lint:compile": "webpack --mode development",
"lint": "run-p 'lint:*'",
"dev": "webpack watch --mode development",
"build": "webpack --mode production",
Expand Down
9 changes: 2 additions & 7 deletions webview/src/experiments/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -737,19 +737,14 @@ describe('App', () => {
jest.useRealTimers()
})

it('should open on left click', () => {
it('should not open on left click', () => {
renderTableWithoutRunningExperiments()

const paramsFileHeader = screen.getByText('params.yaml')
fireEvent.click(paramsFileHeader, { bubbles: true })

jest.advanceTimersByTime(100)
const menuitems = screen.getAllByRole('menuitem')
const itemLabels = menuitems.map(item => item.textContent)
expect(itemLabels).toStrictEqual([
'Open to the Side',
'Set Max Header Height'
])
expect(screen.queryAllByRole('menuitem')).toHaveLength(0)
})

it('should open on right click and close on esc', () => {
Expand Down
2 changes: 1 addition & 1 deletion webview/src/experiments/components/table/Table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { MessageFromWebviewType } from 'dvc/src/webview/contract'
import React from 'react'
import { TableInstance } from 'react-table'
import tableDataFixture from 'dvc/src/test/fixtures/expShow/tableData'
import { SortOrder } from './TableHeader'
import { SortOrder } from './header/TableHeader'
import { Table } from './Table'
import styles from './styles.module.scss'
import { ExperimentsTable } from '../Experiments'
Expand Down
2 changes: 1 addition & 1 deletion webview/src/experiments/components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useRef, useState, CSSProperties } from 'react'
import { useSelector } from 'react-redux'
import cx from 'classnames'
import styles from './styles.module.scss'
import { TableHead } from './TableHead'
import { TableHead } from './header/TableHead'
import { InstanceProp, RowProp } from './interfaces'
import { RowSelectionContext } from './RowSelectionContext'
import { TableBody } from './TableBody'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import cx from 'classnames'
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 { DragFunction } from '../../../shared/components/dragDrop/Draggable'
import styles from '../styles.module.scss'
import { DragFunction } from '../../../../shared/components/dragDrop/Draggable'

export const MergedHeaderGroups: React.FC<{
headerGroup: HeaderGroup<Experiment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import React, { DragEvent, useRef, useEffect } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { HeaderGroup, TableInstance } from 'react-table'
import { MessageFromWebviewType } from 'dvc/src/webview/contract'
import styles from './styles.module.scss'
import { MergedHeaderGroups } from './MergeHeaderGroups'
import { Indicators } from './Indicators'
import { setDropTarget } from './headerDropTargetSlice'
import { useColumnOrder } from '../../hooks/useColumnOrder'
import { ExperimentsState } from '../../store'
import { sendMessage } from '../../../shared/vscode'
import { leafColumnIds, reorderColumnIds } from '../../util/columns'
import { DragFunction } from '../../../shared/components/dragDrop/Draggable'
import { getSelectedForPlotsCount } from '../../util/rows'

import { setDropTarget } from '../headerDropTargetSlice'
import styles from '../styles.module.scss'
import { Indicators } from '../Indicators'
import { useColumnOrder } from '../../../hooks/useColumnOrder'
import { ExperimentsState } from '../../../store'
import { sendMessage } from '../../../../shared/vscode'
import { leafColumnIds, reorderColumnIds } from '../../../util/columns'
import { DragFunction } from '../../../../shared/components/dragDrop/Draggable'
import { getSelectedForPlotsCount } from '../../../util/rows'
interface TableHeadProps {
instance: TableInstance<Experiment>
root: HTMLElement | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { HeaderGroup } from 'react-table'
import { MessageFromWebviewType } from 'dvc/src/webview/contract'
import { VSCodeDivider } from '@vscode/webview-ui-toolkit/react'
import { TableHeaderCell } from './TableHeaderCell'
import { ExperimentsState } from '../../store'
import { DragFunction } from '../../../shared/components/dragDrop/Draggable'
import { MessagesMenu } from '../../../shared/components/messagesMenu/MessagesMenu'
import { MessagesMenuOptionProps } from '../../../shared/components/messagesMenu/MessagesMenuOption'
import { ExperimentsState } from '../../../store'
import { DragFunction } from '../../../../shared/components/dragDrop/Draggable'
import { MessagesMenu } from '../../../../shared/components/messagesMenu/MessagesMenu'
import { MessagesMenuOptionProps } from '../../../../shared/components/messagesMenu/MessagesMenuOption'

export enum SortOrder {
ASCENDING = 'Sort Ascending',
Expand All @@ -38,6 +38,39 @@ interface TableHeaderProps {
root: HTMLElement | null
}

export const sortOption = (
label: SortOrder,
currentSort: SortOrder,
columnId: string
) => {
const sortOrder = currentSort
const hidden = sortOrder === label
const descending = label === SortOrder.DESCENDING
const path = columnId
const removeSortMessage = {
payload: columnId,
type: MessageFromWebviewType.REMOVE_COLUMN_SORT
}
const payload = {
descending,
path
}
const message =
label === SortOrder.NONE
? removeSortMessage
: {
payload,
type: MessageFromWebviewType.SORT_COLUMN
}

return {
hidden,
id: label,
label,
message
} as MessagesMenuOptionProps
}

export const TableHeader: React.FC<TableHeaderProps> = ({
column,
columns,
Expand Down Expand Up @@ -116,39 +149,9 @@ export const TableHeader: React.FC<TableHeaderProps> = ({
<VSCodeDivider />
<MessagesMenu
options={[
{
hidden: sortOrder === SortOrder.ASCENDING,
id: SortOrder.ASCENDING,
label: SortOrder.ASCENDING,
message: {
payload: {
descending: false,
path: column.id
},
type: MessageFromWebviewType.SORT_COLUMN
}
},
{
hidden: sortOrder === SortOrder.DESCENDING,
id: SortOrder.DESCENDING,
label: SortOrder.DESCENDING,
message: {
payload: {
descending: true,
path: column.id
},
type: MessageFromWebviewType.SORT_COLUMN
}
},
{
hidden: sortOrder === SortOrder.NONE,
id: SortOrder.NONE,
label: SortOrder.NONE,
message: {
payload: column.id,
type: MessageFromWebviewType.REMOVE_COLUMN_SORT
}
}
sortOption(SortOrder.ASCENDING, sortOrder, column.id),
sortOption(SortOrder.DESCENDING, sortOrder, column.id),
sortOption(SortOrder.NONE, sortOrder, column.id)
]}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import { useSelector } from 'react-redux'
import { HeaderGroup } from 'react-table'
import cx from 'classnames'
import { useInView } from 'react-intersection-observer'
import styles from './styles.module.scss'
import { SortOrder } from './TableHeader'
import { TableHeaderCellContents } from './TableHeaderCellContents'
import styles from '../styles.module.scss'
import {
countUpperLevels,
isExperimentColumn,
isFirstLevelHeader
} from '../../util/columns'
import { ContextMenu } from '../../../shared/components/contextMenu/ContextMenu'
import { DragFunction } from '../../../shared/components/dragDrop/Draggable'
import { ExperimentsState } from '../../store'
} from '../../../util/columns'
import { ExperimentsState } from '../../../store'
import { ContextMenu } from '../../../../shared/components/contextMenu/ContextMenu'
import { DragFunction } from '../../../../shared/components/dragDrop/Draggable'

const calcResizerHeight = (
isPlaceholder: boolean,
Expand Down Expand Up @@ -147,7 +147,7 @@ export const TableHeaderCell: React.FC<{
<ContextMenu
content={menuContent}
disabled={menuDisabled || menuSuppressed}
trigger={'contextmenu click'}
trigger={'contextmenu'}
>
<div
{...column.getHeaderProps(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React, { useState, useEffect } from 'react'
import cx from 'classnames'
import { ColumnType, Experiment } from 'dvc/src/experiments/webview/contract'
import { HeaderGroup } from 'react-table'
import styles from './styles.module.scss'
import { SortOrder } from './TableHeader'
import styles from '../styles.module.scss'
import {
Draggable,
DragFunction
} from '../../../shared/components/dragDrop/Draggable'
import { IconMenu } from '../../../shared/components/iconMenu/IconMenu'
import { DownArrow, Lines, UpArrow } from '../../../shared/components/icons'
} from '../../../../shared/components/dragDrop/Draggable'
import { IconMenu } from '../../../../shared/components/iconMenu/IconMenu'
import { DownArrow, Lines, UpArrow } from '../../../../shared/components/icons'

const getIconMenuItems = (
sortEnabled: boolean,
Expand Down

0 comments on commit b31475e

Please sign in to comment.