refactor: inherit header from multiple collecions

This commit is contained in:
nivedin
2023-11-30 19:43:46 +05:30
committed by Andrew Bastin
parent b893607ad1
commit 0a54455fe7
9 changed files with 145 additions and 89 deletions

View File

@@ -302,6 +302,7 @@ const editingProperties = ref<{
collection: null,
isRootCollection: false,
path: "",
inheritedProperties: undefined,
})
const confirmModalTitle = ref<string | null>(null)
@@ -678,7 +679,7 @@ const onAddRequest = (requestName: string) => {
if (!path) return
const insertionIndex = saveRESTRequestAs(path, newRequest)
const { auth, headers, name } = cascaseParentCollectionForHeaderAuth(path)
const { auth, headers } = cascaseParentCollectionForHeaderAuth(path)
tabs.createNewTab({
request: newRequest,
@@ -691,8 +692,6 @@ const onAddRequest = (requestName: string) => {
inheritedProperties: {
auth,
headers,
parentName: name,
parentId: path,
},
})
@@ -1330,8 +1329,7 @@ const selectRequest = (selectedRequest: {
// If there is a request with this save context, switch into it
let possibleTab = null
const { auth, headers, name } =
cascaseParentCollectionForHeaderAuth(folderPath)
const { auth, headers } = cascaseParentCollectionForHeaderAuth(folderPath)
if (collectionsType.value.type === "team-collections") {
possibleTab = tabs.getTabRefWithSaveContext({
@@ -1369,9 +1367,7 @@ const selectRequest = (selectedRequest: {
requestIndex: parseInt(requestIndex),
},
inheritedProperties: {
parentId: folderPath || "",
parentName: name,
auth: auth,
auth,
headers,
},
})
@@ -1405,7 +1401,7 @@ const dropRequest = (payload: {
let possibleTab = null
if (collectionsType.value.type === "my-collections" && folderPath) {
const { auth, headers, name } = cascaseParentCollectionForHeaderAuth(
const { auth, headers } = cascaseParentCollectionForHeaderAuth(
destinationCollectionIndex
)
@@ -1427,8 +1423,6 @@ const dropRequest = (payload: {
}
possibleTab.value.document.inheritedProperties = {
parentId: destinationCollectionIndex,
parentName: name,
auth,
headers,
}
@@ -1600,13 +1594,11 @@ const dropCollection = (payload: {
`${destinationCollectionIndex}/${totalFoldersOfDestinationCollection}`
)
const { auth, headers, name } = cascaseParentCollectionForHeaderAuth(
const { auth, headers } = cascaseParentCollectionForHeaderAuth(
`${destinationCollectionIndex}/${totalFoldersOfDestinationCollection}`
)
const inheritedProperty = {
parentId: `${destinationCollectionIndex}/${totalFoldersOfDestinationCollection}`,
parentName: name,
auth,
headers,
}
@@ -1983,12 +1975,9 @@ const editProperties = (payload: {
let inheritedProperties = {}
if (parentIndex) {
const { auth, headers, name } =
cascaseParentCollectionForHeaderAuth(parentIndex)
const { auth, headers } = cascaseParentCollectionForHeaderAuth(parentIndex)
inheritedProperties = {
parentId: parentIndex ?? "",
parentName: name,
auth,
headers,
} as HoppInheritedProperty
@@ -2016,12 +2005,10 @@ const setCollectionProperties = (newCollection: {
editRESTFolder(path, collection)
}
const { auth, headers, name } = cascaseParentCollectionForHeaderAuth(path)
const { auth, headers } = cascaseParentCollectionForHeaderAuth(path)
nextTick(() => {
updateInheritedPropertiesForAffectedRequests(path, {
parentId: path,
parentName: name,
auth,
headers,
})