chore: cleanup

This commit is contained in:
jamesgeorge007
2024-02-12 10:35:54 +05:30
parent 2c47a63ca0
commit 97899ec023
4 changed files with 21 additions and 55 deletions

View File

@@ -302,12 +302,6 @@ const saveRequestAs = async () => {
return return
} }
if (updateRequestResult.right.type === "invalid") {
// REQUEST_INVALIDATED | REQUEST_PATH_NOT_FOUND
return
}
// These remain here in the component // These remain here in the component
RESTTabs.currentActiveTab.value.document = { RESTTabs.currentActiveTab.value.document = {
request: updatedRequest, request: updatedRequest,

View File

@@ -547,19 +547,6 @@ const saveRequest = async () => {
return return
} }
const resultHandle = updateRequestResult.right
if (resultHandle.type === "invalid") {
// REQUEST_INVALIDATED | REQUEST_PATH_NOT_FOUND
if (resultHandle.reason === "REQUEST_PATH_NOT_FOUND") {
// REQUEST_PATH_NOT_FOUND
tab.value.document.saveContext = undefined
await saveRequest()
}
return
}
tab.value.document.isDirty = false tab.value.document.isDirty = false
tab.value.document.saveContext = { tab.value.document.saveContext = {

View File

@@ -779,11 +779,6 @@ const onEditRequest = async (newRequestName: string) => {
return return
} }
if (result.right.type === "invalid") {
// REQUEST_INVALIDATED
return
}
displayModalEditRequest(false) displayModalEditRequest(false)
toast.success(t("request.renamed")) toast.success(t("request.renamed"))
} }

View File

@@ -30,8 +30,8 @@ import { platform } from "~/platform"
import { HandleRef } from "~/services/new-workspace/handle" import { HandleRef } from "~/services/new-workspace/handle"
import { WorkspaceProvider } from "~/services/new-workspace/provider" import { WorkspaceProvider } from "~/services/new-workspace/provider"
import { import {
RESTCollectionLevelAuthHeadersView,
RESTCollectionChildrenView, RESTCollectionChildrenView,
RESTCollectionLevelAuthHeadersView,
RESTCollectionViewItem, RESTCollectionViewItem,
RootRESTCollectionView, RootRESTCollectionView,
} from "~/services/new-workspace/view" } from "~/services/new-workspace/view"
@@ -42,18 +42,13 @@ import {
WorkspaceRequest, WorkspaceRequest,
} from "~/services/new-workspace/workspace" } from "~/services/new-workspace/workspace"
import IconUser from "~icons/lucide/user"
import { NewWorkspaceService } from ".."
import { HoppRESTRequest } from "@hoppscotch/data" import { HoppRESTRequest } from "@hoppscotch/data"
import { merge } from "lodash-es"
import path from "path" import path from "path"
import {
resolveSaveContextOnCollectionReorder,
getFoldersByPath,
} from "~/helpers/collection/collection"
import { HoppGQLHeader } from "~/helpers/graphql" import { HoppGQLHeader } from "~/helpers/graphql"
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties" import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
import { computedAsync } from "@vueuse/core" import IconUser from "~icons/lucide/user"
import { merge } from "lodash-es" import { NewWorkspaceService } from ".."
export class PersonalWorkspaceProviderService export class PersonalWorkspaceProviderService
extends Service extends Service
@@ -272,13 +267,6 @@ export class PersonalWorkspaceProviderService
collectionIndex, collectionIndex,
collectionToRemove ? collectionToRemove.id : undefined collectionToRemove ? collectionToRemove.id : undefined
) )
resolveSaveContextOnCollectionReorder({
lastIndex: collectionIndex,
newIndex: -1,
folderPath: "", // root collection
length: this.restCollectionState.value.state.length,
})
} else { } else {
const folderToRemove = path const folderToRemove = path
? navigateToFolderWithIndexPath( ? navigateToFolderWithIndexPath(
@@ -291,17 +279,6 @@ export class PersonalWorkspaceProviderService
collectionID, collectionID,
folderToRemove ? folderToRemove.id : undefined folderToRemove ? folderToRemove.id : undefined
) )
const parentFolder = collectionID.split("/").slice(0, -1).join("/") // Remove last folder to get parent folder
resolveSaveContextOnCollectionReorder({
lastIndex: this.pathToLastIndex(collectionID),
newIndex: -1,
folderPath: parentFolder,
length: getFoldersByPath(
this.restCollectionState.value.state,
parentFolder
).length,
})
} }
return Promise.resolve(E.right(undefined)) return Promise.resolve(E.right(undefined))
@@ -453,9 +430,22 @@ export class PersonalWorkspaceProviderService
) )
if (!collection) { if (!collection) {
return { const parentCollectionIndexPath = collectionID
type: "invalid" as const, .split("/")
reason: "COLLECTION_PATH_NOT_FOUND" as const, .slice(0, -1)
.join("/")
const requestIndex = this.pathToLastIndex(collectionID)
const parentCollection = navigateToFolderWithIndexPath(
this.restCollectionState.value.state,
parentCollectionIndexPath.split("/").map((x) => parseInt(x))
)
if (!parentCollection || !parentCollection.requests[requestIndex]) {
return {
type: "invalid" as const,
reason: "INVALID_PATH" as const,
}
} }
} }
@@ -467,7 +457,7 @@ export class PersonalWorkspaceProviderService
providerID, providerID,
workspaceID, workspaceID,
collectionID, collectionID,
name: collection?.name, name: collection?.name as string,
}, },
} }
}) })