feat: added reordering and moving for collection (#2916)

This commit is contained in:
Nivedin
2023-02-24 19:09:07 +05:30
committed by GitHub
parent dcd441f15e
commit 4ca6e9ec3a
24 changed files with 1721 additions and 359 deletions

View File

@@ -12,16 +12,37 @@ import {
ImportFromJsonDocument,
ImportFromJsonMutation,
ImportFromJsonMutationVariables,
MoveRestTeamCollectionDocument,
MoveRestTeamCollectionMutation,
MoveRestTeamCollectionMutationVariables,
RenameCollectionDocument,
RenameCollectionMutation,
RenameCollectionMutationVariables,
UpdateCollectionOrderDocument,
UpdateCollectionOrderMutation,
UpdateCollectionOrderMutationVariables,
} from "../graphql"
type CreateNewRootCollectionError = "team_coll/short_title"
type CreateChildCollectionError = "team_coll/short_title"
type RenameCollectionError = "team_coll/short_title"
type DeleteCollectionError = "team/invalid_coll_id"
type MoveRestTeamCollectionError =
| "team/invalid_coll_id"
| "team_coll/invalid_target_id"
| "team/collection_is_parent_coll"
| "team/target_and_destination_collection_are_same"
| "team/target_collection_is_already_root_collection"
type UpdateCollectionOrderError =
| "team/invalid_coll_id"
| "team/collection_and_next_collection_are_same"
| "team/team_collections_have_different_parents"
export const createNewRootCollection = (title: string, teamID: string) =>
runMutation<
CreateNewRootCollectionMutation,
@@ -66,6 +87,33 @@ export const deleteCollection = (collectionID: string) =>
collectionID,
})
/** Can be used to move both collection and folder (considered same in BE) */
export const moveRESTTeamCollection = (
collectionID: string,
destinationCollectionID: string | null
) =>
runMutation<
MoveRestTeamCollectionMutation,
MoveRestTeamCollectionMutationVariables,
MoveRestTeamCollectionError
>(MoveRestTeamCollectionDocument, {
collectionID,
parentCollectionID: destinationCollectionID,
})
export const updateOrderRESTTeamCollection = (
collectionID: string,
destCollID: string
) =>
runMutation<
UpdateCollectionOrderMutation,
UpdateCollectionOrderMutationVariables,
UpdateCollectionOrderError
>(UpdateCollectionOrderDocument, {
collectionID,
destCollID,
})
export const importJSONToTeam = (collectionJSON: string, teamID: string) =>
runMutation<ImportFromJsonMutation, ImportFromJsonMutationVariables, "">(
ImportFromJsonDocument,