From a5fb7cb0d237440528a03014c9ff82d72016c220 Mon Sep 17 00:00:00 2001 From: Nivedin <53208152+nivedin@users.noreply.github.com> Date: Tue, 25 Nov 2025 23:06:02 +0530 Subject: [PATCH] fix: API documentation UI flow improvements (#5618) --- packages/hoppscotch-common/locales/en.json | 2 +- .../src/components/collections/Collection.vue | 15 ++++++++++++++- .../src/components/collections/Request.vue | 17 ++++++++++++++++- .../collections/documentation/Preview.vue | 5 ++--- .../documentation/PublishDocModal.vue | 1 + .../collections/documentation/index.vue | 8 +++----- .../collections/documentation/sections/Auth.vue | 2 +- .../documentation/sections/RequestBody.vue | 4 ++-- .../documentation/sections/Response.vue | 9 +++++---- .../src/components/collections/index.vue | 16 ---------------- .../src/components/documentation/Content.vue | 4 ++-- .../src/helpers/import-export/import/har.ts | 2 ++ .../import/insomnia/insomniaColl.ts | 6 ++++++ .../import-export/import/insomnia/types.ts | 7 ++++++- .../import-export/import/openapi/index.ts | 16 ++++++++++++++++ .../src/helpers/new-codegen/har.ts | 15 ++++++++++----- .../src/helpers/utils/EffectiveURL.ts | 3 +-- 17 files changed, 88 insertions(+), 44 deletions(-) diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json index d70c60f0..8066a1c6 100644 --- a/packages/hoppscotch-common/locales/en.json +++ b/packages/hoppscotch-common/locales/en.json @@ -530,7 +530,7 @@ "copy": "Copy response", "example_copied": "Response example copied to clipboard!", "example_copy_failed": "Failed to copy response example", - "headers": "Headers", + "headers": "Response Headers", "no_examples": "No response examples available", "title": "Response Examples" }, diff --git a/packages/hoppscotch-common/src/components/collections/Collection.vue b/packages/hoppscotch-common/src/components/collections/Collection.vue index 0628d95a..37bbf7b6 100644 --- a/packages/hoppscotch-common/src/components/collections/Collection.vue +++ b/packages/hoppscotch-common/src/components/collections/Collection.vue @@ -258,7 +258,7 @@ :shortcut="['I']" @click=" () => { - emit('open-documentation') + handleDocumentationAction() hide() } " @@ -683,6 +683,19 @@ const handleMockServerAction = () => { emit("create-mock-server") } +const handleDocumentationAction = () => { + const currentUser = platform.auth.getCurrentUser() + + if (!currentUser) { + // Show login modal if user is not authenticated + invokeAction("modals.login.toggle") + return + } + + // User is authenticated, proceed with opening documentation + emit("open-documentation") +} + const resetDragState = () => { dragging.value = false ordering.value = false diff --git a/packages/hoppscotch-common/src/components/collections/Request.vue b/packages/hoppscotch-common/src/components/collections/Request.vue index 488f5d59..628bd5d6 100644 --- a/packages/hoppscotch-common/src/components/collections/Request.vue +++ b/packages/hoppscotch-common/src/components/collections/Request.vue @@ -139,7 +139,7 @@ :shortcut="['I']" @click=" () => { - emit('open-request-documentation') + handleDocumentationAction() hide() } " @@ -241,6 +241,8 @@ import { } from "~/newstore/reordering" import { useReadonlyStream } from "~/composables/stream" import { getMethodLabelColorClassOf } from "~/helpers/rest/labelColoring" +import { platform } from "~/platform" +import { invokeAction } from "~/helpers/actions" type CollectionType = "my-collections" | "team-collections" @@ -455,6 +457,19 @@ const isRequestLoading = computed(() => { return false }) +const handleDocumentationAction = () => { + const currentUser = platform.auth.getCurrentUser() + + if (!currentUser) { + // Show login modal if user is not authenticated + invokeAction("modals.login.toggle") + return + } + + // User is authenticated, proceed with opening documentation + emit("open-request-documentation") +} + const resetDragState = () => { dragging.value = false ordering.value = false diff --git a/packages/hoppscotch-common/src/components/collections/documentation/Preview.vue b/packages/hoppscotch-common/src/components/collections/documentation/Preview.vue index 07891362..8d62885e 100644 --- a/packages/hoppscotch-common/src/components/collections/documentation/Preview.vue +++ b/packages/hoppscotch-common/src/components/collections/documentation/Preview.vue @@ -356,7 +356,7 @@ const scrollToItem = (id: string): void => { block: "start", }) } else { - console.log("Item not found:", id) + console.error("Item not found:", id) } }, 50) }) @@ -375,10 +375,9 @@ const scrollToItemByNameAndType = ( if (itemIndex !== -1) { const targetItem = props.allItems[itemIndex] - console.log(`Found ${type} at index: ${itemIndex}`) scrollToItem(targetItem.id) } else { - console.log(`${type} with name "${name}" not found in allItems`) + console.error(`${type} with name "${name}" not found in allItems`) } } diff --git a/packages/hoppscotch-common/src/components/collections/documentation/PublishDocModal.vue b/packages/hoppscotch-common/src/components/collections/documentation/PublishDocModal.vue index d4fae392..ca3aa07e 100644 --- a/packages/hoppscotch-common/src/components/collections/documentation/PublishDocModal.vue +++ b/packages/hoppscotch-common/src/components/collections/documentation/PublishDocModal.vue @@ -76,6 +76,7 @@
{{ formatJSON(body.body) }}
{{ body.body }}