diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json index 0125cc37e..301448130 100644 --- a/packages/hoppscotch-common/locales/en.json +++ b/packages/hoppscotch-common/locales/en.json @@ -889,6 +889,7 @@ "query": "Query", "schema": "Schema", "shared_requests": "Shared Requests", + "share_tab_request": "Share tab request", "socketio": "Socket.IO", "sse": "SSE", "tests": "Tests", diff --git a/packages/hoppscotch-common/src/components/http/TabHead.vue b/packages/hoppscotch-common/src/components/http/TabHead.vue index 17a65c10e..22ff669a8 100644 --- a/packages/hoppscotch-common/src/components/http/TabHead.vue +++ b/packages/hoppscotch-common/src/components/http/TabHead.vue @@ -29,6 +29,7 @@ class="flex flex-col focus:outline-none" tabindex="0" @keyup.r="renameAction?.$el.click()" + @keyup.s="shareRequestAction?.$el.click()" @keyup.d="duplicateAction?.$el.click()" @keyup.w="closeAction?.$el.click()" @keyup.x="closeOthersAction?.$el.click()" @@ -58,6 +59,19 @@ } " /> + () const tippyActions = ref(null) @@ -123,4 +139,5 @@ const renameAction = ref(null) const closeAction = ref(null) const closeOthersAction = ref(null) const duplicateAction = ref(null) +const shareRequestAction = ref(null) diff --git a/packages/hoppscotch-common/src/components/share/Request.vue b/packages/hoppscotch-common/src/components/share/Request.vue index d62742e5e..44a04c473 100644 --- a/packages/hoppscotch-common/src/components/share/Request.vue +++ b/packages/hoppscotch-common/src/components/share/Request.vue @@ -7,7 +7,7 @@ v-tippy="{ theme: 'tooltip', delay: [500, 20] }" class="flex items-center justify-center flex-1 min-w-0 py-2 cursor-pointer pointer-events-auto" :title="`${timeStamp}`" - @click="openInNewTab" + @click="customizeSharedRequest()" > () const tippyActions = ref(null) @@ -145,10 +144,6 @@ const requestLabelColor = computed(() => getMethodLabelColorClassOf(parseRequest.value) ) -const openInNewTab = () => { - emit("open-new-tab", parseRequest.value) -} - const customizeSharedRequest = () => { const embedProperties = props.request.properties emit( diff --git a/packages/hoppscotch-common/src/components/share/index.vue b/packages/hoppscotch-common/src/components/share/index.vue index 50b7f5c70..bfdbb64c0 100644 --- a/packages/hoppscotch-common/src/components/share/index.vue +++ b/packages/hoppscotch-common/src/components/share/index.vue @@ -9,8 +9,14 @@ />
+ + > + +
import IconHelpCircle from "~icons/lucide/help-circle" +import IconPlus from "~icons/lucide/plus" import { useI18n } from "~/composables/i18n" import ShortcodeListAdapter from "~/helpers/shortcode/ShortcodeListAdapter" import { useReadonlyStream } from "~/composables/stream" @@ -270,6 +284,17 @@ onAuthEvent((ev) => { } }) +const shareRequest = () => { + if (currentUser.value) { + const tab = restTab.currentActiveTab + invokeAction("share.request", { + request: tab.value.document.request, + }) + } else { + invokeAction("modals.login.toggle") + } +} + const deleteSharedRequest = (codeID: string) => { if (currentUser.value) { sharedRequestID.value = codeID @@ -434,13 +459,6 @@ const copySharedRequest = (payload: { } } -const openInNewTab = (request: HoppRESTRequest) => { - restTab.createNewTab({ - isDirty: false, - request, - }) -} - const resolveConfirmModal = (title: string | null) => { if (title === `${t("confirm.remove_shared_request")}`) onDeleteSharedRequest() else { diff --git a/packages/hoppscotch-common/src/pages/index.vue b/packages/hoppscotch-common/src/pages/index.vue index 5c9078862..ecd169105 100644 --- a/packages/hoppscotch-common/src/pages/index.vue +++ b/packages/hoppscotch-common/src/pages/index.vue @@ -26,6 +26,7 @@ @close-tab="removeTab(tab.id)" @close-other-tabs="closeOtherTabsAction(tab.id)" @duplicate-tab="duplicateTab(tab.id)" + @share-tab-request="shareTabRequest(tab.id)" />