fix: fill current value to existing value (#5109)
This commit is contained in:
parent
caeddac94c
commit
a325f2945d
12 changed files with 41 additions and 35 deletions
|
|
@ -45,7 +45,7 @@ const processVariables = (variable: Environment["variables"][number]) => {
|
||||||
currentValue:
|
currentValue:
|
||||||
"currentValue" in variable && variable.currentValue !== ""
|
"currentValue" in variable && variable.currentValue !== ""
|
||||||
? variable.currentValue
|
? variable.currentValue
|
||||||
: process.env[variable.key] || "",
|
: process.env[variable.key] || variable.initialValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return variable;
|
return variable;
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,7 @@ watch(
|
||||||
? "Global"
|
? "Global"
|
||||||
: workingEnvID.value,
|
: workingEnvID.value,
|
||||||
index
|
index
|
||||||
) ?? "",
|
) ?? e.currentValue,
|
||||||
initialValue: e.initialValue,
|
initialValue: e.initialValue,
|
||||||
secret: e.secret,
|
secret: e.secret,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,7 @@ watch(
|
||||||
props.editingEnvironment?.id ?? "",
|
props.editingEnvironment?.id ?? "",
|
||||||
index,
|
index,
|
||||||
e.secret
|
e.secret
|
||||||
) ?? "",
|
) ?? e.currentValue,
|
||||||
initialValue: e.initialValue,
|
initialValue: e.initialValue,
|
||||||
secret: e.secret,
|
secret: e.secret,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ const cursorTooltipField = (aggregateEnvs: AggregateEnvironment[]) =>
|
||||||
? currentSelectedEnvironment.id
|
? currentSelectedEnvironment.id
|
||||||
: "Global",
|
: "Global",
|
||||||
tooltipEnv?.key ?? ""
|
tooltipEnv?.key ?? ""
|
||||||
)?.currentValue ?? "")
|
)?.currentValue ?? tooltipEnv?.currentValue)
|
||||||
: tooltipEnv?.currentValue
|
: tooltipEnv?.currentValue
|
||||||
|
|
||||||
const hasSecretEnv = secretEnvironmentService.hasSecretValue(
|
const hasSecretEnv = secretEnvironmentService.hasSecretValue(
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ export const transformEnvironmentVariables = ({
|
||||||
key,
|
key,
|
||||||
secret,
|
secret,
|
||||||
initialValue,
|
initialValue,
|
||||||
currentValue: "",
|
currentValue: variable.secret ? "" : (variable.currentValue ?? ""),
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ export const insomniaEnvImporter = (contents: string[]) => {
|
||||||
([key, value]) => ({
|
([key, value]) => ({
|
||||||
key,
|
key,
|
||||||
initialValue: value,
|
initialValue: value,
|
||||||
currentValue: "",
|
currentValue: value,
|
||||||
secret: false,
|
secret: false,
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ export const postmanEnvImporter = (contents: string[]) => {
|
||||||
variables: values.map(({ key, value, type }) => ({
|
variables: values.map(({ key, value, type }) => ({
|
||||||
key,
|
key,
|
||||||
initialValue: value,
|
initialValue: value,
|
||||||
currentValue: "",
|
currentValue: value,
|
||||||
secret: type === "secret",
|
secret: type === "secret",
|
||||||
})),
|
})),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,13 @@ const unWrapEnvironments = (
|
||||||
currentValue: secretVar.value,
|
currentValue: secretVar.value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { ...globalVar, currentValue: currentVar?.currentValue ?? "" }
|
return {
|
||||||
|
...globalVar,
|
||||||
|
currentValue:
|
||||||
|
currentVar?.currentValue ??
|
||||||
|
globalVar.currentValue ??
|
||||||
|
globalVar.initialValue,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const resolvedSelectedWithSecrets = selected.variables.map(
|
const resolvedSelectedWithSecrets = selected.variables.map(
|
||||||
|
|
@ -57,7 +63,13 @@ const unWrapEnvironments = (
|
||||||
currentValue: secretVar.value,
|
currentValue: secretVar.value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { ...selectedVar, currentValue: currentVar?.currentValue ?? "" }
|
return {
|
||||||
|
...selectedVar,
|
||||||
|
currentValue:
|
||||||
|
currentVar?.currentValue ??
|
||||||
|
selectedVar.currentValue ??
|
||||||
|
selectedVar.initialValue,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -523,17 +523,16 @@ export function getAggregateEnvs() {
|
||||||
|
|
||||||
export function getAggregateEnvsWithSecrets() {
|
export function getAggregateEnvsWithSecrets() {
|
||||||
const currentEnv = getCurrentEnvironment()
|
const currentEnv = getCurrentEnvironment()
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...currentEnv.variables.map((x, index) => {
|
...currentEnv.variables.map((x, index) => {
|
||||||
let currentValue
|
let currentValue = x.currentValue
|
||||||
if (x.secret) {
|
if (x.secret) {
|
||||||
currentValue =
|
currentValue =
|
||||||
secretEnvironmentService.getSecretEnvironmentVariableValue(
|
secretEnvironmentService.getSecretEnvironmentVariableValue(
|
||||||
currentEnv.id,
|
currentEnv.id,
|
||||||
index
|
index
|
||||||
)
|
) ?? ""
|
||||||
} else {
|
|
||||||
currentValue = x.currentValue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return <AggregateEnvironment>{
|
return <AggregateEnvironment>{
|
||||||
|
|
@ -545,15 +544,13 @@ export function getAggregateEnvsWithSecrets() {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
...getGlobalVariables().map((x, index) => {
|
...getGlobalVariables().map((x, index) => {
|
||||||
let currentValue
|
let currentValue = x.currentValue
|
||||||
if (x.secret) {
|
if (x.secret) {
|
||||||
currentValue =
|
currentValue =
|
||||||
secretEnvironmentService.getSecretEnvironmentVariableValue(
|
secretEnvironmentService.getSecretEnvironmentVariableValue(
|
||||||
"Global",
|
"Global",
|
||||||
index
|
index
|
||||||
)
|
) ?? ""
|
||||||
} else {
|
|
||||||
currentValue = x.currentValue
|
|
||||||
}
|
}
|
||||||
return <AggregateEnvironment>{
|
return <AggregateEnvironment>{
|
||||||
key: x.key,
|
key: x.key,
|
||||||
|
|
@ -571,19 +568,17 @@ export const aggregateEnvsWithSecrets$: Observable<AggregateEnvironment[]> =
|
||||||
map(([selectedEnv, globalEnv]) => {
|
map(([selectedEnv, globalEnv]) => {
|
||||||
const results: AggregateEnvironment[] = []
|
const results: AggregateEnvironment[] = []
|
||||||
selectedEnv?.variables.map((x, index) => {
|
selectedEnv?.variables.map((x, index) => {
|
||||||
let currentValue
|
let currentValue = x.currentValue
|
||||||
if (x.secret) {
|
if (x.secret) {
|
||||||
currentValue =
|
currentValue =
|
||||||
secretEnvironmentService.getSecretEnvironmentVariableValue(
|
secretEnvironmentService.getSecretEnvironmentVariableValue(
|
||||||
selectedEnv.id,
|
selectedEnv.id,
|
||||||
index
|
index
|
||||||
)
|
) ?? ""
|
||||||
} else {
|
|
||||||
currentValue = x.currentValue
|
|
||||||
}
|
}
|
||||||
results.push({
|
results.push({
|
||||||
key: x.key,
|
key: x.key,
|
||||||
currentValue: currentValue ?? "",
|
currentValue: currentValue,
|
||||||
initialValue: x.initialValue,
|
initialValue: x.initialValue,
|
||||||
secret: x.secret,
|
secret: x.secret,
|
||||||
sourceEnv: selectedEnv.name,
|
sourceEnv: selectedEnv.name,
|
||||||
|
|
@ -591,19 +586,17 @@ export const aggregateEnvsWithSecrets$: Observable<AggregateEnvironment[]> =
|
||||||
})
|
})
|
||||||
|
|
||||||
globalEnv.variables.map((x, index) => {
|
globalEnv.variables.map((x, index) => {
|
||||||
let currentValue
|
let currentValue = x.currentValue
|
||||||
if (x.secret) {
|
if (x.secret) {
|
||||||
currentValue =
|
currentValue =
|
||||||
secretEnvironmentService.getSecretEnvironmentVariableValue(
|
secretEnvironmentService.getSecretEnvironmentVariableValue(
|
||||||
"Global",
|
"Global",
|
||||||
index
|
index
|
||||||
)
|
) ?? ""
|
||||||
} else {
|
|
||||||
currentValue = x.currentValue
|
|
||||||
}
|
}
|
||||||
results.push({
|
results.push({
|
||||||
key: x.key,
|
key: x.key,
|
||||||
currentValue: currentValue ?? "",
|
currentValue: currentValue,
|
||||||
initialValue: x.initialValue,
|
initialValue: x.initialValue,
|
||||||
secret: x.secret,
|
secret: x.secret,
|
||||||
sourceEnv: "Global",
|
sourceEnv: "Global",
|
||||||
|
|
|
||||||
|
|
@ -221,12 +221,13 @@ export class EnvironmentInspectorService extends Service implements Inspector {
|
||||||
env.key
|
env.key
|
||||||
)
|
)
|
||||||
|
|
||||||
const hasCurrentValue = this.currentEnvs.hasValue(
|
const hasCurrentValue =
|
||||||
env.sourceEnv !== "Global"
|
this.currentEnvs.hasValue(
|
||||||
? currentSelectedEnvironment.id
|
env.sourceEnv !== "Global"
|
||||||
: "Global",
|
? currentSelectedEnvironment.id
|
||||||
env.key
|
: "Global",
|
||||||
)
|
env.key
|
||||||
|
) || env.currentValue !== ""
|
||||||
|
|
||||||
if (env.key === formattedExEnv) {
|
if (env.key === formattedExEnv) {
|
||||||
if (env.secret ? !hasSecretEnv : !hasCurrentValue) {
|
if (env.secret ? !hasSecretEnv : !hasCurrentValue) {
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ export const translateToNewEnvironmentVariables = (
|
||||||
return {
|
return {
|
||||||
key: x.key,
|
key: x.key,
|
||||||
initialValue: x.initialValue ?? x.value ?? "",
|
initialValue: x.initialValue ?? x.value ?? "",
|
||||||
currentValue: "",
|
currentValue: x.currentValue ?? x.value ?? "",
|
||||||
secret: false,
|
secret: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export default defineVersion({
|
||||||
key,
|
key,
|
||||||
secret,
|
secret,
|
||||||
initialValue: secret ? "" : variable.value,
|
initialValue: secret ? "" : variable.value,
|
||||||
currentValue: "",
|
currentValue: secret ? "" : variable.value,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue