Skip to content

Commit 47e4bb9

Browse files
authored
Add drag and drop mode to plots (#4934)
* WIP Add drag and drop mode * Add drag and drop ode to custom plots * Fix some tests * Fix tests * Self review * Add tests * Apply review * Remove empty optional prop * Seamless drag and drop mode (#4942) * Make toggling drag and drop mode seamless * Add tests * Fix pplot actions * Fix drag end event * Add style to plots in drag and drop mode (#4960) * Add style to drag and drop mode plots * Format custom plots titles in drag and drop mode * Self review * Add tests * Fix bug and style
1 parent 9554e41 commit 47e4bb9

32 files changed

+1346
-1044
lines changed

extension/src/experiments/columns/collect/metricsAndParams.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ import {
1616
fileHasError,
1717
MetricsOrParams
1818
} from '../../../cli/dvc/contract'
19-
import {
20-
buildMetricOrParamPath,
21-
FILE_SEPARATOR,
22-
METRIC_PARAM_SEPARATOR
23-
} from '../paths'
19+
import { buildMetricOrParamPath } from '../paths'
20+
import { FILE_SEPARATOR, METRIC_PARAM_SEPARATOR } from '../constants'
2421

2522
const collectMetricOrParam = (
2623
acc: ColumnAccumulator,

extension/src/experiments/columns/constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ export const DEFAULT_COLUMN_IDS = [
2020
BRANCH_COLUMN_ID,
2121
COMMIT_COLUMN_ID
2222
]
23+
24+
export const ENCODED_METRIC_PARAM_SEPARATOR = '%2E'
25+
export const ENCODE_METRIC_PARAM_REGEX = /\./g
26+
export const DECODE_METRIC_PARAM_REGEX = /%2E/g
27+
export const METRIC_PARAM_SEPARATOR = '.'
28+
export const FILE_SEPARATOR = ':'
29+
export const FILE_SPLIT_REGEX = new RegExp(
30+
`([^${FILE_SEPARATOR}]*)(?:${FILE_SEPARATOR}([^${FILE_SEPARATOR}]*))?(?:${FILE_SEPARATOR}(.*))?`
31+
)

extension/src/experiments/columns/paths.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { join } from 'path'
2+
import {
3+
DECODE_METRIC_PARAM_REGEX,
4+
ENCODED_METRIC_PARAM_SEPARATOR,
5+
ENCODE_METRIC_PARAM_REGEX,
6+
FILE_SEPARATOR,
7+
FILE_SPLIT_REGEX,
8+
METRIC_PARAM_SEPARATOR
9+
} from './constants'
210
import { definedAndNonEmpty } from '../../util/array'
311
import { ColumnType } from '../webview/contract'
412

5-
export const METRIC_PARAM_SEPARATOR = '.'
6-
const ENCODED_METRIC_PARAM_SEPARATOR = '%2E'
7-
const ENCODE_METRIC_PARAM_REGEX = /\./g
8-
const DECODE_METRIC_PARAM_REGEX = /%2E/g
9-
10-
export const FILE_SEPARATOR = ':'
11-
const FILE_SPLIT_REGEX = new RegExp(
12-
`([^${FILE_SEPARATOR}]*)(?:${FILE_SEPARATOR}([^${FILE_SEPARATOR}]*))?(?:${FILE_SEPARATOR}(.*))?`
13-
)
14-
1513
const encodeColumn = (segment: string) =>
1614
segment.replace(ENCODE_METRIC_PARAM_REGEX, ENCODED_METRIC_PARAM_SEPARATOR)
1715

extension/src/plots/model/collect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ const getCustomPlotData = (
151151
const updatedSpec = truncateVegaSpecTitles(spec, nbItemsPerRow, height)
152152

153153
return {
154+
content: updatedSpec,
154155
id: getCustomPlotId(metric, param),
155156
metric,
156157
param,
157-
spec: updatedSpec,
158158
values
159159
} as CustomPlotData
160160
}

extension/src/plots/model/custom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TopLevelSpec } from 'vega-lite'
22
import { getCustomPlotId } from './collect'
33
import { Column, ColumnType } from '../../experiments/webview/contract'
4-
import { FILE_SEPARATOR } from '../../experiments/columns/paths'
4+
import { FILE_SEPARATOR } from '../../experiments/columns/constants'
55
import { ColorScale } from '../webview/contract'
66

77
export type CustomPlotsOrderValue = {

extension/src/plots/webview/contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export type CustomPlot = {
9494
}
9595

9696
export type CustomPlotData = CustomPlot & {
97-
spec: SpecWithTitles
97+
content: SpecWithTitles
9898
}
9999

100100
export type CustomPlotsData = {

extension/src/test/fixtures/expShow/base/customPlots.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const data: CustomPlotsData = {
9999
id: 'custom-summary.json:loss-params.yaml:log_file',
100100
metric: 'summary.json:loss',
101101
param: 'params.yaml:log_file',
102-
spec: {
102+
content: {
103103
$schema: 'https://vega.github.io/schema/vega-lite/v5.json',
104104
data: { name: 'values' },
105105
encoding: {
@@ -245,7 +245,7 @@ const data: CustomPlotsData = {
245245
param: 5
246246
}
247247
],
248-
spec: {
248+
content: {
249249
$schema: 'https://vega.github.io/schema/vega-lite/v5.json',
250250
data: { name: 'values' },
251251
encoding: {

0 commit comments

Comments
 (0)