From a227af05d97e5dd154d779aeb2287507749cd1df Mon Sep 17 00:00:00 2001 From: Jesvin Jose Date: Wed, 8 Feb 2023 10:29:18 +0530 Subject: [PATCH] feat: active tab no longer resets after request (#2917) Co-authored-by: Andrew Bastin Closes https://github.com/hoppscotch/hoppscotch/issues/2080 --- .../src/components/http/Response.vue | 36 +++--- .../src/components/http/ResponseMeta.vue | 4 +- .../src/components/lenses/HeadersRenderer.vue | 4 +- .../lenses/HeadersRendererEntry.vue | 4 +- .../lenses/ResponseBodyRenderer.vue | 113 +++++++++++------- .../src/helpers/types/HoppRESTResponse.ts | 6 +- 6 files changed, 93 insertions(+), 74 deletions(-) diff --git a/packages/hoppscotch-common/src/components/http/Response.vue b/packages/hoppscotch-common/src/components/http/Response.vue index f83afcc9d..2f6c75152 100644 --- a/packages/hoppscotch-common/src/components/http/Response.vue +++ b/packages/hoppscotch-common/src/components/http/Response.vue @@ -3,40 +3,32 @@ - diff --git a/packages/hoppscotch-common/src/components/http/ResponseMeta.vue b/packages/hoppscotch-common/src/components/http/ResponseMeta.vue index 79a71b33e..f2d1f139a 100644 --- a/packages/hoppscotch-common/src/components/http/ResponseMeta.vue +++ b/packages/hoppscotch-common/src/components/http/ResponseMeta.vue @@ -107,7 +107,7 @@ const t = useI18n() const colorMode = useColorMode() const props = defineProps<{ - response: HoppRESTResponse + response: HoppRESTResponse | null }>() /** @@ -118,6 +118,7 @@ const props = defineProps<{ */ const readableResponseSize = computed(() => { if ( + props.response === null || props.response.type === "loading" || props.response.type === "network_fail" || props.response.type === "script_fail" || @@ -135,6 +136,7 @@ const readableResponseSize = computed(() => { const statusCategory = computed(() => { if ( + props.response === null || props.response.type === "loading" || props.response.type === "network_fail" || props.response.type === "script_fail" || diff --git a/packages/hoppscotch-common/src/components/lenses/HeadersRenderer.vue b/packages/hoppscotch-common/src/components/lenses/HeadersRenderer.vue index 5f1963423..d853e2a8e 100644 --- a/packages/hoppscotch-common/src/components/lenses/HeadersRenderer.vue +++ b/packages/hoppscotch-common/src/components/lenses/HeadersRenderer.vue @@ -27,18 +27,18 @@ diff --git a/packages/hoppscotch-common/src/helpers/types/HoppRESTResponse.ts b/packages/hoppscotch-common/src/helpers/types/HoppRESTResponse.ts index 811c325aa..b43f6f6fd 100644 --- a/packages/hoppscotch-common/src/helpers/types/HoppRESTResponse.ts +++ b/packages/hoppscotch-common/src/helpers/types/HoppRESTResponse.ts @@ -1,10 +1,12 @@ import { HoppRESTRequest } from "@hoppscotch/data" +export type HoppRESTResponseHeader = { key: string; value: string } + export type HoppRESTResponse = | { type: "loading"; req: HoppRESTRequest } | { type: "fail" - headers: { key: string; value: string }[] + headers: HoppRESTResponseHeader[] body: ArrayBuffer statusCode: number @@ -27,7 +29,7 @@ export type HoppRESTResponse = } | { type: "success" - headers: { key: string; value: string }[] + headers: HoppRESTResponseHeader[] body: ArrayBuffer statusCode: number meta: {