From 208cf3def25b29b51a6e3f8bac8ba68d96787140 Mon Sep 17 00:00:00 2001 From: Matt Seddon Date: Tue, 14 Mar 2023 17:37:03 +1100 Subject: [PATCH] Add show experiments button to final experiments screen --- extension/src/setup/index.ts | 3 ++- extension/src/setup/webview/messages.ts | 7 ++++++- extension/src/webview/contract.ts | 2 ++ webview/src/setup/components/Experiments.tsx | 9 +++++++++ webview/src/setup/components/messages.ts | 4 ++++ webview/src/shared/components/icons/Beaker.tsx | 17 +++++++++++++++++ webview/src/shared/components/icons/index.ts | 1 + 7 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 webview/src/shared/components/icons/Beaker.tsx diff --git a/extension/src/setup/index.ts b/extension/src/setup/index.ts index a5fb6cdca2..9eba4ef5ec 100644 --- a/extension/src/setup/index.ts +++ b/extension/src/setup/index.ts @@ -367,7 +367,8 @@ export class Setup private createWebviewMessageHandler() { const webviewMessages = new WebviewMessages( () => this.getWebview(), - () => this.initializeGit() + () => this.initializeGit(), + () => this.showExperiments() ) this.dispose.track( this.onDidReceivedWebviewMessage(message => diff --git a/extension/src/setup/webview/messages.ts b/extension/src/setup/webview/messages.ts index 636e56fecd..118e2c40a3 100644 --- a/extension/src/setup/webview/messages.ts +++ b/extension/src/setup/webview/messages.ts @@ -20,13 +20,16 @@ import { openUrl } from '../../vscode/external' export class WebviewMessages { private readonly getWebview: () => BaseWebview | undefined private readonly initializeGit: () => void + private readonly showExperiments: () => void constructor( getWebview: () => BaseWebview | undefined, - initializeGit: () => void + initializeGit: () => void, + showExperiments: () => void ) { this.getWebview = getWebview this.initializeGit = initializeGit + this.showExperiments = showExperiments } public sendWebviewMessage({ @@ -94,6 +97,8 @@ export class WebviewMessages { ConfigKey.STUDIO_SHARE_EXPERIMENTS_LIVE, message.payload ) + case MessageFromWebviewType.SHOW_EXPERIMENTS: + return this.showExperiments() default: Logger.error(`Unexpected message: ${JSON.stringify(message)}`) diff --git a/extension/src/webview/contract.ts b/extension/src/webview/contract.ts index 212ff8ff4f..645f4b09a2 100644 --- a/extension/src/webview/contract.ts +++ b/extension/src/webview/contract.ts @@ -52,6 +52,7 @@ export enum MessageFromWebviewType { SET_STUDIO_SHARE_EXPERIMENTS_LIVE = 'set-studio-share-experiments-live', SHARE_EXPERIMENT_AS_BRANCH = 'share-experiment-as-branch', SHARE_EXPERIMENT_AS_COMMIT = 'share-experiment-as-commit', + SHOW_EXPERIMENTS = 'show-experiments', TOGGLE_METRIC = 'toggle-metric', TOGGLE_PLOTS_SECTION = 'toggle-plots-section', REMOVE_CUSTOM_PLOTS = 'remove-custom-plots', @@ -237,6 +238,7 @@ export type MessageFromWebview = | { type: MessageFromWebviewType.SAVE_STUDIO_TOKEN } | { type: MessageFromWebviewType.ADD_CONFIGURATION } | { type: MessageFromWebviewType.ZOOM_PLOT } + | { type: MessageFromWebviewType.SHOW_EXPERIMENTS } export type MessageToWebview = { type: MessageToWebviewType.SET_DATA diff --git a/webview/src/setup/components/Experiments.tsx b/webview/src/setup/components/Experiments.tsx index de02909e74..12725454bd 100644 --- a/webview/src/setup/components/Experiments.tsx +++ b/webview/src/setup/components/Experiments.tsx @@ -9,11 +9,14 @@ import { installDvc, selectPythonInterpreter, setupWorkspace, + showExperiments, showScmPanel } from './messages' import { NeedsGitCommit } from './NeedsGitCommit' import { NoData } from './NoData' import { EmptyState } from '../../shared/components/emptyState/EmptyState' +import { IconButton } from '../../shared/components/button/IconButton' +import { Beaker } from '../../shared/components/icons' export type ExperimentsProps = { canGitInitialize: boolean | undefined @@ -79,6 +82,12 @@ export const Experiments: React.FC = ({ return (

{"You're all setup"}

+
) } diff --git a/webview/src/setup/components/messages.ts b/webview/src/setup/components/messages.ts index 2b60384219..d9a2ffb485 100644 --- a/webview/src/setup/components/messages.ts +++ b/webview/src/setup/components/messages.ts @@ -33,6 +33,10 @@ export const setupWorkspace = () => { sendMessage({ type: MessageFromWebviewType.SETUP_WORKSPACE }) } +export const showExperiments = () => { + sendMessage({ type: MessageFromWebviewType.SHOW_EXPERIMENTS }) +} + export const openStudio = () => sendMessage({ type: MessageFromWebviewType.OPEN_STUDIO }) diff --git a/webview/src/shared/components/icons/Beaker.tsx b/webview/src/shared/components/icons/Beaker.tsx new file mode 100644 index 0000000000..4f664318a9 --- /dev/null +++ b/webview/src/shared/components/icons/Beaker.tsx @@ -0,0 +1,17 @@ +import * as React from 'react' +import { SVGProps } from 'react' +const SvgBeaker = (props: SVGProps) => ( + + + +) +export default SvgBeaker diff --git a/webview/src/shared/components/icons/index.ts b/webview/src/shared/components/icons/index.ts index db0a6b4e15..60499e9ca7 100644 --- a/webview/src/shared/components/icons/index.ts +++ b/webview/src/shared/components/icons/index.ts @@ -1,4 +1,5 @@ export { default as Add } from './Add' +export { default as Beaker } from './Beaker' export { default as Check } from './Check' export { default as ChevronDown } from './ChevronDown' export { default as ChevronRight } from './ChevronRight'