From 006dbf6a33f08b7026fdeaefe06e597d1d44f3d2 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 17 Sep 2024 13:11:01 -0700 Subject: [PATCH 01/19] Add secret name to value map to home store --- .../webviews/homeView/src/stores/home.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/extensions/vscode/webviews/homeView/src/stores/home.ts b/extensions/vscode/webviews/homeView/src/stores/home.ts index 547c62492..551ca620c 100644 --- a/extensions/vscode/webviews/homeView/src/stores/home.ts +++ b/extensions/vscode/webviews/homeView/src/stores/home.ts @@ -10,6 +10,7 @@ import { Configuration, ContentRecordFile, ConfigurationError, + isConfigurationError, } from "../../../../src/api"; import { WebviewToHostMessageType } from "../../../../src/types/messages/webviewToHostMessages"; import { RPackage } from "../../../../src/api/types/packages"; @@ -27,6 +28,8 @@ export const useHomeStore = defineStore("home", () => { return credentials.value.sort((a, b) => a.name.localeCompare(b.name)); }); + const secrets = ref(new Map()); + const showDisabledOverlay = ref(false); const selectedContentRecord = ref(); @@ -57,6 +60,32 @@ export const useHomeStore = defineStore("home", () => { }, ); + watch( + [selectedContentRecord, selectedConfiguration], + ([contentRecord, config], [prevContentRecord, prevConfig]) => { + const result = new Map(); + + if (config === undefined || isConfigurationError(config)) { + return result; + } + + const isSameContentRecord = Boolean( + contentRecord?.saveName === prevContentRecord?.saveName, + ); + + config.configuration.secrets?.forEach((secret) => { + if (isSameContentRecord && secrets.value?.has(secret)) { + result.set(secret, secrets.value.get(secret)); + } else { + result.set(secret, undefined); + } + }); + + secrets.value = result; + }, + { immediate: true }, + ); + // Always use the content record as the source of truth for the // credential. Can be undefined if a Credential is not specified or found. const serverCredential = computed(() => { @@ -194,6 +223,7 @@ export const useHomeStore = defineStore("home", () => { configurationsInError, credentials, sortedCredentials, + secrets, selectedContentRecord, selectedConfiguration, serverCredential, From 78e8cc7eb5d4d656def8cb224032d5264a201d09 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 17 Sep 2024 13:11:29 -0700 Subject: [PATCH 02/19] Optionally send secrets in deploy msg --- .../src/types/messages/webviewToHostMessages.ts | 1 + extensions/vscode/src/views/homeView.ts | 12 +++--------- .../homeView/src/components/DeployButton.vue | 9 +++++++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/extensions/vscode/src/types/messages/webviewToHostMessages.ts b/extensions/vscode/src/types/messages/webviewToHostMessages.ts index dfe3702c4..cc1cf5835 100644 --- a/extensions/vscode/src/types/messages/webviewToHostMessages.ts +++ b/extensions/vscode/src/types/messages/webviewToHostMessages.ts @@ -96,6 +96,7 @@ export type DeployMsg = AnyWebviewToHostMessage< credentialName: string; configurationName: string; projectDir: string; + secrets?: Record; } >; diff --git a/extensions/vscode/src/views/homeView.ts b/extensions/vscode/src/views/homeView.ts index 59e02517a..f941451d0 100644 --- a/extensions/vscode/src/views/homeView.ts +++ b/extensions/vscode/src/views/homeView.ts @@ -248,6 +248,7 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { credentialName: string, configurationName: string, projectDir: string, + secrets?: Record, ) { try { const api = await useApi(); @@ -256,6 +257,7 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { credentialName, configurationName, projectDir, + secrets, ); deployProject(response.data.localId, this.stream); } catch (error: unknown) { @@ -270,6 +272,7 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { msg.content.credentialName, msg.content.configurationName, msg.content.projectDir, + msg.content.secrets, ); } @@ -1398,15 +1401,6 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { return await this.sendRefreshedFilesLists(); }, DebounceDelaysMS.file); - public initiatePublish(target: PublishProcessParams) { - this.initiateDeployment( - target.deploymentName, - target.credentialName, - target.configurationName, - target.projectDir, - ); - } - public async handleFileInitiatedDeploymentSelection(uri: Uri) { // Guide the user to create a new Deployment with that file as the entrypoint // if one doesn’t exist diff --git a/extensions/vscode/webviews/homeView/src/components/DeployButton.vue b/extensions/vscode/webviews/homeView/src/components/DeployButton.vue index c47e1319d..cf74b6475 100644 --- a/extensions/vscode/webviews/homeView/src/components/DeployButton.vue +++ b/extensions/vscode/webviews/homeView/src/components/DeployButton.vue @@ -46,6 +46,14 @@ const deploy = () => { return; } + // Only send up secrets that have values + const secrets: Record = {}; + home.secrets.forEach((value, name) => { + if (value) { + secrets[name] = value; + } + }); + hostConduit.sendMsg({ kind: WebviewToHostMessageType.DEPLOY, content: { @@ -53,6 +61,7 @@ const deploy = () => { configurationName: home.selectedConfiguration.configurationName, credentialName: home.serverCredential.name, projectDir: home.selectedContentRecord.projectDir, + secrets: secrets, }, }); }; From c5de584261cfedd1c990f7b1799a3f5a0a078492 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 17 Sep 2024 13:14:57 -0700 Subject: [PATCH 03/19] Add clearSecretValues action to store --- .../vscode/webviews/homeView/src/stores/home.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/extensions/vscode/webviews/homeView/src/stores/home.ts b/extensions/vscode/webviews/homeView/src/stores/home.ts index 551ca620c..278ddfdc7 100644 --- a/extensions/vscode/webviews/homeView/src/stores/home.ts +++ b/extensions/vscode/webviews/homeView/src/stores/home.ts @@ -215,6 +215,16 @@ export const useHomeStore = defineStore("home", () => { rVersion.value = version; }; + const clearSecretValues = () => { + const cleared = new Map(); + + secrets.value.forEach((_, key) => { + cleared.set(key, undefined); + }); + + secrets.value = cleared; + }; + return { showDisabledOverlay, publishInProgress, @@ -244,5 +254,6 @@ export const useHomeStore = defineStore("home", () => { updateParentViewSelectionState, updatePythonPackages, updateRPackages, + clearSecretValues, }; }); From 393bfc94e47b59680d9e6aff1d62745b8cbd2349 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 17 Sep 2024 13:20:49 -0700 Subject: [PATCH 04/19] Clear secrets on successful publish --- extensions/vscode/webviews/homeView/src/HostConduitService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/vscode/webviews/homeView/src/HostConduitService.ts b/extensions/vscode/webviews/homeView/src/HostConduitService.ts index 524e65447..0cb51d505 100644 --- a/extensions/vscode/webviews/homeView/src/HostConduitService.ts +++ b/extensions/vscode/webviews/homeView/src/HostConduitService.ts @@ -159,6 +159,7 @@ const onPublishStartMsg = () => { }; const onPublishFinishSuccessMsg = () => { const home = useHomeStore(); + home.clearSecretValues(); home.publishInProgress = false; home.lastContentRecordResult = `Last Deployment was Successful`; home.lastContentRecordMsg = ""; From e7b42795881a89183a89051f08052eb24040ab52 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 17 Sep 2024 15:30:56 -0700 Subject: [PATCH 05/19] Create secrets view --- .../vscode/webviews/homeView/src/App.vue | 2 + .../src/components/views/secrets/Secret.vue | 75 +++++++++++++++++++ .../src/components/views/secrets/Secrets.vue | 38 ++++++++++ 3 files changed, 115 insertions(+) create mode 100644 extensions/vscode/webviews/homeView/src/components/views/secrets/Secret.vue create mode 100644 extensions/vscode/webviews/homeView/src/components/views/secrets/Secrets.vue diff --git a/extensions/vscode/webviews/homeView/src/App.vue b/extensions/vscode/webviews/homeView/src/App.vue index 2da5dc518..81c243e14 100644 --- a/extensions/vscode/webviews/homeView/src/App.vue +++ b/extensions/vscode/webviews/homeView/src/App.vue @@ -6,6 +6,7 @@