From 52220d9a2e9a185f32d8eaf08bd3db801b000b6a Mon Sep 17 00:00:00 2001 From: nivedin Date: Mon, 19 Feb 2024 14:01:01 +0530 Subject: [PATCH] chore: add action for inscpector and tooltip env --- .../editor/extensions/HoppEnvironment.ts | 15 +++++--- .../inspectors/environment.inspector.ts | 34 ++++++++++++++----- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts b/packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts index 2f52aaab2..22374f204 100644 --- a/packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts +++ b/packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts @@ -125,11 +125,16 @@ const cursorTooltipField = (aggregateEnvs: AggregateEnvironment[]) => invokeActionType = "modals.my.environment.edit" } - invokeAction(invokeActionType, { - envName: tooltipEnv?.sourceEnv !== "Global" ? envName : "Global", - variableName: parsedEnvKey, - isSecret: tooltipEnv?.secret, - }) + if (tooltipEnv?.sourceEnv === "RequestVariable") { + restTabs.currentActiveTab.value.document.optionTabPreference = + "requestVariables" + } else { + invokeAction(invokeActionType, { + envName: tooltipEnv?.sourceEnv !== "Global" ? envName : "Global", + variableName: parsedEnvKey, + isSecret: tooltipEnv?.secret, + }) + } }) editIcon.innerHTML = `${IconEdit}` tooltip.appendChild(editIcon) diff --git a/packages/hoppscotch-common/src/services/inspection/inspectors/environment.inspector.ts b/packages/hoppscotch-common/src/services/inspection/inspectors/environment.inspector.ts index a5f6dc2b5..aeb909e88 100644 --- a/packages/hoppscotch-common/src/services/inspection/inspectors/environment.inspector.ts +++ b/packages/hoppscotch-common/src/services/inspection/inspectors/environment.inspector.ts @@ -154,7 +154,18 @@ export class EnvironmentInspectorService extends Service implements Inspector { const formattedExEnv = exEnv.slice(2, -2) const currentSelectedEnvironment = getCurrentEnvironment() - this.aggregateEnvsWithSecrets.value.forEach((env) => { + const currentTab = this.restTabs.currentActiveTab.value + + const environmentVariables = [ + ...currentTab.document.request.requestVariables.map((env) => ({ + ...env, + secret: false, + sourceEnv: "RequestVariable", + })), + ...this.aggregateEnvsWithSecrets.value, + ] + + environmentVariables.forEach((env) => { const hasSecretEnv = this.secretEnvs.hasSecretValue( env.sourceEnv !== "Global" ? currentSelectedEnvironment.id @@ -208,14 +219,19 @@ export class EnvironmentInspectorService extends Service implements Inspector { "inspections.environment.add_environment_value" ), apply: () => { - invokeAction(invokeActionType, { - envName: - env.sourceEnv !== "Global" - ? currentSelectedEnvironment.name - : "Global", - variableName: formattedExEnv, - isSecret: env.secret, - }) + if (env.sourceEnv === "RequestVariable") { + currentTab.document.optionTabPreference = + "requestVariables" + } else { + invokeAction(invokeActionType, { + envName: + env.sourceEnv !== "Global" + ? currentSelectedEnvironment.name + : "Global", + variableName: formattedExEnv, + isSecret: env.secret, + }) + } }, }, severity: 2,