feat: secret variables in environments (#3779)
Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
@@ -81,6 +81,7 @@ async function loadUserEnvironments() {
|
||||
runDispatchWithOutSyncing(() => {
|
||||
replaceEnvironments(
|
||||
environments.map(({ id, variables, name }) => ({
|
||||
v: 1,
|
||||
id,
|
||||
name,
|
||||
variables: JSON.parse(variables),
|
||||
@@ -164,6 +165,7 @@ function setupUserEnvironmentUpdatedSubscription() {
|
||||
if ((localIndex || localIndex == 0) && name) {
|
||||
runDispatchWithOutSyncing(() => {
|
||||
updateEnvironment(localIndex, {
|
||||
v: 1,
|
||||
id,
|
||||
name,
|
||||
variables: JSON.parse(variables),
|
||||
|
||||
@@ -20,10 +20,14 @@ import {
|
||||
deleteUserEnvironment,
|
||||
updateUserEnvironment,
|
||||
} from "./environments.api"
|
||||
import { SecretEnvironmentService } from "@hoppscotch/common/services/secret-environment.service"
|
||||
import { getService } from "@hoppscotch/common/modules/dioc"
|
||||
|
||||
export const environmentsMapper = createMapper<number, string>()
|
||||
export const globalEnvironmentMapper = createMapper<number, string>()
|
||||
|
||||
const secretEnvironmentService = getService(SecretEnvironmentService)
|
||||
|
||||
export const storeSyncDefinition: StoreSyncDefinitionOf<
|
||||
typeof environmentsStore
|
||||
> = {
|
||||
@@ -34,6 +38,12 @@ export const storeSyncDefinition: StoreSyncDefinitionOf<
|
||||
|
||||
if (E.isRight(res)) {
|
||||
const id = res.right.createUserEnvironment.id
|
||||
|
||||
secretEnvironmentService.updateSecretEnvironmentID(
|
||||
environmentsStore.value.environments[lastCreatedEnvIndex].id,
|
||||
id
|
||||
)
|
||||
|
||||
environmentsStore.value.environments[lastCreatedEnvIndex].id = id
|
||||
removeDuplicateEntry(id)
|
||||
}
|
||||
@@ -84,7 +94,6 @@ export const storeSyncDefinition: StoreSyncDefinitionOf<
|
||||
},
|
||||
updateEnvironment({ envIndex, updatedEnv }) {
|
||||
const backendId = environmentsStore.value.environments[envIndex].id
|
||||
|
||||
if (backendId) {
|
||||
updateUserEnvironment(backendId, updatedEnv)()
|
||||
}
|
||||
@@ -97,7 +106,12 @@ export const storeSyncDefinition: StoreSyncDefinitionOf<
|
||||
setGlobalVariables({ entries }) {
|
||||
const backendId = getGlobalVariableID()
|
||||
if (backendId) {
|
||||
updateUserEnvironment(backendId, { name: "", variables: entries })()
|
||||
updateUserEnvironment(backendId, {
|
||||
name: "",
|
||||
variables: entries,
|
||||
id: "",
|
||||
v: 1,
|
||||
})()
|
||||
}
|
||||
},
|
||||
clearGlobalVariables() {
|
||||
|
||||
Reference in New Issue
Block a user