Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 committed Nov 7, 2023
1 parent 3426303 commit c81c90e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
11 changes: 2 additions & 9 deletions extension/src/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ export class Setup
new EventEmitter()
)

private readonly studioConnectionChanged: EventEmitter<void> =
this.dispose.track(new EventEmitter())

private readonly onDidChangeWorkspace: Event<void> =
this.workspaceChanged.event

Expand Down Expand Up @@ -146,16 +143,12 @@ export class Setup
}

this.collectWorkspaceScale = collectWorkspaceScale
this.onDidChangeStudioConnection = this.studioConnectionChanged.event

this.setCommandsAvailability(false)
this.setProjectAvailability()

this.studio = new Studio(
internalCommands,
this.studioConnectionChanged,
() => this.getCwd()
)
this.studio = new Studio(internalCommands, () => this.getCwd())
this.onDidChangeStudioConnection = this.studio.onDidChangeStudioConnection

this.webviewMessages = this.createWebviewMessageHandler()

Expand Down
2 changes: 1 addition & 1 deletion extension/src/setup/inputBox.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isStudioAccessToken } from './token'
import { isStudioAccessToken } from './studio'

export const validateTokenInput = (input: string | undefined) => {
if (!isStudioAccessToken(input)) {
Expand Down
27 changes: 19 additions & 8 deletions extension/src/setup/studio.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
import { EventEmitter } from 'vscode'
import { isStudioAccessToken } from './token'
import { Event, EventEmitter } from 'vscode'
import { AvailableCommands, InternalCommands } from '../commands/internal'
import { getFirstWorkspaceFolder } from '../vscode/workspaceFolders'
import { Args, ConfigKey, Flag } from '../cli/dvc/constants'
import { ContextKey, setContextValue } from '../vscode/context'
import { Disposable } from '../class/dispose'

export class Studio {
protected studioConnectionChanged: EventEmitter<void>
export const isStudioAccessToken = (text?: string): boolean => {
if (!text) {
return false
}
return text.startsWith('isat_') && text.length >= 53
}

export class Studio extends Disposable {
public readonly onDidChangeStudioConnection: Event<void>
private readonly studioConnectionChanged: EventEmitter<void> =
this.dispose.track(new EventEmitter())

private readonly getCwd: () => string | undefined
private readonly internalCommands: InternalCommands
private studioAccessToken: string | undefined = undefined
private studioIsConnected = false
private shareLiveToStudio: boolean | undefined = undefined
private readonly getCwd: () => string | undefined
private readonly internalCommands: InternalCommands

constructor(
internalCommands: InternalCommands,
studioConnectionChanged: EventEmitter<void>,
getCwd: () => string | undefined
) {
super()

this.internalCommands = internalCommands
this.studioConnectionChanged = studioConnectionChanged
this.getCwd = getCwd
this.onDidChangeStudioConnection = this.studioConnectionChanged.event
}

public getStudioAccessToken() {
Expand Down
6 changes: 0 additions & 6 deletions extension/src/setup/token.ts

This file was deleted.

0 comments on commit c81c90e

Please sign in to comment.