Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch add Studio access token to update when Studio is connected #3400

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@
"command": "dvc.addStudioAccessToken",
"category": "DVC"
},
{
"title": "Update Studio Access Token",
"command": "dvc.updateStudioAccessToken",
"category": "DVC"
},
{
"title": "Add",
"command": "dvc.addTarget",
Expand Down Expand Up @@ -635,7 +640,11 @@
},
{
"command": "dvc.addStudioAccessToken",
"when": "dvc.commands.available && dvc.project.available"
"when": "dvc.commands.available && dvc.project.available && !dvc.studio.connected"
},
{
"command": "dvc.updateStudioAccessToken",
"when": "dvc.commands.available && dvc.project.available && dvc.studio.connected"
},
{
"command": "dvc.addTarget",
Expand Down
1 change: 1 addition & 0 deletions extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export enum RegisteredCommands {
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',
EXPERIMENT_VIEW_SHARE_TO_STUDIO = 'dvc.views.experiments.shareExperimentToStudio'
}
5 changes: 5 additions & 0 deletions extension/src/connect/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const registerConnectCommands = (
() => connect.saveStudioAccessToken()
)

internalCommands.registerExternalCommand(
RegisteredCommands.UPDATE_STUDIO_ACCESS_TOKEN,
() => connect.saveStudioAccessToken()
)

internalCommands.registerExternalCommand(
RegisteredCommands.REMOVE_STUDIO_ACCESS_TOKEN,
() => connect.removeStudioAccessToken()
Expand Down
1 change: 1 addition & 0 deletions extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,6 @@ export interface IEventNamePropertyMapping {
[EventName.CONNECT_SHOW]: undefined
[EventName.OPEN_STUDIO_SETTINGS]: undefined
[EventName.ADD_STUDIO_ACCESS_TOKEN]: undefined
[EventName.UPDATE_STUDIO_ACCESS_TOKEN]: undefined
[EventName.REMOVE_STUDIO_ACCESS_TOKEN]: undefined
}
11 changes: 11 additions & 0 deletions webview/src/connect/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,16 @@ describe('App', () => {
type: MessageFromWebviewType.SET_STUDIO_SHARE_EXPERIMENTS_LIVE
})
})

it('should enable the user to update their studio token', () => {
const shareExperimentsLive = false
renderApp(true, shareExperimentsLive)
mockPostMessage.mockClear()
const button = screen.getByText('Update Token')
fireEvent.click(button)
expect(mockPostMessage).toHaveBeenCalledWith({
type: MessageFromWebviewType.SAVE_STUDIO_TOKEN
})
})
})
})
2 changes: 1 addition & 1 deletion webview/src/connect/components/Studio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const Settings: React.FC<{
appearance="primary"
isNested={false}
text={'Update Token'}
onClick={openStudio}
onClick={saveStudioToken}
/>
<Button
appearance="secondary"
Expand Down