refactor: update share request flow (#3805)
This commit is contained in:
@@ -889,6 +889,7 @@
|
|||||||
"query": "Query",
|
"query": "Query",
|
||||||
"schema": "Schema",
|
"schema": "Schema",
|
||||||
"shared_requests": "Shared Requests",
|
"shared_requests": "Shared Requests",
|
||||||
|
"share_tab_request": "Share tab request",
|
||||||
"socketio": "Socket.IO",
|
"socketio": "Socket.IO",
|
||||||
"sse": "SSE",
|
"sse": "SSE",
|
||||||
"tests": "Tests",
|
"tests": "Tests",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
class="flex flex-col focus:outline-none"
|
class="flex flex-col focus:outline-none"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@keyup.r="renameAction?.$el.click()"
|
@keyup.r="renameAction?.$el.click()"
|
||||||
|
@keyup.s="shareRequestAction?.$el.click()"
|
||||||
@keyup.d="duplicateAction?.$el.click()"
|
@keyup.d="duplicateAction?.$el.click()"
|
||||||
@keyup.w="closeAction?.$el.click()"
|
@keyup.w="closeAction?.$el.click()"
|
||||||
@keyup.x="closeOthersAction?.$el.click()"
|
@keyup.x="closeOthersAction?.$el.click()"
|
||||||
@@ -58,6 +59,19 @@
|
|||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
<HoppSmartItem
|
||||||
|
ref="shareRequestAction"
|
||||||
|
:icon="IconShare2"
|
||||||
|
:label="t('tab.share_tab_request')"
|
||||||
|
:shortcut="['S']"
|
||||||
|
:new="true"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
emit('share-tab-request')
|
||||||
|
hide()
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
<HoppSmartItem
|
<HoppSmartItem
|
||||||
v-if="isRemovable"
|
v-if="isRemovable"
|
||||||
ref="closeAction"
|
ref="closeAction"
|
||||||
@@ -99,6 +113,7 @@ import IconXCircle from "~icons/lucide/x-circle"
|
|||||||
import IconXSquare from "~icons/lucide/x-square"
|
import IconXSquare from "~icons/lucide/x-square"
|
||||||
import IconFileEdit from "~icons/lucide/file-edit"
|
import IconFileEdit from "~icons/lucide/file-edit"
|
||||||
import IconCopy from "~icons/lucide/copy"
|
import IconCopy from "~icons/lucide/copy"
|
||||||
|
import IconShare2 from "~icons/lucide/share-2"
|
||||||
import { HoppTab } from "~/services/tab"
|
import { HoppTab } from "~/services/tab"
|
||||||
import { HoppRESTDocument } from "~/helpers/rest/document"
|
import { HoppRESTDocument } from "~/helpers/rest/document"
|
||||||
|
|
||||||
@@ -114,6 +129,7 @@ const emit = defineEmits<{
|
|||||||
(event: "close-tab"): void
|
(event: "close-tab"): void
|
||||||
(event: "close-other-tabs"): void
|
(event: "close-other-tabs"): void
|
||||||
(event: "duplicate-tab"): void
|
(event: "duplicate-tab"): void
|
||||||
|
(event: "share-tab-request"): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const tippyActions = ref<TippyComponent | null>(null)
|
const tippyActions = ref<TippyComponent | null>(null)
|
||||||
@@ -123,4 +139,5 @@ const renameAction = ref<HTMLButtonElement | null>(null)
|
|||||||
const closeAction = ref<HTMLButtonElement | null>(null)
|
const closeAction = ref<HTMLButtonElement | null>(null)
|
||||||
const closeOthersAction = ref<HTMLButtonElement | null>(null)
|
const closeOthersAction = ref<HTMLButtonElement | null>(null)
|
||||||
const duplicateAction = ref<HTMLButtonElement | null>(null)
|
const duplicateAction = ref<HTMLButtonElement | null>(null)
|
||||||
|
const shareRequestAction = ref<HTMLButtonElement | null>(null)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
v-tippy="{ theme: 'tooltip', delay: [500, 20] }"
|
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"
|
class="flex items-center justify-center flex-1 min-w-0 py-2 cursor-pointer pointer-events-auto"
|
||||||
:title="`${timeStamp}`"
|
:title="`${timeStamp}`"
|
||||||
@click="openInNewTab"
|
@click="customizeSharedRequest()"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="flex items-center justify-center w-16 px-2 truncate pointer-events-none"
|
class="flex items-center justify-center w-16 px-2 truncate pointer-events-none"
|
||||||
@@ -128,7 +128,6 @@ const emit = defineEmits<{
|
|||||||
embedProperties?: string | null
|
embedProperties?: string | null
|
||||||
): void
|
): void
|
||||||
(e: "delete-shared-request", codeID: string): void
|
(e: "delete-shared-request", codeID: string): void
|
||||||
(e: "open-new-tab", request: HoppRESTRequest): void
|
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const tippyActions = ref<TippyComponent | null>(null)
|
const tippyActions = ref<TippyComponent | null>(null)
|
||||||
@@ -145,10 +144,6 @@ const requestLabelColor = computed(() =>
|
|||||||
getMethodLabelColorClassOf(parseRequest.value)
|
getMethodLabelColorClassOf(parseRequest.value)
|
||||||
)
|
)
|
||||||
|
|
||||||
const openInNewTab = () => {
|
|
||||||
emit("open-new-tab", parseRequest.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const customizeSharedRequest = () => {
|
const customizeSharedRequest = () => {
|
||||||
const embedProperties = props.request.properties
|
const embedProperties = props.request.properties
|
||||||
emit(
|
emit(
|
||||||
|
|||||||
@@ -9,8 +9,14 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="sticky top-sidebarPrimaryStickyFold z-10 flex flex-1 flex-shrink-0 justify-end overflow-x-auto border-b border-dividerLight bg-primary"
|
class="sticky top-sidebarPrimaryStickyFold z-10 flex flex-1 flex-shrink-0 justify-between overflow-x-auto border-b border-dividerLight bg-primary"
|
||||||
>
|
>
|
||||||
|
<HoppButtonSecondary
|
||||||
|
:label="t('action.new')"
|
||||||
|
:icon="IconPlus"
|
||||||
|
class="!rounded-none"
|
||||||
|
@click="shareRequest()"
|
||||||
|
/>
|
||||||
<HoppButtonSecondary
|
<HoppButtonSecondary
|
||||||
v-tippy="{ theme: 'tooltip' }"
|
v-tippy="{ theme: 'tooltip' }"
|
||||||
to="https://docs.hoppscotch.io/documentation/features/widgets"
|
to="https://docs.hoppscotch.io/documentation/features/widgets"
|
||||||
@@ -47,7 +53,6 @@
|
|||||||
:request="request"
|
:request="request"
|
||||||
@customize-shared-request="customizeSharedRequest"
|
@customize-shared-request="customizeSharedRequest"
|
||||||
@delete-shared-request="deleteSharedRequest"
|
@delete-shared-request="deleteSharedRequest"
|
||||||
@open-new-tab="openInNewTab"
|
|
||||||
/>
|
/>
|
||||||
<HoppSmartIntersection
|
<HoppSmartIntersection
|
||||||
v-if="hasMoreSharedRequests"
|
v-if="hasMoreSharedRequests"
|
||||||
@@ -70,7 +75,15 @@
|
|||||||
:alt="`${t('empty.shared_requests')}`"
|
:alt="`${t('empty.shared_requests')}`"
|
||||||
:text="t('empty.shared_requests')"
|
:text="t('empty.shared_requests')"
|
||||||
@drop.stop
|
@drop.stop
|
||||||
|
>
|
||||||
|
<template #body>
|
||||||
|
<HoppButtonPrimary
|
||||||
|
:label="t('add.new')"
|
||||||
|
:icon="IconPlus"
|
||||||
|
@click="shareRequest()"
|
||||||
/>
|
/>
|
||||||
|
</template>
|
||||||
|
</HoppSmartPlaceholder>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<HoppSmartConfirmModal
|
<HoppSmartConfirmModal
|
||||||
@@ -95,6 +108,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import IconHelpCircle from "~icons/lucide/help-circle"
|
import IconHelpCircle from "~icons/lucide/help-circle"
|
||||||
|
import IconPlus from "~icons/lucide/plus"
|
||||||
import { useI18n } from "~/composables/i18n"
|
import { useI18n } from "~/composables/i18n"
|
||||||
import ShortcodeListAdapter from "~/helpers/shortcode/ShortcodeListAdapter"
|
import ShortcodeListAdapter from "~/helpers/shortcode/ShortcodeListAdapter"
|
||||||
import { useReadonlyStream } from "~/composables/stream"
|
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) => {
|
const deleteSharedRequest = (codeID: string) => {
|
||||||
if (currentUser.value) {
|
if (currentUser.value) {
|
||||||
sharedRequestID.value = codeID
|
sharedRequestID.value = codeID
|
||||||
@@ -434,13 +459,6 @@ const copySharedRequest = (payload: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const openInNewTab = (request: HoppRESTRequest) => {
|
|
||||||
restTab.createNewTab({
|
|
||||||
isDirty: false,
|
|
||||||
request,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const resolveConfirmModal = (title: string | null) => {
|
const resolveConfirmModal = (title: string | null) => {
|
||||||
if (title === `${t("confirm.remove_shared_request")}`) onDeleteSharedRequest()
|
if (title === `${t("confirm.remove_shared_request")}`) onDeleteSharedRequest()
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
@close-tab="removeTab(tab.id)"
|
@close-tab="removeTab(tab.id)"
|
||||||
@close-other-tabs="closeOtherTabsAction(tab.id)"
|
@close-other-tabs="closeOtherTabsAction(tab.id)"
|
||||||
@duplicate-tab="duplicateTab(tab.id)"
|
@duplicate-tab="duplicateTab(tab.id)"
|
||||||
|
@share-tab-request="shareTabRequest(tab.id)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
@@ -145,6 +146,11 @@ const tabs = useService(RESTTabService)
|
|||||||
|
|
||||||
const currentTabID = tabs.currentTabID
|
const currentTabID = tabs.currentTabID
|
||||||
|
|
||||||
|
const currentUser = useReadonlyStream(
|
||||||
|
platform.auth.getCurrentUserStream(),
|
||||||
|
platform.auth.getCurrentUser()
|
||||||
|
)
|
||||||
|
|
||||||
type PopupDetails = {
|
type PopupDetails = {
|
||||||
show: boolean
|
show: boolean
|
||||||
position: {
|
position: {
|
||||||
@@ -308,6 +314,19 @@ const onSaveModalClose = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const shareTabRequest = (tabID: string) => {
|
||||||
|
const tab = tabs.getTabRef(tabID)
|
||||||
|
if (tab.value) {
|
||||||
|
if (currentUser.value) {
|
||||||
|
invokeAction("share.request", {
|
||||||
|
request: tab.value.document.request,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
invokeAction("modals.login.toggle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const syncTabState = () => {
|
const syncTabState = () => {
|
||||||
if (tabStateForSync.value)
|
if (tabStateForSync.value)
|
||||||
tabs.loadTabsFromPersistedState(tabStateForSync.value)
|
tabs.loadTabsFromPersistedState(tabStateForSync.value)
|
||||||
|
|||||||
Reference in New Issue
Block a user