feat(common): remove functions to utilize ref_id when IDs are not provided (#5898)
Co-authored-by: nivedin <nivedinp@gmail.com>
This commit is contained in:
parent
60c607c185
commit
088ea9f4dc
3 changed files with 39 additions and 1 deletions
|
|
@ -358,6 +358,7 @@ const saveRequestAs = async () => {
|
|||
folderPath: `${picked.value.collectionIndex}`,
|
||||
requestIndex: insertionIndex,
|
||||
exampleID: undefined,
|
||||
requestRefID: requestUpdated._ref_id,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -392,6 +393,7 @@ const saveRequestAs = async () => {
|
|||
originLocation: "user-collection",
|
||||
folderPath: picked.value.folderPath,
|
||||
requestIndex: insertionIndex,
|
||||
requestRefID: requestUpdated._ref_id,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1351,6 +1351,9 @@ export function removeRESTCollection(
|
|||
collectionIndex: number,
|
||||
collectionID?: string
|
||||
) {
|
||||
if (!collectionID) {
|
||||
collectionID = restCollectionStore.value.state[collectionIndex]?._ref_id
|
||||
}
|
||||
restCollectionStore.dispatch({
|
||||
dispatcher: "removeCollection",
|
||||
payload: {
|
||||
|
|
@ -1518,6 +1521,13 @@ export function editRESTFolder(path: string, folder: Partial<HoppCollection>) {
|
|||
}
|
||||
|
||||
export function removeRESTFolder(path: string, folderID?: string) {
|
||||
if (!folderID) {
|
||||
const folder = navigateToFolderWithIndexPath(
|
||||
restCollectionStore.value.state,
|
||||
path.split("/").map((index) => parseInt(index))
|
||||
)
|
||||
folderID = folder?._ref_id
|
||||
}
|
||||
restCollectionStore.dispatch({
|
||||
dispatcher: "removeFolder",
|
||||
payload: {
|
||||
|
|
@ -1621,6 +1631,13 @@ export function removeRESTRequest(
|
|||
requestIndex: number,
|
||||
requestID?: string
|
||||
) {
|
||||
if (!requestID) {
|
||||
const request = navigateToFolderWithIndexPath(
|
||||
restCollectionStore.value.state,
|
||||
path.split("/").map((index) => parseInt(index))
|
||||
)?.requests[requestIndex]
|
||||
requestID = request?.id || (request as HoppRESTRequest)?._ref_id
|
||||
}
|
||||
restCollectionStore.dispatch({
|
||||
dispatcher: "removeRequest",
|
||||
payload: {
|
||||
|
|
@ -1705,6 +1722,9 @@ export function removeGraphqlCollection(
|
|||
collectionIndex: number,
|
||||
collectionID?: string
|
||||
) {
|
||||
if (!collectionID) {
|
||||
collectionID = graphqlCollectionStore.value.state[collectionIndex]?._ref_id
|
||||
}
|
||||
graphqlCollectionStore.dispatch({
|
||||
dispatcher: "removeCollection",
|
||||
payload: {
|
||||
|
|
@ -1751,6 +1771,13 @@ export function editGraphqlFolder(
|
|||
}
|
||||
|
||||
export function removeGraphqlFolder(path: string, folderID?: string) {
|
||||
if (!folderID) {
|
||||
const folder = navigateToFolderWithIndexPath(
|
||||
graphqlCollectionStore.value.state,
|
||||
path.split("/").map((index) => parseInt(index))
|
||||
)
|
||||
folderID = folder?._ref_id
|
||||
}
|
||||
graphqlCollectionStore.dispatch({
|
||||
dispatcher: "removeFolder",
|
||||
payload: {
|
||||
|
|
@ -1828,6 +1855,13 @@ export function removeGraphqlRequest(
|
|||
requestIndex: number,
|
||||
requestID?: string
|
||||
) {
|
||||
if (!requestID) {
|
||||
const request = navigateToFolderWithIndexPath(
|
||||
graphqlCollectionStore.value.state,
|
||||
path.split("/").map((index) => parseInt(index))
|
||||
)?.requests[requestIndex]
|
||||
requestID = request?.id || `${path}/${requestIndex}`
|
||||
}
|
||||
graphqlCollectionStore.dispatch({
|
||||
dispatcher: "removeRequest",
|
||||
payload: {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,9 @@ export class RESTTabService extends TabService<HoppTabDocument> {
|
|||
tab.document.saveContext.folderPath === ctx?.folderPath &&
|
||||
tab.document.saveContext.requestIndex === ctx?.requestIndex &&
|
||||
tab.document.saveContext.exampleID === ctx?.exampleID &&
|
||||
tab.document.saveContext.requestRefID === ctx?.requestRefID
|
||||
(ctx?.requestRefID != null
|
||||
? tab.document.saveContext.requestRefID === ctx.requestRefID
|
||||
: true)
|
||||
) {
|
||||
return this.getTabRef(tab.id)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue