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}`,
|
folderPath: `${picked.value.collectionIndex}`,
|
||||||
requestIndex: insertionIndex,
|
requestIndex: insertionIndex,
|
||||||
exampleID: undefined,
|
exampleID: undefined,
|
||||||
|
requestRefID: requestUpdated._ref_id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -392,6 +393,7 @@ const saveRequestAs = async () => {
|
||||||
originLocation: "user-collection",
|
originLocation: "user-collection",
|
||||||
folderPath: picked.value.folderPath,
|
folderPath: picked.value.folderPath,
|
||||||
requestIndex: insertionIndex,
|
requestIndex: insertionIndex,
|
||||||
|
requestRefID: requestUpdated._ref_id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1351,6 +1351,9 @@ export function removeRESTCollection(
|
||||||
collectionIndex: number,
|
collectionIndex: number,
|
||||||
collectionID?: string
|
collectionID?: string
|
||||||
) {
|
) {
|
||||||
|
if (!collectionID) {
|
||||||
|
collectionID = restCollectionStore.value.state[collectionIndex]?._ref_id
|
||||||
|
}
|
||||||
restCollectionStore.dispatch({
|
restCollectionStore.dispatch({
|
||||||
dispatcher: "removeCollection",
|
dispatcher: "removeCollection",
|
||||||
payload: {
|
payload: {
|
||||||
|
|
@ -1518,6 +1521,13 @@ export function editRESTFolder(path: string, folder: Partial<HoppCollection>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeRESTFolder(path: string, folderID?: string) {
|
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({
|
restCollectionStore.dispatch({
|
||||||
dispatcher: "removeFolder",
|
dispatcher: "removeFolder",
|
||||||
payload: {
|
payload: {
|
||||||
|
|
@ -1621,6 +1631,13 @@ export function removeRESTRequest(
|
||||||
requestIndex: number,
|
requestIndex: number,
|
||||||
requestID?: string
|
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({
|
restCollectionStore.dispatch({
|
||||||
dispatcher: "removeRequest",
|
dispatcher: "removeRequest",
|
||||||
payload: {
|
payload: {
|
||||||
|
|
@ -1705,6 +1722,9 @@ export function removeGraphqlCollection(
|
||||||
collectionIndex: number,
|
collectionIndex: number,
|
||||||
collectionID?: string
|
collectionID?: string
|
||||||
) {
|
) {
|
||||||
|
if (!collectionID) {
|
||||||
|
collectionID = graphqlCollectionStore.value.state[collectionIndex]?._ref_id
|
||||||
|
}
|
||||||
graphqlCollectionStore.dispatch({
|
graphqlCollectionStore.dispatch({
|
||||||
dispatcher: "removeCollection",
|
dispatcher: "removeCollection",
|
||||||
payload: {
|
payload: {
|
||||||
|
|
@ -1751,6 +1771,13 @@ export function editGraphqlFolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeGraphqlFolder(path: string, folderID?: string) {
|
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({
|
graphqlCollectionStore.dispatch({
|
||||||
dispatcher: "removeFolder",
|
dispatcher: "removeFolder",
|
||||||
payload: {
|
payload: {
|
||||||
|
|
@ -1828,6 +1855,13 @@ export function removeGraphqlRequest(
|
||||||
requestIndex: number,
|
requestIndex: number,
|
||||||
requestID?: string
|
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({
|
graphqlCollectionStore.dispatch({
|
||||||
dispatcher: "removeRequest",
|
dispatcher: "removeRequest",
|
||||||
payload: {
|
payload: {
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,9 @@ export class RESTTabService extends TabService<HoppTabDocument> {
|
||||||
tab.document.saveContext.folderPath === ctx?.folderPath &&
|
tab.document.saveContext.folderPath === ctx?.folderPath &&
|
||||||
tab.document.saveContext.requestIndex === ctx?.requestIndex &&
|
tab.document.saveContext.requestIndex === ctx?.requestIndex &&
|
||||||
tab.document.saveContext.exampleID === ctx?.exampleID &&
|
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)
|
return this.getTabRef(tab.id)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue