Skip to content

Commit 427a181

Browse files
authored
chore: resolve global env in team env and tooltip UI update (hoppscotch#5187)
1 parent 594f078 commit 427a181

File tree

11 files changed

+303
-135
lines changed

11 files changed

+303
-135
lines changed

packages/hoppscotch-common/assets/scss/styles.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ a {
158158
@apply shadow-none #{!important};
159159
@apply fixed;
160160
@apply inline-flex;
161-
@apply -mt-7;
162161
}
163162
}
164163

@@ -169,7 +168,7 @@ a {
169168
@apply shadow;
170169

171170
.tippy-content {
172-
@apply flex;
171+
@apply flex flex-col;
173172
@apply text-tiny text-primary;
174173
@apply font-semibold;
175174
@apply px-2 py-1;

packages/hoppscotch-common/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,14 @@
407407
"added": "Environment addition",
408408
"create_new": "Create new environment",
409409
"created": "Environment created",
410+
"current_value": "Current value",
410411
"deleted": "Environment deletion",
411412
"duplicated": "Environment duplicated",
412413
"edit": "Edit Environment",
413414
"empty_variables": "No variables",
414415
"global": "Global",
415416
"global_variables": "Global variables",
417+
"initial_value": "Initial value",
416418
"import_or_create": "Import or create a environment",
417419
"invalid_name": "Please provide a name for the environment",
418420
"list": "Environment variables",

packages/hoppscotch-common/src/components/environments/Selector.vue

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,14 @@
239239
{{ t("environment.name") }}
240240
</span>
241241
<span
242-
class="min-w-[9rem] w-full truncate text-tiny font-semibold"
242+
class="min-w-[4rem] w-full truncate text-tiny font-semibold"
243243
>
244-
{{ t("environment.value") }}
244+
{{ t("environment.initial_value") }}
245+
</span>
246+
<span
247+
class="min-w-[4rem] w-full truncate text-tiny font-semibold"
248+
>
249+
{{ t("environment.current_value") }}
245250
</span>
246251
</div>
247252
<div
@@ -252,7 +257,13 @@
252257
<span class="min-w-[9rem] w-1/4 truncate text-secondaryLight">
253258
{{ variable.key }}
254259
</span>
255-
<span class="min-w-[9rem] w-full truncate text-secondaryLight">
260+
<span class="min-w-[4rem] w-full truncate text-secondaryLight">
261+
<template v-if="variable.secret"> ******** </template>
262+
<template v-else>
263+
{{ variable.initialValue }}
264+
</template>
265+
</span>
266+
<span class="min-w-[4rem] w-full truncate text-secondaryLight">
256267
<template v-if="variable.secret"> ******** </template>
257268
<template v-else>
258269
{{ variable.currentValue }}
@@ -297,9 +308,14 @@
297308
{{ t("environment.name") }}
298309
</span>
299310
<span
300-
class="min-w-[9rem] w-full truncate text-tiny font-semibold"
311+
class="min-w-[4rem] w-full truncate text-tiny font-semibold"
301312
>
302-
{{ t("environment.value") }}
313+
{{ t("environment.initial_value") }}
314+
</span>
315+
<span
316+
class="min-w-[4rem] w-full truncate text-tiny font-semibold"
317+
>
318+
{{ t("environment.current_value") }}
303319
</span>
304320
</div>
305321
<div
@@ -310,7 +326,13 @@
310326
<span class="min-w-[9rem] w-1/4 truncate text-secondaryLight">
311327
{{ variable.key }}
312328
</span>
313-
<span class="min-w-[9rem] w-full truncate text-secondaryLight">
329+
<span class="min-w-[4rem] w-full truncate text-secondaryLight">
330+
<template v-if="variable.secret"> ******** </template>
331+
<template v-else>
332+
{{ variable.initialValue }}
333+
</template>
334+
</span>
335+
<span class="min-w-[4rem] w-full truncate text-secondaryLight">
314336
<template v-if="variable.secret"> ******** </template>
315337
<template v-else>
316338
{{ variable.currentValue }}

packages/hoppscotch-common/src/components/environments/teams/Details.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ import * as A from "fp-ts/Array"
159159
import * as O from "fp-ts/Option"
160160
import * as TE from "fp-ts/TaskEither"
161161
import { flow, pipe } from "fp-ts/function"
162-
import { Environment, parseTemplateStringE } from "@hoppscotch/data"
162+
import {
163+
Environment,
164+
GlobalEnvironment,
165+
parseTemplateStringE,
166+
} from "@hoppscotch/data"
163167
import { refAutoReset } from "@vueuse/core"
164168
import { clone } from "lodash-es"
165169
import { useToast } from "@composables/toast"
@@ -181,6 +185,8 @@ import { useService } from "dioc/vue"
181185
import { SecretEnvironmentService } from "~/services/secret-environment.service"
182186
import { getEnvActionErrorMessage } from "~/helpers/error-messages"
183187
import { CurrentValueService } from "~/services/current-environment-value.service"
188+
import { useReadonlyStream } from "~/composables/stream"
189+
import { globalEnv$ } from "~/newstore/environments"
184190
185191
type EnvironmentVariable = {
186192
id: number
@@ -259,6 +265,8 @@ const vars = ref<EnvironmentVariable[]>([
259265
const secretEnvironmentService = useService(SecretEnvironmentService)
260266
const currentEnvironmentValueService = useService(CurrentValueService)
261267
268+
const globalEnv = useReadonlyStream(globalEnv$, {} as GlobalEnvironment)
269+
262270
const secretVars = computed(() =>
263271
pipe(
264272
vars.value,
@@ -302,6 +310,7 @@ const liveEnvs = computed(() => {
302310
}
303311
return [
304312
...vars.value.map((x) => ({ ...x.env, sourceEnv: editingName.value! })),
313+
...globalEnv.value.variables.map((x) => ({ ...x, sourceEnv: "Global" })),
305314
]
306315
})
307316

packages/hoppscotch-common/src/components/smart/EnvInput.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
v-else
1818
ref="editor"
1919
:placeholder="placeholder"
20-
class="flex flex-1 truncate"
20+
class="flex flex-1 truncate relative"
2121
:class="styles"
2222
@click="emit('click', $event)"
2323
@keydown="handleKeystroke"
@@ -85,7 +85,10 @@ import { inputTheme } from "~/helpers/editor/themes/baseTheme"
8585
import { HoppReactiveEnvPlugin } from "~/helpers/editor/extensions/HoppEnvironment"
8686
import { HoppPredefinedVariablesPlugin } from "~/helpers/editor/extensions/HoppPredefinedVariables"
8787
import { useReadonlyStream } from "@composables/stream"
88-
import { AggregateEnvironment, aggregateEnvs$ } from "~/newstore/environments"
88+
import {
89+
AggregateEnvironment,
90+
aggregateEnvsWithCurrentValue$,
91+
} from "~/newstore/environments"
8992
import { platform } from "~/platform"
9093
import { onClickOutside, useDebounceFn } from "@vueuse/core"
9194
import { InspectorResult } from "~/services/inspection"
@@ -365,9 +368,10 @@ watch(
365368
let clipboardEv: ClipboardEvent | null = null
366369
let pastedValue: string | null = null
367370
368-
const aggregateEnvs = useReadonlyStream(aggregateEnvs$, []) as Ref<
369-
AggregateEnvironment[]
370-
>
371+
const aggregateEnvs = useReadonlyStream(
372+
aggregateEnvsWithCurrentValue$,
373+
[]
374+
) as Ref<AggregateEnvironment[]>
371375
372376
const tabs = useService(RESTTabService)
373377
@@ -377,7 +381,7 @@ const envVars = computed(() => {
377381
const { key, secret } = x
378382
const currentValue = secret ? "********" : x.currentValue
379383
const initialValue = secret ? "********" : x.initialValue
380-
const sourceEnv = "sourceEnv" in x ? x.sourceEnv : null
384+
const sourceEnv = "sourceEnv" in x ? x.sourceEnv : ""
381385
return {
382386
key,
383387
currentValue,

0 commit comments

Comments
 (0)