diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 3c842af40..6680c69aa 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -58,6 +58,12 @@ "icon": "$(refresh)", "category": "Posit Publisher" }, + { + "command": "posit.publisher.homeView.removeSecret", + "title": "Remove Secret from Configuration", + "icon": "$(trash)", + "category": "Posit Publisher" + }, { "command": "posit.publisher.files.refresh", "title": "Refresh Deployment Files", @@ -247,6 +253,10 @@ "command": "posit.publisher.homeView.refreshCredentials", "when": "posit.publish.state == 'initialized'" }, + { + "command": "posit.publisher.homeView.removeSecret", + "when": "false" + }, { "command": "posit.publisher.files.refresh", "when": "posit.publish.state == 'initialized'" @@ -346,6 +356,10 @@ { "command": "posit.publisher.homeView.deleteCredential", "when": "webviewId == 'posit.publisher.homeView' && webviewSection == 'credentials-tree-item'" + }, + { + "command": "posit.publisher.homeView.removeSecret", + "when": "webviewId == 'posit.publisher.homeView' && webviewSection == 'secrets-tree-item'" } ] }, diff --git a/extensions/vscode/src/constants.ts b/extensions/vscode/src/constants.ts index 97148df39..24febcd94 100644 --- a/extensions/vscode/src/constants.ts +++ b/extensions/vscode/src/constants.ts @@ -73,6 +73,7 @@ const homeViewCommands = { AddCredential: "posit.publisher.homeView.addCredential", DeleteCredential: "posit.publisher.homeView.deleteCredential", RefreshCredentials: "posit.publisher.homeView.refreshCredentials", + RemoveSecret: "posit.publisher.homeView.removeSecret", EditCurrentConfiguration: "posit.publisher.homeView.edit.Configuration", // Added automatically by VSCode with view registration Focus: "posit.publisher.homeView.focus", diff --git a/extensions/vscode/src/views/homeView.ts b/extensions/vscode/src/views/homeView.ts index 75124ba7e..939be385b 100644 --- a/extensions/vscode/src/views/homeView.ts +++ b/extensions/vscode/src/views/homeView.ts @@ -936,6 +936,30 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { } } + public removeSecret = async (context: { name: string }) => { + const activeConfig = await this.state.getSelectedConfiguration(); + if (activeConfig === undefined) { + console.error("homeView::removeSecret: No active configuration."); + return; + } + + try { + await showProgress("Removing Secret", Views.HomeView, async () => { + const api = await useApi(); + await api.secrets.remove( + activeConfig.configurationName, + context.name, + activeConfig.projectDir, + ); + }); + } catch (error: unknown) { + const summary = getSummaryStringFromError("removeSecret", error); + window.showInformationMessage( + `Failed to remove secret from configuration. ${summary}`, + ); + } + }; + private async showNewCredential() { return await commands.executeCommand(Commands.HomeView.AddCredential); } @@ -1789,6 +1813,13 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { }), ); + this.context.subscriptions.push( + commands.registerCommand( + Commands.HomeView.RemoveSecret, + this.removeSecret, + ), + ); + this.context.subscriptions.push( commands.registerCommand(Commands.HomeView.RefreshCredentials, () => useBus().trigger("refreshCredentials", undefined), diff --git a/extensions/vscode/webviews/homeView/src/components/views/secrets/Secret.vue b/extensions/vscode/webviews/homeView/src/components/views/secrets/Secret.vue index 31221d9af..550c2c6cc 100644 --- a/extensions/vscode/webviews/homeView/src/components/views/secrets/Secret.vue +++ b/extensions/vscode/webviews/homeView/src/components/views/secrets/Secret.vue @@ -6,6 +6,7 @@ :list-style="secretValue || isEditing ? 'default' : 'deemphasized'" :tooltip="tooltip" align-icon-with-twisty + :data-vscode-context="vscodeContext" >