chore: update env tooltip updation mechanism

This commit is contained in:
nivedin
2024-02-19 21:15:02 +05:30
committed by Andrew Bastin
parent e01818444e
commit 7685409ee6
2 changed files with 48 additions and 52 deletions

View File

@@ -373,16 +373,27 @@ const envVars = computed(() => {
key: x.key, key: x.key,
sourceEnv: "source" in x ? x.source : null, sourceEnv: "source" in x ? x.source : null,
value: "********", value: "********",
secret: true,
} }
} }
return { return {
key: x.key, key: x.key,
value: x.value, value: x.value,
sourceEnv: "source" in x ? x.source : null, sourceEnv: "source" in x ? x.source : null,
secret: false,
} }
}) })
: [ : [
...tabs.currentActiveTab.value.document.request.requestVariables, ...tabs.currentActiveTab.value.document.request.requestVariables.map(
(x) => {
return {
key: x.key,
value: x.value,
sourceEnv: "RequestVariable",
secret: false,
}
}
),
...aggregateEnvs.value, ...aggregateEnvs.value,
] ]
}) })

View File

@@ -216,48 +216,43 @@ export class HoppEnvironmentPlugin {
subscribeToStream: StreamSubscriberFunc, subscribeToStream: StreamSubscriberFunc,
private editorView: Ref<EditorView | undefined> private editorView: Ref<EditorView | undefined>
) { ) {
// const aggregateEnvs = getAggregateEnvsWithSecrets()
// const currentTab = restTabs.currentActiveTab.value
// watch(
// currentTab.document.request.requestVariables,
// (reqVariables) => {
// console.log("reqVariables", reqVariables)
// this.envs = [
// ...reqVariables.map((variable) => ({
// key: variable.key,
// value: variable.value,
// sourceEnv: "RequestVariable",
// secret: false,
// })),
// ...aggregateEnvs,
// ]
// this.editorView.value?.dispatch({
// effects: this.compartment.reconfigure([
// cursorTooltipField(this.envs),
// environmentHighlightStyle(this.envs),
// ]),
// })
// },
// { immediate: true }
// )
const currentTab = restTabs.currentActiveTab.value
const aggregateEnvs = getAggregateEnvsWithSecrets() const aggregateEnvs = getAggregateEnvsWithSecrets()
const currentTab = restTabs.currentActiveTab.value
this.envs = [ watch(
...currentTab.document.request.requestVariables.map((variable) => ({ currentTab.document.request,
key: variable.key, (reqVariables) => {
value: variable.value, this.envs = [
sourceEnv: "RequestVariable", ...reqVariables.requestVariables.map((variable) => ({
secret: false, key: variable.key,
})), value: variable.value,
...aggregateEnvs, sourceEnv: "RequestVariable",
] secret: false,
})),
...aggregateEnvs,
]
this.editorView.value?.dispatch({
effects: this.compartment.reconfigure([
cursorTooltipField(this.envs),
environmentHighlightStyle(this.envs),
]),
})
},
{ immediate: true, deep: true }
)
subscribeToStream(aggregateEnvsWithSecrets$, (envs) => { subscribeToStream(aggregateEnvsWithSecrets$, (envs) => {
this.envs = envs this.envs = [
...currentTab.document.request.requestVariables.map((variable) => ({
key: variable.key,
value: variable.value,
sourceEnv: "RequestVariable",
secret: false,
})),
...envs,
]
this.editorView.value?.dispatch({ this.editorView.value?.dispatch({
effects: this.compartment.reconfigure([ effects: this.compartment.reconfigure([
cursorTooltipField(this.envs), cursorTooltipField(this.envs),
@@ -284,20 +279,10 @@ export class HoppReactiveEnvPlugin {
envsRef: Ref<AggregateEnvironment[]>, envsRef: Ref<AggregateEnvironment[]>,
private editorView: Ref<EditorView | undefined> private editorView: Ref<EditorView | undefined>
) { ) {
const currentTab = restTabs.currentActiveTab
watch( watch(
[currentTab.value.document.request, envsRef], envsRef,
([reqVariables, envs]) => { (envs) => {
this.envs = [ this.envs = envs
...reqVariables.requestVariables.map((variable) => ({
key: variable.key,
value: variable.value,
sourceEnv: "RequestVariable",
secret: false,
})),
...envs,
]
this.editorView.value?.dispatch({ this.editorView.value?.dispatch({
effects: this.compartment.reconfigure([ effects: this.compartment.reconfigure([