feat: request variables (#3825)
Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
This commit is contained in:
@@ -5,48 +5,51 @@
|
||||
render-inactive-tabs
|
||||
>
|
||||
<HoppSmartTab
|
||||
v-if="properties ? properties.includes('params') : true"
|
||||
v-if="properties?.includes('params') ?? true"
|
||||
:id="'params'"
|
||||
:label="`${t('tab.parameters')}`"
|
||||
:info="`${newActiveParamsCount$}`"
|
||||
:info="`${newActiveParamsCount}`"
|
||||
>
|
||||
<HttpParameters v-model="request.params" />
|
||||
<HttpParameters v-model="request.params" :envs="envs" />
|
||||
</HoppSmartTab>
|
||||
<HoppSmartTab
|
||||
v-if="properties ? properties.includes('bodyParams') : true"
|
||||
v-if="properties?.includes('bodyParams') ?? true"
|
||||
:id="'bodyParams'"
|
||||
:label="`${t('tab.body')}`"
|
||||
>
|
||||
<HttpBody
|
||||
v-model:headers="request.headers"
|
||||
v-model:body="request.body"
|
||||
:envs="envs"
|
||||
@change-tab="changeOptionTab"
|
||||
/>
|
||||
</HoppSmartTab>
|
||||
<HoppSmartTab
|
||||
v-if="properties ? properties.includes('headers') : true"
|
||||
v-if="properties?.includes('headers') ?? true"
|
||||
:id="'headers'"
|
||||
:label="`${t('tab.headers')}`"
|
||||
:info="`${newActiveHeadersCount$}`"
|
||||
:info="`${newActiveHeadersCount}`"
|
||||
>
|
||||
<HttpHeaders
|
||||
v-model="request"
|
||||
:inherited-properties="inheritedProperties"
|
||||
:envs="envs"
|
||||
@change-tab="changeOptionTab"
|
||||
/>
|
||||
</HoppSmartTab>
|
||||
<HoppSmartTab
|
||||
v-if="properties ? properties.includes('authorization') : true"
|
||||
v-if="properties?.includes('authorization') ?? true"
|
||||
:id="'authorization'"
|
||||
:label="`${t('tab.authorization')}`"
|
||||
>
|
||||
<HttpAuthorization
|
||||
v-model="request.auth"
|
||||
:inherited-properties="inheritedProperties"
|
||||
:envs="envs"
|
||||
/>
|
||||
</HoppSmartTab>
|
||||
<HoppSmartTab
|
||||
v-if="properties ? properties.includes('preRequestScript') : true"
|
||||
v-if="properties?.includes('preRequestScript') ?? true"
|
||||
:id="'preRequestScript'"
|
||||
:label="`${t('tab.pre_request_script')}`"
|
||||
:indicator="
|
||||
@@ -58,7 +61,7 @@
|
||||
<HttpPreRequestScript v-model="request.preRequestScript" />
|
||||
</HoppSmartTab>
|
||||
<HoppSmartTab
|
||||
v-if="properties ? properties.includes('tests') : true"
|
||||
v-if="properties?.includes('tests') ?? true"
|
||||
:id="'tests'"
|
||||
:label="`${t('tab.tests')}`"
|
||||
:indicator="
|
||||
@@ -67,6 +70,15 @@
|
||||
>
|
||||
<HttpTests v-model="request.testScript" />
|
||||
</HoppSmartTab>
|
||||
<HoppSmartTab
|
||||
v-if="properties?.includes('requestVariables') ?? true"
|
||||
:id="'requestVariables'"
|
||||
:label="`${t('tab.variables')}`"
|
||||
:info="`${newActiveRequestVariablesCount}`"
|
||||
:align-last="true"
|
||||
>
|
||||
<HttpRequestVariables v-model="request.requestVariables" />
|
||||
</HoppSmartTab>
|
||||
</HoppSmartTabs>
|
||||
</template>
|
||||
|
||||
@@ -77,6 +89,7 @@ import { useVModel } from "@vueuse/core"
|
||||
import { computed } from "vue"
|
||||
import { defineActionHandler } from "~/helpers/actions"
|
||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||
import { AggregateEnvironment } from "~/newstore/environments"
|
||||
|
||||
const VALID_OPTION_TABS = [
|
||||
"params",
|
||||
@@ -85,6 +98,7 @@ const VALID_OPTION_TABS = [
|
||||
"authorization",
|
||||
"preRequestScript",
|
||||
"tests",
|
||||
"requestVariables",
|
||||
] as const
|
||||
|
||||
export type RESTOptionTabs = (typeof VALID_OPTION_TABS)[number]
|
||||
@@ -98,6 +112,7 @@ const props = withDefaults(
|
||||
optionTab: RESTOptionTabs
|
||||
properties?: string[]
|
||||
inheritedProperties?: HoppInheritedProperty
|
||||
envs?: AggregateEnvironment[]
|
||||
}>(),
|
||||
{
|
||||
optionTab: "params",
|
||||
@@ -116,22 +131,27 @@ const changeOptionTab = (e: RESTOptionTabs) => {
|
||||
selectedOptionTab.value = e
|
||||
}
|
||||
|
||||
const newActiveParamsCount$ = computed(() => {
|
||||
const e = request.value.params.filter(
|
||||
(x) => x.active && (x.key !== "" || x.value !== "")
|
||||
const newActiveParamsCount = computed(() => {
|
||||
const count = request.value.params.filter(
|
||||
(x) => x.active && (x.key || x.value)
|
||||
).length
|
||||
|
||||
if (e === 0) return null
|
||||
return `${e}`
|
||||
return count ? count : null
|
||||
})
|
||||
|
||||
const newActiveHeadersCount$ = computed(() => {
|
||||
const e = request.value.headers.filter(
|
||||
(x) => x.active && (x.key !== "" || x.value !== "")
|
||||
const newActiveHeadersCount = computed(() => {
|
||||
const count = request.value.headers.filter(
|
||||
(x) => x.active && (x.key || x.value)
|
||||
).length
|
||||
|
||||
if (e === 0) return null
|
||||
return `${e}`
|
||||
return count ? count : null
|
||||
})
|
||||
|
||||
const newActiveRequestVariablesCount = computed(() => {
|
||||
const count = request.value.requestVariables.filter(
|
||||
(x) => x.active && (x.key || x.value)
|
||||
).length
|
||||
return count ? count : null
|
||||
})
|
||||
|
||||
defineActionHandler("request.open-tab", ({ tab }) => {
|
||||
|
||||
Reference in New Issue
Block a user