Skip to content

Commit

Permalink
Move Connect to Studio into Setup webview (#3452)
Browse files Browse the repository at this point in the history
* move Connect to Studio into Setup webview

* reduce duplication and refactor
  • Loading branch information
mattseddon authored Mar 14, 2023
1 parent 40e7d96 commit 5302a56
Show file tree
Hide file tree
Showing 47 changed files with 976 additions and 1,055 deletions.
22 changes: 2 additions & 20 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,6 @@
"command": "dvc.showCommands",
"category": "DVC"
},
{
"title": "Connect to Studio",
"command": "dvc.showConnect",
"category": "DVC"
},
{
"title": "Open Studio Settings",
"command": "dvc.showStudioSettings",
"category": "DVC"
},
{
"title": "Show Experiments",
"command": "dvc.showExperiments",
Expand Down Expand Up @@ -819,14 +809,6 @@
"command": "dvc.stopQueuedExperiments",
"when": "dvc.commands.available && dvc.project.available"
},
{
"command": "dvc.showConnect",
"when": "dvc.commands.available && dvc.project.available && !dvc.studio.connected"
},
{
"command": "dvc.showStudioSettings",
"when": "dvc.commands.available && dvc.project.available && dvc.studio.connected"
},
{
"command": "dvc.selectForCompare",
"when": "false"
Expand Down Expand Up @@ -1416,12 +1398,12 @@
},
{
"view": "dvc.views.studio",
"contents": "[$(plug) Connect](command:dvc.showConnect)",
"contents": "[$(plug) Connect](command:dvc.showSetup)",
"when": "!dvc.studio.connected"
},
{
"view": "dvc.views.studio",
"contents": "[$(settings-gear) Open Settings](command:dvc.showConnect)",
"contents": "[$(settings-gear) Open Settings](command:dvc.showSetup)",
"when": "dvc.studio.connected"
},
{
Expand Down
2 changes: 0 additions & 2 deletions extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ export enum RegisteredCommands {
SETUP_SHOW = 'dvc.showSetup',
SELECT_FOCUSED_PROJECTS = 'dvc.selectFocusedProjects',

CONNECT_SHOW = 'dvc.showConnect',
OPEN_STUDIO_SETTINGS = 'dvc.showStudioSettings',
ADD_STUDIO_ACCESS_TOKEN = 'dvc.addStudioAccessToken',
UPDATE_STUDIO_ACCESS_TOKEN = 'dvc.updateStudioAccessToken',
REMOVE_STUDIO_ACCESS_TOKEN = 'dvc.removeStudioAccessToken',
Expand Down
167 changes: 0 additions & 167 deletions extension/src/connect/index.ts

This file was deleted.

33 changes: 0 additions & 33 deletions extension/src/connect/register.ts

This file was deleted.

6 changes: 0 additions & 6 deletions extension/src/connect/webview/contract.ts

This file was deleted.

8 changes: 4 additions & 4 deletions extension/src/experiments/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Progress, commands } from 'vscode'
import { AvailableCommands, InternalCommands } from '../../commands/internal'
import { Toast } from '../../vscode/toast'
import { WorkspaceExperiments } from '../workspace'
import { Connect } from '../../connect'
import { Setup } from '../../setup'
import { RegisteredCommands } from '../../commands/external'

export const getBranchExperimentCommand =
Expand Down Expand Up @@ -108,11 +108,11 @@ export const getShareExperimentAsCommitCommand =
}

export const getShareExperimentToStudioCommand =
(internalCommands: InternalCommands, connect: Connect) =>
(internalCommands: InternalCommands, setup: Setup) =>
({ dvcRoot, id }: { dvcRoot: string; id: string }) => {
const studioAccessToken = connect.getStudioAccessToken()
const studioAccessToken = setup.getStudioAccessToken()
if (!studioAccessToken) {
return commands.executeCommand(RegisteredCommands.CONNECT_SHOW)
return commands.executeCommand(RegisteredCommands.SETUP_SHOW)
}

return internalCommands.executeCommand(
Expand Down
6 changes: 2 additions & 4 deletions extension/src/experiments/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Title } from '../../vscode/title'
import { Context, getDvcRootFromContext } from '../../vscode/context'
import { Setup } from '../../setup'
import { showSetupOrExecuteCommand } from '../../commands/util'
import { Connect } from '../../connect'

type ExperimentDetails = { dvcRoot: string; id: string }

Expand Down Expand Up @@ -331,8 +330,7 @@ const registerExperimentRunCommands = (
export const registerExperimentCommands = (
experiments: WorkspaceExperiments,
internalCommands: InternalCommands,
setup: Setup,
connect: Connect
setup: Setup
) => {
registerExperimentCwdCommands(experiments, internalCommands)
registerExperimentNameCommands(experiments, internalCommands)
Expand All @@ -348,7 +346,7 @@ export const registerExperimentCommands = (

internalCommands.registerExternalCommand(
RegisteredCommands.EXPERIMENT_VIEW_SHARE_TO_STUDIO,
getShareExperimentToStudioCommand(internalCommands, connect)
getShareExperimentToStudioCommand(internalCommands, setup)
)

internalCommands.registerExternalCliCommand(
Expand Down
15 changes: 3 additions & 12 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { DvcExecutor } from './cli/dvc/executor'
import { DvcRunner } from './cli/dvc/runner'
import { DvcReader } from './cli/dvc/reader'
import { Config } from './config'
import { Connect } from './connect'
import { registerConnectCommands } from './connect/register'
import { Context } from './context'
import { WorkspaceExperiments } from './experiments/workspace'
import { registerExperimentCommands } from './experiments/commands/register'
Expand Down Expand Up @@ -65,7 +63,6 @@ export class Extension extends Disposable {

private readonly resourceLocator: ResourceLocator
private readonly repositories: WorkspaceRepositories
private readonly connect: Connect
private readonly experiments: WorkspaceExperiments
private readonly plots: WorkspacePlots
private readonly setup: Setup
Expand Down Expand Up @@ -94,14 +91,10 @@ export class Extension extends Disposable {

const config = this.dispose.track(new Config())

this.connect = this.dispose.track(
new Connect(context, this.resourceLocator.dvcIcon)
)

this.gitExecutor = this.dispose.track(new GitExecutor())
this.gitReader = this.dispose.track(new GitReader())

const getStudioLiveShareToken = () => this.connect.getStudioLiveShareToken()
const getStudioLiveShareToken = () => this.setup.getStudioLiveShareToken()

this.dvcExecutor = this.dispose.track(
new DvcExecutor(config, getStudioLiveShareToken, cwd =>
Expand Down Expand Up @@ -189,6 +182,7 @@ export class Extension extends Disposable {

this.setup = this.dispose.track(
new Setup(
context,
config,
this.internalCommands,
this.experiments,
Expand All @@ -207,14 +201,11 @@ export class Extension extends Disposable {
)
)

registerConnectCommands(this.connect, this.internalCommands)

registerPatchCommand(this.internalCommands)
registerExperimentCommands(
this.experiments,
this.internalCommands,
this.setup,
this.connect
this.setup
)
registerPlotsCommands(this.plots, this.internalCommands, this.setup)
registerSetupCommands(this.setup, this.internalCommands)
Expand Down
2 changes: 1 addition & 1 deletion extension/src/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const showUnauthorized = async () => {
UserResponse.SHOW
)
if (response === UserResponse.SHOW) {
return commands.executeCommand(RegisteredCommands.CONNECT_SHOW)
return commands.executeCommand(RegisteredCommands.SETUP_SHOW)
}
}

Expand Down
Loading

0 comments on commit 5302a56

Please sign in to comment.