diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json index fd5eb94dc..836446fb0 100644 --- a/packages/hoppscotch-common/locales/en.json +++ b/packages/hoppscotch-common/locales/en.json @@ -257,6 +257,7 @@ "error": { "browser_support_sse": "This browser doesn't seems to have Server Sent Events support.", "check_console_details": "Check console log for details.", + "check_how_to_add_origin": "Check how you can add an origin", "curl_invalid_format": "cURL is not formatted properly", "danger_zone": "Danger zone", "delete_account": "Your account is currently an owner in these teams:", @@ -277,6 +278,7 @@ "no_environments_to_export": "No environments to export. Please create an environment to get started.", "no_results_found": "No matches found", "page_not_found": "This page could not be found", + "please_install_extension": "Please install the extension and add origin to the extension.", "proxy_error": "Proxy error", "script_fail": "Could not execute pre-request script", "something_went_wrong": "Something went wrong", diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.ts index 786d61c73..5adf4db2c 100644 --- a/packages/hoppscotch-common/src/components.d.ts +++ b/packages/hoppscotch-common/src/components.d.ts @@ -1,11 +1,11 @@ -// generated by unplugin-vue-components -// We suggest you to commit this file into source control +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 -import '@vue/runtime-core' - export {} -declare module '@vue/runtime-core' { +declare module 'vue' { export interface GlobalComponents { AppActionHandler: typeof import('./components/app/ActionHandler.vue')['default'] AppAnnouncement: typeof import('./components/app/Announcement.vue')['default'] @@ -154,6 +154,7 @@ declare module '@vue/runtime-core' { IconLucideMinus: typeof import('~icons/lucide/minus')['default'] IconLucideSearch: typeof import('~icons/lucide/search')['default'] IconLucideUsers: typeof import('~icons/lucide/users')['default'] + InterceptorsErrorPlaceholder: typeof import('./components/interceptors/ErrorPlaceholder.vue')['default'] InterceptorsExtensionSubtitle: typeof import('./components/interceptors/ExtensionSubtitle.vue')['default'] LensesHeadersRenderer: typeof import('./components/lenses/HeadersRenderer.vue')['default'] LensesHeadersRendererEntry: typeof import('./components/lenses/HeadersRendererEntry.vue')['default'] @@ -218,5 +219,4 @@ declare module '@vue/runtime-core' { WorkspaceCurrent: typeof import('./components/workspace/Current.vue')['default'] WorkspaceSelector: typeof import('./components/workspace/Selector.vue')['default'] } - } diff --git a/packages/hoppscotch-common/src/components/graphql/Sidebar.vue b/packages/hoppscotch-common/src/components/graphql/Sidebar.vue index 84a15cfa9..c4a3e9dba 100644 --- a/packages/hoppscotch-common/src/components/graphql/Sidebar.vue +++ b/packages/hoppscotch-common/src/components/graphql/Sidebar.vue @@ -58,8 +58,8 @@ v-for="(field, index) in filteredQueryFields" :key="`field-${index}`" :gql-field="field" - @jump-to-type="handleJumpToType" class="p-4" + @jump-to-type="handleJumpToType" /> { const streamResult = await streamPromise requestCancelFunc.value = cancel - if (E.isRight(streamResult)) { subscribeToStream( streamResult.right, @@ -365,6 +364,20 @@ const newSendRequest = async () => { loading.value = false }, () => { + // TODO: Change this any to a proper type + const result = (streamResult.right as any).value + if ( + result.type === "network_fail" && + result.error?.error === "NO_PW_EXT_HOOK" + ) { + const errorResponse: HoppRESTResponse = { + type: "extension_error", + error: result.error.humanMessage.heading, + component: result.error.component, + req: result.req, + } + updateRESTResponse(errorResponse) + } loading.value = false } ) diff --git a/packages/hoppscotch-common/src/components/http/ResponseMeta.vue b/packages/hoppscotch-common/src/components/http/ResponseMeta.vue index 2d31fffeb..1bfb7d766 100644 --- a/packages/hoppscotch-common/src/components/http/ResponseMeta.vue +++ b/packages/hoppscotch-common/src/components/http/ResponseMeta.vue @@ -11,6 +11,12 @@ {{ t("state.loading") }} + + + + + + {{ t("error.please_install_extension") }} + + + {{ t("error.check_how_to_add_origin") }} + + here + + + + + + + + + + + + + + + {{ t("settings.extensions_use_toggle") }} + + + + + + + diff --git a/packages/hoppscotch-common/src/composables/stream.ts b/packages/hoppscotch-common/src/composables/stream.ts index b742a1bb3..32e26bedd 100644 --- a/packages/hoppscotch-common/src/composables/stream.ts +++ b/packages/hoppscotch-common/src/composables/stream.ts @@ -152,12 +152,14 @@ export function useStreamSubscriber(): { error?: (e: any) => void, complete?: () => void ) => { - const sub = stream.subscribe({ + let sub: Subscription | null = null + + sub = stream.subscribe({ next, error, complete: () => { if (complete) complete() - subs.splice(subs.indexOf(sub), 1) + if (sub) subs.splice(subs.indexOf(sub), 1) }, }) diff --git a/packages/hoppscotch-common/src/helpers/types/HoppRESTResponse.ts b/packages/hoppscotch-common/src/helpers/types/HoppRESTResponse.ts index bb5141d4c..0bc894342 100644 --- a/packages/hoppscotch-common/src/helpers/types/HoppRESTResponse.ts +++ b/packages/hoppscotch-common/src/helpers/types/HoppRESTResponse.ts @@ -1,4 +1,5 @@ import { HoppRESTRequest } from "@hoppscotch/data" +import { Component } from "vue" export type HoppRESTResponseHeader = { key: string; value: string } @@ -39,3 +40,9 @@ export type HoppRESTResponse = req: HoppRESTRequest } + | { + type: "extension_error" + error: string + component: Component + req: HoppRESTRequest + } diff --git a/packages/hoppscotch-common/src/platform/std/interceptors/extension.ts b/packages/hoppscotch-common/src/platform/std/interceptors/extension.ts index 99caa6095..07ed237a8 100644 --- a/packages/hoppscotch-common/src/platform/std/interceptors/extension.ts +++ b/packages/hoppscotch-common/src/platform/std/interceptors/extension.ts @@ -12,6 +12,7 @@ import { computed, readonly, ref } from "vue" import { browserIsChrome, browserIsFirefox } from "~/helpers/utils/userAgent" import SettingsExtension from "~/components/settings/Extension.vue" import InterceptorsExtensionSubtitle from "~/components/interceptors/ExtensionSubtitle.vue" +import InterceptorsErrorPlaceholder from "~/components/interceptors/ErrorPlaceholder.vue" export const defineSubscribableObject = (obj: T) => { const proxyObject = { @@ -217,6 +218,7 @@ export class ExtensionInterceptorService description: () => "Heading not found", }, error: "NO_PW_EXT_HOOK", + component: InterceptorsErrorPlaceholder, }) } diff --git a/packages/hoppscotch-common/src/services/interceptor.service.ts b/packages/hoppscotch-common/src/services/interceptor.service.ts index 4ed5b113e..8abf0f3f7 100644 --- a/packages/hoppscotch-common/src/services/interceptor.service.ts +++ b/packages/hoppscotch-common/src/services/interceptor.service.ts @@ -29,6 +29,7 @@ export type InterceptorError = description: (t: ReturnType) => string } error?: unknown + component?: Component } /**