fix: team secret env tooltip update bug

This commit is contained in:
nivedin
2024-02-12 13:22:06 +05:30
committed by Andrew Bastin
parent de4635df23
commit 1d7c0c0ba1
2 changed files with 19 additions and 2 deletions

View File

@@ -380,7 +380,7 @@ const saveEnvironment = async () => {
const variables = pipe( const variables = pipe(
filterdVariables, filterdVariables,
A.map((e) => A.map((e) =>
e.secret ? { key: e.key, secret: e.secret, value: undefined } : e e.secret ? { key: e.key, secret: e.secret ?? false, value: undefined } : e
) )
) )

View File

@@ -14,12 +14,15 @@ import {
AggregateEnvironment, AggregateEnvironment,
aggregateEnvsWithSecrets$, aggregateEnvsWithSecrets$,
getAggregateEnvsWithSecrets, getAggregateEnvsWithSecrets,
getCurrentEnvironment,
getSelectedEnvironmentType, getSelectedEnvironmentType,
} from "~/newstore/environments" } from "~/newstore/environments"
import { invokeAction } from "~/helpers/actions" import { invokeAction } from "~/helpers/actions"
import IconUser from "~icons/lucide/user?raw" import IconUser from "~icons/lucide/user?raw"
import IconUsers from "~icons/lucide/users?raw" import IconUsers from "~icons/lucide/users?raw"
import IconEdit from "~icons/lucide/edit?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 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_FOUND = "env-found"
const HOPP_ENV_HIGHLIGHT_NOT_FOUND = "env-not-found" const HOPP_ENV_HIGHLIGHT_NOT_FOUND = "env-not-found"
const secretEnvironmentService = getService(SecretEnvironmentService)
const cursorTooltipField = (aggregateEnvs: AggregateEnvironment[]) => const cursorTooltipField = (aggregateEnvs: AggregateEnvironment[]) =>
hoverTooltip( hoverTooltip(
(view, pos, side) => { (view, pos, side) => {
@@ -67,9 +72,21 @@ const cursorTooltipField = (aggregateEnvs: AggregateEnvironment[]) =>
const envName = tooltipEnv?.sourceEnv ?? "Choose an Environment" const envName = tooltipEnv?.sourceEnv ?? "Choose an Environment"
let envValue = "Not Found" 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 if (!tooltipEnv?.secret && tooltipEnv?.value) envValue = tooltipEnv.value
else if (tooltipEnv?.secret && tooltipEnv.value) { else if (tooltipEnv?.secret && !tooltipEnv.value && hasSecretEnv) {
envValue = "******" envValue = "******"
} else if (tooltipEnv?.secret && !tooltipEnv.value && !hasSecretEnv) {
envValue = "Empty"
} else if (!tooltipEnv?.sourceEnv) { } else if (!tooltipEnv?.sourceEnv) {
envValue = "Not Found" envValue = "Not Found"
} else if (!tooltipEnv?.value) { } else if (!tooltipEnv?.value) {