refactor: persist only request handles under tab saveContext at runtime
Remove provider, workspace and request IDs.
This commit is contained in:
@@ -79,7 +79,7 @@
|
|||||||
interactive
|
interactive
|
||||||
trigger="click"
|
trigger="click"
|
||||||
theme="popover"
|
theme="popover"
|
||||||
:on-shown="() => tippyActions.focus()"
|
:on-shown="() => tippyActions?.focus()"
|
||||||
>
|
>
|
||||||
<HoppButtonSecondary
|
<HoppButtonSecondary
|
||||||
v-tippy="{ theme: 'tooltip' }"
|
v-tippy="{ theme: 'tooltip' }"
|
||||||
|
|||||||
@@ -501,10 +501,7 @@ import {
|
|||||||
updateInheritedPropertiesForAffectedRequests,
|
updateInheritedPropertiesForAffectedRequests,
|
||||||
updateSaveContextForAffectedRequests,
|
updateSaveContextForAffectedRequests,
|
||||||
} from "~/helpers/collection/collection"
|
} from "~/helpers/collection/collection"
|
||||||
import {
|
import { getRequestsByPath } from "~/helpers/collection/request"
|
||||||
getRequestsByPath,
|
|
||||||
resolveSaveContextOnRequestReorder,
|
|
||||||
} from "~/helpers/collection/request"
|
|
||||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||||
import { Picked } from "~/helpers/types/HoppPicked"
|
import { Picked } from "~/helpers/types/HoppPicked"
|
||||||
import {
|
import {
|
||||||
@@ -842,16 +839,11 @@ const onAddRequest = async (requestName: string) => {
|
|||||||
|
|
||||||
const { auth, headers } = cascadingAuthHeadersHandle.value.data
|
const { auth, headers } = cascadingAuthHeadersHandle.value.data
|
||||||
|
|
||||||
const { providerID, requestID, workspaceID } = requestHandle.value.data
|
|
||||||
|
|
||||||
tabs.createNewTab({
|
tabs.createNewTab({
|
||||||
request: newRequest,
|
request: newRequest,
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
saveContext: {
|
saveContext: {
|
||||||
originLocation: "workspace-user-collection",
|
originLocation: "workspace-user-collection",
|
||||||
workspaceID,
|
|
||||||
providerID,
|
|
||||||
requestID,
|
|
||||||
requestHandle,
|
requestHandle,
|
||||||
},
|
},
|
||||||
inheritedProperties: {
|
inheritedProperties: {
|
||||||
@@ -1160,8 +1152,6 @@ const selectRequest = async (requestIndexPath: string) => {
|
|||||||
|
|
||||||
const { auth, headers } = cascadingAuthHeadersHandle.value.data
|
const { auth, headers } = cascadingAuthHeadersHandle.value.data
|
||||||
|
|
||||||
const { providerID, requestID, workspaceID } = requestHandle.value.data
|
|
||||||
|
|
||||||
// If there is a request with this save context, switch into it
|
// If there is a request with this save context, switch into it
|
||||||
const possibleTab = tabs.getTabRefWithSaveContext({
|
const possibleTab = tabs.getTabRefWithSaveContext({
|
||||||
originLocation: "workspace-user-collection",
|
originLocation: "workspace-user-collection",
|
||||||
@@ -1177,9 +1167,6 @@ const selectRequest = async (requestIndexPath: string) => {
|
|||||||
isDirty: false,
|
isDirty: false,
|
||||||
saveContext: {
|
saveContext: {
|
||||||
originLocation: "workspace-user-collection",
|
originLocation: "workspace-user-collection",
|
||||||
workspaceID,
|
|
||||||
providerID,
|
|
||||||
requestID,
|
|
||||||
requestHandle,
|
requestHandle,
|
||||||
},
|
},
|
||||||
inheritedProperties: {
|
inheritedProperties: {
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ export function resolveSaveContextOnCollectionReorder(
|
|||||||
requestID.split("/").slice(-1)[0]
|
requestID.split("/").slice(-1)[0]
|
||||||
}`
|
}`
|
||||||
|
|
||||||
tab.value.document.saveContext.requestID = newRequestID
|
|
||||||
requestHandle.data = {
|
requestHandle.data = {
|
||||||
...requestHandle.data,
|
...requestHandle.data,
|
||||||
collectionID: newCollectionID!,
|
collectionID: newCollectionID!,
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ export function resolveSaveContextOnRequestReorder(payload: {
|
|||||||
|
|
||||||
requestIDArr[requestIDArr.length - 1] = requestIndex.toString()
|
requestIDArr[requestIDArr.length - 1] = requestIndex.toString()
|
||||||
|
|
||||||
tab.value.document.saveContext.requestID = requestIDArr.join("/")
|
|
||||||
requestHandle.data.requestID = requestIDArr.join("/")
|
requestHandle.data.requestID = requestIDArr.join("/")
|
||||||
requestHandle.data.collectionID = requestIDArr.slice(0, -1).join("/")
|
requestHandle.data.collectionID = requestIDArr.slice(0, -1).join("/")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,17 +16,17 @@ export type HoppRESTSaveContext =
|
|||||||
/**
|
/**
|
||||||
* ID of the workspace
|
* ID of the workspace
|
||||||
*/
|
*/
|
||||||
workspaceID: string
|
workspaceID?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID of the provider
|
* ID of the provider
|
||||||
*/
|
*/
|
||||||
providerID: string
|
providerID?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the request in the collection tree
|
* Path to the request in the collection tree
|
||||||
*/
|
*/
|
||||||
requestID: string
|
requestID?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle to the request open in the tab
|
* Handle to the request open in the tab
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {
|
|||||||
TabService as TabServiceInterface,
|
TabService as TabServiceInterface,
|
||||||
} from "."
|
} from "."
|
||||||
|
|
||||||
import { HoppGQLDocument } from "~/helpers/graphql/document"
|
|
||||||
import { NewWorkspaceService } from "../new-workspace"
|
import { NewWorkspaceService } from "../new-workspace"
|
||||||
import { HandleRef } from "../new-workspace/handle"
|
import { HandleRef } from "../new-workspace/handle"
|
||||||
import { WorkspaceRequest } from "../new-workspace/workspace"
|
import { WorkspaceRequest } from "../new-workspace/workspace"
|
||||||
@@ -137,10 +136,12 @@ export abstract class TabService<Doc>
|
|||||||
if (E.isRight(requestHandleResult)) {
|
if (E.isRight(requestHandleResult)) {
|
||||||
requestHandle = requestHandleResult.right
|
requestHandle = requestHandleResult.right
|
||||||
|
|
||||||
|
const { originLocation } = saveContext
|
||||||
|
|
||||||
resolvedTabDoc = {
|
resolvedTabDoc = {
|
||||||
...resolvedTabDoc,
|
...resolvedTabDoc,
|
||||||
saveContext: {
|
saveContext: {
|
||||||
...saveContext,
|
originLocation,
|
||||||
requestHandle,
|
requestHandle,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user