refactor: persist IDs under tab save context

This commit is contained in:
jamesgeorge007
2024-02-16 19:09:06 +05:30
parent 89f7c2ce5e
commit 316dc8f759
9 changed files with 110 additions and 182 deletions

View File

@@ -1,5 +1,7 @@
import { HoppCollection } from "@hoppscotch/data"
import * as E from "fp-ts/Either"
import { ref } from "vue"
import { getService } from "~/modules/dioc"
import { GQLTabService } from "~/services/tab/graphql"
import { RESTTabService } from "~/services/tab/rest"
@@ -183,19 +185,10 @@ export function updateInheritedPropertiesForAffectedRequests(
return Boolean(tab.document.saveContext.collectionID?.startsWith(path))
}
if (
tab.document.saveContext?.originLocation !== "workspace-user-collection"
) {
return false
}
const requestHandle = ref(tab.document.saveContext.requestHandle)
return (
tab.document.saveContext?.originLocation ===
"workspace-user-collection" &&
requestHandle.value.type === "ok" &&
requestHandle.value.data.collectionID.startsWith(path)
tab.document.saveContext.collectionID?.startsWith(path)
)
})
@@ -212,18 +205,6 @@ export function updateInheritedPropertiesForAffectedRequests(
)
}
if (tab.value.document.saveContext?.originLocation === "team-collection") {
return (
tab.value.document.saveContext.collectionID?.startsWith(path) &&
path ===
folderPathCloseToSaveContext(
tab.value.document.inheritedProperties?.auth.parentID,
path,
tab.value.document.saveContext.collectionID
)
)
}
if (
tab.value.document.saveContext?.originLocation !==
"workspace-user-collection"
@@ -231,16 +212,15 @@ export function updateInheritedPropertiesForAffectedRequests(
return false
}
const requestHandle = ref(tab.value.document.saveContext.requestHandle)
const { collectionID } = tab.value.document.saveContext
return (
requestHandle.value.type === "ok" &&
requestHandle.value.data.collectionID.startsWith(path) &&
collectionID.startsWith(path) &&
path ===
folderPathCloseToSaveContext(
tab.value.document.inheritedProperties?.auth.parentID,
path,
requestHandle.value.data.collectionID
collectionID
)
)
})

View File

@@ -3,8 +3,6 @@ import { HoppRESTResponse } from "../types/HoppRESTResponse"
import { HoppTestResult } from "../types/HoppTestResult"
import { RESTOptionTabs } from "~/components/http/RequestOptions.vue"
import { HoppInheritedProperty } from "../types/HoppInheritedProperties"
import { HandleRef } from "~/services/new-workspace/handle"
import { WorkspaceRequest } from "~/services/new-workspace/workspace"
export type HoppRESTSaveContext =
| {
@@ -14,9 +12,24 @@ export type HoppRESTSaveContext =
// TODO: Make this `user-collection` after porting all usages
originLocation: "workspace-user-collection"
/**
* Handle to a request in the workspace
* ID of the workspace
*/
requestHandle: HandleRef<WorkspaceRequest>
workspaceID: string
/**
* ID of the provider
*/
providerID: string
/**
* ID of the collection
*/
collectionID: string
/**
* Path to the request in the collection tree
*/
requestID: string
}
| {
/**