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

@@ -228,30 +228,30 @@ const saveRequestAs = async () => {
if (!isHoppRESTRequest(updatedRequest))
throw new Error("requestUpdated is not a REST Request")
const collPathIndex =
const collectionPathIndex =
picked.value.pickedType === "my-collection"
? picked.value.collectionIndex.toString()
: picked.value.folderPath
const collHandleResult = await workspaceService.getCollectionHandle(
const collectionHandleResult = await workspaceService.getCollectionHandle(
workspaceService.activeWorkspaceHandle.value,
collPathIndex
collectionPathIndex
)
if (E.isLeft(collHandleResult)) {
if (E.isLeft(collectionHandleResult)) {
// INVALID_WORKSPACE_HANDLE | INVALID_COLLECTION_ID | INVALID_PATH
return
}
const collHandle = collHandleResult.right
const collectionHandle = collectionHandleResult.right
if (collHandle.value.type === "invalid") {
if (collectionHandle.value.type === "invalid") {
// WORKSPACE_INVALIDATED
return
}
const requestHandleResult = await workspaceService.createRESTRequest(
collHandle,
collectionHandle,
updatedRequest
)
@@ -299,13 +299,18 @@ const saveRequestAs = async () => {
return
}
// These remain here in the component
const { collectionID, providerID, requestID, workspaceID } =
requestHandle.value.data
RESTTabs.currentActiveTab.value.document = {
request: updatedRequest,
isDirty: false,
saveContext: {
originLocation: "workspace-user-collection",
requestHandle,
workspaceID,
providerID,
collectionID,
requestID,
},
}