Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: environment tooltip update bug (#3819)
Nivedin45b532747ec0
diff --git a/packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts b/packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.tsindex 06ca1b012..9a1ab8a3a 100644--- a/packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts+++ b/packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts@@ -14,12 +14,15 @@ import {AggregateEnvironment,aggregateEnvsWithSecrets$,getAggregateEnvsWithSecrets,+ getCurrentEnvironment,getSelectedEnvironmentType,} from "~/newstore/environments"import { invokeAction } from "~/helpers/actions"import IconUser from "~icons/lucide/user?raw"import IconUsers from "~icons/lucide/users?raw"import IconEdit from "~icons/lucide/edit?raw"+import { SecretEnvironmentService } from "~/services/secret-environment.service"+import { getService } from "~/modules/dioc"const HOPP_ENVIRONMENT_REGEX = /(<<[a-zA-Z0-9-_]+>>)/g@@ -28,6 +31,8 @@ const HOPP_ENV_HIGHLIGHT =const HOPP_ENV_HIGHLIGHT_FOUND = "env-found"const HOPP_ENV_HIGHLIGHT_NOT_FOUND = "env-not-found"+const secretEnvironmentService = getService(SecretEnvironmentService)+const cursorTooltipField = (aggregateEnvs: AggregateEnvironment[]) =>hoverTooltip((view, pos, side) => {@@ -67,9 +72,21 @@ const cursorTooltipField = (aggregateEnvs: AggregateEnvironment[]) =>const envName = tooltipEnv?.sourceEnv ?? "Choose an Environment"let envValue = "Not Found"++ const currentSelectedEnvironment = getCurrentEnvironment()++ const hasSecretEnv = secretEnvironmentService.hasSecretValue(+ tooltipEnv?.sourceEnv !== "Global"+ ? currentSelectedEnvironment.id+ : "Global",+ tooltipEnv?.key ?? ""+ )+if (!tooltipEnv?.secret && tooltipEnv?.value) envValue = tooltipEnv.value- else if (tooltipEnv?.secret && tooltipEnv.value) {+ else if (tooltipEnv?.secret && hasSecretEnv) {envValue = "******"+ } else if (tooltipEnv?.secret && !hasSecretEnv) {+ envValue = "Empty"} else if (!tooltipEnv?.sourceEnv) {envValue = "Not Found"} else if (!tooltipEnv?.value) {diff --git a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.tsindex ff7e975ec..b5854403d 100644--- a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts+++ b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts@@ -374,6 +374,10 @@ const EnvironmentVariablesSchema = z.union([key: z.string(),secret: z.literal(true),}),+ z.object({+ key: z.string(),+ value: z.string(),+ }),])export const SECRET_ENVIRONMENT_VARIABLE_SCHEMA = z.union([@@ -405,7 +409,9 @@ const HoppTestResultSchema = z.object({additions: z.array(EnvironmentVariablesSchema),updations: z.array(- EnvironmentVariablesSchema.refine((x) => !x.secret).and(+ EnvironmentVariablesSchema.refine(+ (x) => "secret" in x && !x.secret+ ).and(z.object({previousValue: z.string(),})@@ -418,7 +424,9 @@ const HoppTestResultSchema = z.object({additions: z.array(EnvironmentVariablesSchema),updations: z.array(- EnvironmentVariablesSchema.refine((x) => !x.secret).and(+ EnvironmentVariablesSchema.refine(+ (x) => "secret" in x && !x.secret+ ).and(z.object({previousValue: z.string(),})