chore: add fallback url if endpoint is empty while saving and sharing req
This commit is contained in:
@@ -86,6 +86,8 @@ import { platform } from "~/platform"
|
|||||||
import { useService } from "dioc/vue"
|
import { useService } from "dioc/vue"
|
||||||
import { RESTTabService } from "~/services/tab/rest"
|
import { RESTTabService } from "~/services/tab/rest"
|
||||||
import { GQLTabService } from "~/services/tab/graphql"
|
import { GQLTabService } from "~/services/tab/graphql"
|
||||||
|
import { getDefaultRESTRequest } from "~/helpers/rest/default"
|
||||||
|
import { getDefaultGQLRequest } from "~/helpers/graphql/default"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -221,6 +223,15 @@ const saveRequestAs = async () => {
|
|||||||
|
|
||||||
requestUpdated.name = requestName.value
|
requestUpdated.name = requestName.value
|
||||||
|
|
||||||
|
if (props.mode === "rest") {
|
||||||
|
;(requestUpdated as HoppRESTRequest).endpoint =
|
||||||
|
(requestUpdated as HoppRESTRequest).endpoint ||
|
||||||
|
getDefaultRESTRequest().endpoint
|
||||||
|
} else {
|
||||||
|
;(requestUpdated as HoppGQLRequest).url =
|
||||||
|
(requestUpdated as HoppGQLRequest).url || getDefaultGQLRequest().url
|
||||||
|
}
|
||||||
|
|
||||||
if (picked.value.pickedType === "my-collection") {
|
if (picked.value.pickedType === "my-collection") {
|
||||||
if (!isHoppRESTRequest(requestUpdated))
|
if (!isHoppRESTRequest(requestUpdated))
|
||||||
throw new Error("requestUpdated is not a REST Request")
|
throw new Error("requestUpdated is not a REST Request")
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ import { InterceptorService } from "~/services/interceptor.service"
|
|||||||
import { editGraphqlRequest } from "~/newstore/collections"
|
import { editGraphqlRequest } from "~/newstore/collections"
|
||||||
import { GQLTabService } from "~/services/tab/graphql"
|
import { GQLTabService } from "~/services/tab/graphql"
|
||||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||||
|
import { getDefaultGQLRequest } from "~/helpers/graphql/default"
|
||||||
|
|
||||||
const VALID_GQL_OPERATIONS = [
|
const VALID_GQL_OPERATIONS = [
|
||||||
"query",
|
"query",
|
||||||
@@ -247,10 +248,16 @@ const saveRequest = () => {
|
|||||||
tabs.currentActiveTab.value.document.saveContext.originLocation ===
|
tabs.currentActiveTab.value.document.saveContext.originLocation ===
|
||||||
"user-collection"
|
"user-collection"
|
||||||
) {
|
) {
|
||||||
|
const finalRequest = {
|
||||||
|
...tabs.currentActiveTab.value.document.request,
|
||||||
|
url:
|
||||||
|
tabs.currentActiveTab.value.document.request.url ||
|
||||||
|
getDefaultGQLRequest().url,
|
||||||
|
}
|
||||||
editGraphqlRequest(
|
editGraphqlRequest(
|
||||||
tabs.currentActiveTab.value.document.saveContext.folderPath,
|
tabs.currentActiveTab.value.document.saveContext.folderPath,
|
||||||
tabs.currentActiveTab.value.document.saveContext.requestIndex,
|
tabs.currentActiveTab.value.document.saveContext.requestIndex,
|
||||||
tabs.currentActiveTab.value.document.request
|
finalRequest
|
||||||
)
|
)
|
||||||
|
|
||||||
tabs.currentActiveTab.value.document.isDirty = false
|
tabs.currentActiveTab.value.document.isDirty = false
|
||||||
|
|||||||
@@ -112,7 +112,10 @@ const activeTabs = tabs.getActiveTabs()
|
|||||||
|
|
||||||
const addNewTab = () => {
|
const addNewTab = () => {
|
||||||
const tab = tabs.createNewTab({
|
const tab = tabs.createNewTab({
|
||||||
request: getDefaultGQLRequest(),
|
request: {
|
||||||
|
...getDefaultGQLRequest(),
|
||||||
|
url: "",
|
||||||
|
},
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,10 @@ const onTabUpdate = (tab: HoppTab<HoppRESTDocument>) => {
|
|||||||
|
|
||||||
const addNewTab = () => {
|
const addNewTab = () => {
|
||||||
const tab = tabs.createNewTab({
|
const tab = tabs.createNewTab({
|
||||||
request: getDefaultRESTRequest(),
|
request: {
|
||||||
|
...getDefaultRESTRequest(),
|
||||||
|
endpoint: "",
|
||||||
|
},
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -295,8 +298,14 @@ const shareTabRequest = (tabID: string) => {
|
|||||||
const tab = tabs.getTabRef(tabID)
|
const tab = tabs.getTabRef(tabID)
|
||||||
if (tab.value) {
|
if (tab.value) {
|
||||||
if (currentUser.value) {
|
if (currentUser.value) {
|
||||||
|
const finalRequest = {
|
||||||
|
...tab.value.document.request,
|
||||||
|
endpoint:
|
||||||
|
tab.value.document.request.endpoint ||
|
||||||
|
getDefaultRESTRequest().endpoint,
|
||||||
|
}
|
||||||
invokeAction("share.request", {
|
invokeAction("share.request", {
|
||||||
request: tab.value.document.request,
|
request: finalRequest,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
invokeAction("modals.login.toggle")
|
invokeAction("modals.login.toggle")
|
||||||
|
|||||||
Reference in New Issue
Block a user