refactor: open request with header and auth in search
This commit is contained in:
@@ -10,17 +10,14 @@ import { Ref, computed, effectScope, markRaw, ref, watch } from "vue"
|
|||||||
import { getI18n } from "~/modules/i18n"
|
import { getI18n } from "~/modules/i18n"
|
||||||
import MiniSearch from "minisearch"
|
import MiniSearch from "minisearch"
|
||||||
import {
|
import {
|
||||||
|
cascadeParentCollectionForHeaderAuth,
|
||||||
graphqlCollectionStore,
|
graphqlCollectionStore,
|
||||||
restCollectionStore,
|
restCollectionStore,
|
||||||
} from "~/newstore/collections"
|
} from "~/newstore/collections"
|
||||||
import IconFolder from "~icons/lucide/folder"
|
import IconFolder from "~icons/lucide/folder"
|
||||||
import RESTRequestSpotlightEntry from "~/components/app/spotlight/entry/RESTRequest.vue"
|
import RESTRequestSpotlightEntry from "~/components/app/spotlight/entry/RESTRequest.vue"
|
||||||
import GQLRequestSpotlightEntry from "~/components/app/spotlight/entry/GQLRequest.vue"
|
import GQLRequestSpotlightEntry from "~/components/app/spotlight/entry/GQLRequest.vue"
|
||||||
import {
|
import { HoppCollection } from "@hoppscotch/data"
|
||||||
HoppCollection,
|
|
||||||
HoppGQLRequest,
|
|
||||||
HoppRESTRequest,
|
|
||||||
} from "@hoppscotch/data"
|
|
||||||
import { WorkspaceService } from "~/services/workspace.service"
|
import { WorkspaceService } from "~/services/workspace.service"
|
||||||
import { invokeAction } from "~/helpers/actions"
|
import { invokeAction } from "~/helpers/actions"
|
||||||
import { RESTTabService } from "~/services/tab/rest"
|
import { RESTTabService } from "~/services/tab/rest"
|
||||||
@@ -229,7 +226,7 @@ export class CollectionsSpotlightSearcherService
|
|||||||
|
|
||||||
private getRESTFolderFromFolderPath(
|
private getRESTFolderFromFolderPath(
|
||||||
folderPath: string
|
folderPath: string
|
||||||
): HoppCollection<HoppRESTRequest> | undefined {
|
): HoppCollection | undefined {
|
||||||
try {
|
try {
|
||||||
const folderIndicies = folderPath.split("/").map((x) => parseInt(x))
|
const folderIndicies = folderPath.split("/").map((x) => parseInt(x))
|
||||||
|
|
||||||
@@ -253,7 +250,7 @@ export class CollectionsSpotlightSearcherService
|
|||||||
|
|
||||||
private getGQLFolderFromFolderPath(
|
private getGQLFolderFromFolderPath(
|
||||||
folderPath: string
|
folderPath: string
|
||||||
): HoppCollection<HoppGQLRequest> | undefined {
|
): HoppCollection | undefined {
|
||||||
try {
|
try {
|
||||||
const folderIndicies = folderPath.split("/").map((x) => parseInt(x))
|
const folderIndicies = folderPath.split("/").map((x) => parseInt(x))
|
||||||
|
|
||||||
@@ -304,6 +301,11 @@ export class CollectionsSpotlightSearcherService
|
|||||||
|
|
||||||
if (!req) return
|
if (!req) return
|
||||||
|
|
||||||
|
const { auth, headers } = cascadeParentCollectionForHeaderAuth(
|
||||||
|
folderPath.join("/"),
|
||||||
|
"rest"
|
||||||
|
)
|
||||||
|
|
||||||
this.restTab.createNewTab(
|
this.restTab.createNewTab(
|
||||||
{
|
{
|
||||||
request: req,
|
request: req,
|
||||||
@@ -313,6 +315,10 @@ export class CollectionsSpotlightSearcherService
|
|||||||
folderPath: folderPath.join("/"),
|
folderPath: folderPath.join("/"),
|
||||||
requestIndex: reqIndex,
|
requestIndex: reqIndex,
|
||||||
},
|
},
|
||||||
|
inheritedProperties: {
|
||||||
|
auth,
|
||||||
|
headers,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
@@ -326,6 +332,10 @@ export class CollectionsSpotlightSearcherService
|
|||||||
|
|
||||||
if (!req) return
|
if (!req) return
|
||||||
|
|
||||||
|
const { auth, headers } = cascadeParentCollectionForHeaderAuth(
|
||||||
|
folderPath.join("/"),
|
||||||
|
"graphql"
|
||||||
|
)
|
||||||
this.gqlTab.createNewTab({
|
this.gqlTab.createNewTab({
|
||||||
saveContext: {
|
saveContext: {
|
||||||
originLocation: "user-collection",
|
originLocation: "user-collection",
|
||||||
@@ -334,6 +344,10 @@ export class CollectionsSpotlightSearcherService
|
|||||||
},
|
},
|
||||||
request: req,
|
request: req,
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
|
inheritedProperties: {
|
||||||
|
auth,
|
||||||
|
headers,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user