From 1bc57f159c223bc6541f5b150b49a124a15ef639 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Mon, 26 Apr 2021 09:37:18 +0000 Subject: [PATCH 01/36] merge feat/teams-new-ui Co-authored-by: Isha Gupta <40794215+IshaGupta18@users.noreply.github.com> Co-authored-by: Liyas Thomas Co-authored-by: Osheen Sachdev <45964755+oshhh@users.noreply.github.com> Co-authored-by: Rohan Rajpal Co-authored-by: Raghav Gupta --- components/collections/Add.vue | 40 +- components/collections/ChooseType.vue | 63 + components/collections/Collection.vue | 396 +- components/collections/Edit.vue | 44 +- components/collections/EditFolder.vue | 40 +- components/collections/EditRequest.vue | 44 +- components/collections/Folder.vue | 336 +- components/collections/ImportExport.vue | 190 +- components/collections/Request.vue | 54 +- components/collections/SaveRequest.vue | 100 +- components/collections/index.vue | 187 +- components/smart/Tabs.vue | 1 + components/teams/Add.vue | 92 + components/teams/Edit.vue | 436 ++ components/teams/ImportExport.vue | 173 + components/teams/Team.vue | 114 + components/teams/index.vue | 145 + helpers/fb.js | 3 + helpers/teams/utils.js | 460 ++ lang/en-US.json | 27 +- layouts/default.vue | 12 + nuxt.config.js | 8 + package-lock.json | 5588 ++++++++++++++++++++++- package.json | 3 + pages/index.vue | 4 + pages/settings.vue | 4 + plugins/apollo.js | 12 + 27 files changed, 8278 insertions(+), 298 deletions(-) create mode 100644 components/collections/ChooseType.vue create mode 100644 components/teams/Add.vue create mode 100644 components/teams/Edit.vue create mode 100644 components/teams/ImportExport.vue create mode 100644 components/teams/Team.vue create mode 100644 components/teams/index.vue create mode 100644 helpers/teams/utils.js create mode 100644 plugins/apollo.js diff --git a/components/collections/Add.vue b/components/collections/Add.vue index 545d103ee..9d82dcdfc 100644 --- a/components/collections/Add.vue +++ b/components/collections/Add.vue @@ -39,10 +39,12 @@ diff --git a/components/collections/Collection.vue b/components/collections/Collection.vue index 9d4447a75..3ff5198e6 100644 --- a/components/collections/Collection.vue +++ b/components/collections/Collection.vue @@ -13,7 +13,7 @@ arrow_right arrow_drop_down folder - {{ collection.name }} + {{ collection.name ? collection.name : collection.title }}
- +
+ + {{ pageNo }} + +
+ @@ -48,13 +72,43 @@
- +
- + @@ -66,8 +120,10 @@
  • @@ -123,6 +208,7 @@ diff --git a/components/teams/Edit.vue b/components/teams/Edit.vue new file mode 100644 index 000000000..9bb40fd30 --- /dev/null +++ b/components/teams/Edit.vue @@ -0,0 +1,436 @@ + + + diff --git a/components/teams/ImportExport.vue b/components/teams/ImportExport.vue new file mode 100644 index 000000000..d17a69c68 --- /dev/null +++ b/components/teams/ImportExport.vue @@ -0,0 +1,173 @@ + + + diff --git a/components/teams/Team.vue b/components/teams/Team.vue new file mode 100644 index 000000000..74aa4d257 --- /dev/null +++ b/components/teams/Team.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/components/teams/index.vue b/components/teams/index.vue new file mode 100644 index 000000000..d7f265239 --- /dev/null +++ b/components/teams/index.vue @@ -0,0 +1,145 @@ + + + + + diff --git a/helpers/fb.js b/helpers/fb.js index 2d30aa65d..7ee3eacd6 100644 --- a/helpers/fb.js +++ b/helpers/fb.js @@ -32,6 +32,7 @@ export class FirebaseInstance { this.usersCollection = this.app.firestore().collection("users") this.currentUser = null + this.idToken = null this.currentFeeds = [] this.currentSettings = [] this.currentHistory = [] @@ -76,6 +77,8 @@ export class FirebaseInstance { }) this.app.auth().onAuthStateChanged((user) => { + this.currentUser$.next(user) + if (user) { this.currentUser = user diff --git a/helpers/teams/utils.js b/helpers/teams/utils.js new file mode 100644 index 000000000..62cdb42f7 --- /dev/null +++ b/helpers/teams/utils.js @@ -0,0 +1,460 @@ +import gql from "graphql-tag" + +async function createTeam(apollo, name) { + return apollo.mutate({ + mutation: gql` + mutation($name: String!) { + createTeam(name: $name) { + name + } + } + `, + variables: { + name: name, + }, + }) +} + +async function addTeamMemberByEmail(apollo, userRole, userEmail, teamID) { + return apollo.mutate({ + mutation: gql` + mutation addTeamMemberByEmail( + $userRole: TeamMemberRole! + $userEmail: String! + $teamID: String! + ) { + addTeamMemberByEmail(userRole: $userRole, userEmail: $userEmail, teamID: $teamID) { + role + } + } + `, + variables: { + userRole: userRole, + userEmail: userEmail, + teamID: teamID, + }, + }) +} + +async function updateTeamMemberRole(apollo, userID, newRole, teamID) { + return apollo.mutate({ + mutation: gql` + mutation updateTeamMemberRole( + $newRole: TeamMemberRole! + $userUid: String! + $teamID: String! + ) { + updateTeamMemberRole(newRole: $newRole, userUid: $userUid, teamID: $teamID) { + role + } + } + `, + variables: { + newRole: newRole, + userUid: userID, + teamID: teamID, + }, + }) +} + +async function renameTeam(apollo, name, teamID) { + return apollo.mutate({ + mutation: gql` + mutation renameTeam($newName: String!, $teamID: String!) { + renameTeam(newName: $newName, teamID: $teamID) { + id + } + } + `, + variables: { + newName: name, + teamID: teamID, + }, + }) +} + +async function removeTeamMember(apollo, userID, teamID) { + return apollo.mutate({ + mutation: gql` + mutation removeTeamMember($userUid: String!, $teamID: String!) { + removeTeamMember(userUid: $userUid, teamID: $teamID) + } + `, + variables: { + userUid: userID, + teamID: teamID, + }, + }) +} + +async function deleteTeam(apollo, teamID) { + let response = undefined + while (true) { + response = await apollo.mutate({ + mutation: gql` + mutation($teamID: String!) { + deleteTeam(teamID: $teamID) + } + `, + variables: { + teamID: teamID, + }, + }) + if (response != undefined) break + } + return response +} + +async function exitTeam(apollo, teamID) { + apollo.mutate({ + mutation: gql` + mutation($teamID: String!) { + leaveTeam(teamID: $teamID) + } + `, + variables: { + teamID: teamID, + }, + }) +} + +async function rootCollectionsOfTeam(apollo, teamID) { + var collections = [] + var cursor = "" + while (true) { + var response = await apollo.query({ + query: gql` + query rootCollectionsOfTeam($teamID: String!, $cursor: String!) { + rootCollectionsOfTeam(teamID: $teamID, cursor: $cursor) { + id + title + } + } + `, + variables: { + teamID: teamID, + cursor: cursor, + }, + fetchPolicy: "no-cache", + }) + if (response.data.rootCollectionsOfTeam.length == 0) break + response.data.rootCollectionsOfTeam.forEach((collection) => { + collections.push(collection) + }) + cursor = collections[collections.length - 1].id + } + return collections +} + +async function getCollectionChildren(apollo, collectionID) { + var children = [] + var response = await apollo.query({ + query: gql` + query getCollectionChildren($collectionID: String!) { + collection(collectionID: $collectionID) { + children { + id + title + } + } + } + `, + variables: { + collectionID: collectionID, + }, + fetchPolicy: "no-cache", + }) + response.data.collection.children.forEach((child) => { + children.push(child) + }) + return children +} + +async function getCollectionRequests(apollo, collectionID) { + var requests = [] + var cursor = "" + while (true) { + var response = await apollo.query({ + query: gql` + query getCollectionRequests($collectionID: String!, $cursor: String) { + requestsInCollection(collectionID: $collectionID, cursor: $cursor) { + id + title + request + } + } + `, + variables: { + collectionID: collectionID, + cursor: cursor, + }, + fetchPolicy: "no-cache", + }) + + response.data.requestsInCollection.forEach((request) => { + requests.push(request) + }) + + if (response.data.requestsInCollection.length < 10) { + break + } + cursor = requests[requests.length - 1].id + } + return requests +} + +async function renameCollection(apollo, title, id) { + let response = undefined + while (true) { + response = await apollo.mutate({ + mutation: gql` + mutation($newTitle: String!, $collectionID: String!) { + renameCollection(newTitle: $newTitle, collectionID: $collectionID) { + id + } + } + `, + variables: { + newTitle: title, + collectionID: id, + }, + }) + if (response != undefined) break + } + return response +} + +async function updateRequest(apollo, request, requestName, requestID) { + let response = undefined + while (true) { + response = await apollo.mutate({ + mutation: gql` + mutation($data: UpdateTeamRequestInput!, $requestID: String!) { + updateRequest(data: $data, requestID: $requestID) { + id + } + } + `, + variables: { + data: { + request: JSON.stringify(request), + title: requestName, + }, + requestID: requestID, + }, + }) + if (response != undefined) break + } + return response +} + +async function addChildCollection(apollo, title, id) { + let response = undefined + while (true) { + response = await apollo.mutate({ + mutation: gql` + mutation($childTitle: String!, $collectionID: String!) { + createChildCollection(childTitle: $childTitle, collectionID: $collectionID) { + id + } + } + `, + variables: { + childTitle: title, + collectionID: id, + }, + }) + if (response != undefined) break + } + return response +} + +async function deleteCollection(apollo, id) { + let response = undefined + while (true) { + response = await apollo.mutate({ + mutation: gql` + mutation($collectionID: String!) { + deleteCollection(collectionID: $collectionID) + } + `, + variables: { + collectionID: id, + }, + }) + if (response != undefined) break + } + return response +} + +async function deleteRequest(apollo, requestID) { + let response = undefined + while (true) { + response = await apollo.mutate({ + mutation: gql` + mutation($requestID: String!) { + deleteRequest(requestID: $requestID) + } + `, + variables: { + requestID: requestID, + }, + }) + if (response != undefined) break + } + return response +} + +async function createNewRootCollection(apollo, title, id) { + let response = undefined + while (true) { + response = await apollo.mutate({ + mutation: gql` + mutation($title: String!, $teamID: String!) { + createRootCollection(title: $title, teamID: $teamID) { + id + } + } + `, + variables: { + title: title, + teamID: id, + }, + }) + if (response != undefined) break + } + return response +} + +async function saveRequestAsTeams(apollo, request, title, teamID, collectionID) { + await apollo.mutate({ + mutation: gql` + mutation($data: CreateTeamRequestInput!, $collectionID: String!) { + createRequestInCollection(data: $data, collectionID: $collectionID) { + collection { + id + team { + id + name + } + } + } + } + `, + variables: { + collectionID: collectionID, + data: { + teamID: teamID, + title: title, + request: request, + }, + }, + }) +} + +async function overwriteRequestTeams(apollo, request, title, requestID) { + await apollo.mutate({ + mutation: gql` + mutation updateRequest($data: UpdateTeamRequestInput!, $requestID: String!) { + updateRequest(data: $data, requestID: $requestID) { + id + title + } + } + `, + variables: { + requestID: requestID, + data: { + request: request, + title: title, + }, + }, + }) +} + +async function importFromMyCollections(apollo, collectionID, teamID) { + let response = await apollo.mutate({ + mutation: gql` + mutation importFromMyCollections($fbCollectionPath: String!, $teamID: String!) { + importCollectionFromUserFirestore(fbCollectionPath: $fbCollectionPath, teamID: $teamID) { + id + title + } + } + `, + variables: { + fbCollectionPath: collectionID, + teamID: teamID, + }, + }) + return response.data != null +} + +async function importFromJSON(apollo, collections, teamID) { + let response = await apollo.mutate({ + mutation: gql` + mutation importFromJSON($jsonString: String!, $teamID: String!) { + importCollectionsFromJSON(jsonString: $jsonString, teamID: $teamID) + } + `, + variables: { + jsonString: JSON.stringify(collections), + teamID: teamID, + }, + }) + return response.data != null +} + +async function replaceWithJSON(apollo, collections, teamID) { + let response = await apollo.mutate({ + mutation: gql` + mutation replaceWithJSON($jsonString: String!, $teamID: String!) { + replaceCollectionsWithJSON(jsonString: $jsonString, teamID: $teamID) + } + `, + variables: { + jsonString: JSON.stringify(collections), + teamID: teamID, + }, + }) + return response.data != null +} + +async function exportAsJSON(apollo, teamID) { + let response = await apollo.query({ + query: gql` + query exportAsJSON($teamID: String!) { + exportCollectionsToJSON(teamID: $teamID) + } + `, + variables: { + teamID: teamID, + }, + }) + return response.data.exportCollectionsToJSON +} + +export default { + rootCollectionsOfTeam: rootCollectionsOfTeam, + getCollectionChildren: getCollectionChildren, + getCollectionRequests: getCollectionRequests, + saveRequestAsTeams: saveRequestAsTeams, + overwriteRequestTeams: overwriteRequestTeams, + importFromMyCollections: importFromMyCollections, + importFromJSON: importFromJSON, + replaceWithJSON: replaceWithJSON, + exportAsJSON: exportAsJSON, + renameCollection: renameCollection, + updateRequest: updateRequest, + addChildCollection: addChildCollection, + deleteCollection: deleteCollection, + deleteRequest: deleteRequest, + createNewRootCollection: createNewRootCollection, + createTeam: createTeam, + addTeamMemberByEmail: addTeamMemberByEmail, + renameTeam: renameTeam, + deleteTeam: deleteTeam, + exitTeam: exitTeam, + updateTeamMemberRole: updateTeamMemberRole, + removeTeamMember: removeTeamMember, +} diff --git a/lang/en-US.json b/lang/en-US.json index b32e93d64..1d86c5d73 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -305,5 +305,30 @@ "account_exists": "Account exists with different credential - Login to link both accounts", "confirm": "Confirm", "new_version_found": "New version found. Refresh to update.", - "size": "Size" + "size": "Size", + "exit": "Exit Team", + "string_length_insufficient": "Team name should be atleast 6 characters long", + "invalid_emailID_format": "Email ID format is invalid", + "teams": "Teams", + "new_team": "New Team", + "my_new_team": "My New Team", + "edit_team": "Edit Team", + "team_member_list": "Member List", + "invalid_team_name": "Please provide a valid name for the team", + "use_team": "Use Team", + "add_one_member": "(add at least one member)", + "permissions": "Permissions", + "email": "E-mail", + "create_new_team": "Create new team", + "new_team_created": "New team created", + "team_saved": "Team saved", + "team_name_empty": "Team name empty", + "disable_new_collection": "You do not have edit access to these collections", + "collection_added": "Collection added successfully", + "folder_added": "Folder added successfully", + "team_exited": "Team exited", + "disable_exit": "Only owner cannot exit the team", + "folder_renamed": "Folder renamed successfully", + "role_updated": "User role(s) updated successfully", + "user_removed": "User removed successfully" } diff --git a/layouts/default.vue b/layouts/default.vue index 17116bd0e..f7159a38e 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -14,6 +14,7 @@ From 3bbf334f99a754777b525576417343e6d6080a01 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Tue, 11 May 2021 05:49:36 +0000 Subject: [PATCH 19/36] refactor: separate folders for team and personal collections --- components/collections/ChooseType.vue | 2 +- components/collections/Folder.vue | 499 -------------------- components/collections/graphql/Folder.vue | 2 +- components/collections/index.vue | 8 +- components/collections/my/Collection.vue | 2 +- components/collections/my/Folder.vue | 211 +++++++++ components/collections/teams/Collection.vue | 6 +- components/collections/teams/Folder.vue | 208 ++++++++ 8 files changed, 432 insertions(+), 506 deletions(-) delete mode 100644 components/collections/Folder.vue create mode 100644 components/collections/my/Folder.vue create mode 100644 components/collections/teams/Folder.vue diff --git a/components/collections/ChooseType.vue b/components/collections/ChooseType.vue index 89a5676f7..a726703ba 100644 --- a/components/collections/ChooseType.vue +++ b/components/collections/ChooseType.vue @@ -46,7 +46,7 @@ export default { } } `, - pollInterval: 10000, + pollInterval: 5000, }, }, methods: { diff --git a/components/collections/Folder.vue b/components/collections/Folder.vue deleted file mode 100644 index 3abf2adea..000000000 --- a/components/collections/Folder.vue +++ /dev/null @@ -1,499 +0,0 @@ - - - diff --git a/components/collections/graphql/Folder.vue b/components/collections/graphql/Folder.vue index b20d152d2..8a0a8ce32 100644 --- a/components/collections/graphql/Folder.vue +++ b/components/collections/graphql/Folder.vue @@ -52,7 +52,7 @@

-
    +
    @@ -269,6 +269,9 @@ export default { document.addEventListener("keydown", this._keyListener.bind(this)) this.$subscribeTo(this.teamCollectionAdapter.collections$, (colls) => { + console.log("new tree!") + console.log(colls) + this.teamCollectionsNew = cloneDeep(colls) }) }, @@ -550,8 +553,7 @@ export default { console.log(collectionID) this.teamCollectionAdapter.expandCollection(collectionID) }, - removeCollection(collectionsType, collectionIndex, collectionID) { - console.log("removing") + removeCollection({ collectionsType, collectionIndex, collectionID }) { if (collectionsType.type == "my-collections") { this.$store.commit("postwoman/removeCollection", { collectionIndex: collectionIndex, diff --git a/components/collections/my/Collection.vue b/components/collections/my/Collection.vue index 04fe27909..1cfa96d4e 100644 --- a/components/collections/my/Collection.vue +++ b/components/collections/my/Collection.vue @@ -70,7 +70,7 @@ :key="index" class="ml-8 border-l border-brdColor" > - +
    +
    +
    + +
    + + + + +
    +
    +
      +
    • + +
    • +
    +
      +
    • + +
    • +
    +
      +
    • +

      not_interested {{ $t("folder_empty") }}

      +
    • +
    +
    + +
    + + + diff --git a/components/collections/teams/Collection.vue b/components/collections/teams/Collection.vue index 3fa309c2f..77250ef07 100644 --- a/components/collections/teams/Collection.vue +++ b/components/collections/teams/Collection.vue @@ -77,7 +77,7 @@ :key="folder.title" class="ml-8 border-l border-brdColor" > -
@@ -199,6 +200,9 @@ export default { }) this.confirmRemove = false }, + expandCollection(collectionID) { + this.$emit("expand-collection", collectionID) + }, }, } diff --git a/components/collections/teams/Folder.vue b/components/collections/teams/Folder.vue new file mode 100644 index 000000000..e25de9cda --- /dev/null +++ b/components/collections/teams/Folder.vue @@ -0,0 +1,208 @@ + + + From c756be54a1ed7e15472078ac0fb8806706479e65 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Tue, 11 May 2021 13:10:36 +0000 Subject: [PATCH 20/36] refactor: separate request components for team & my collections --- components/collections/my/Collection.vue | 2 +- components/collections/my/Folder.vue | 2 +- components/collections/{ => my}/Request.vue | 39 ++---- components/collections/teams/Collection.vue | 2 +- components/collections/teams/Folder.vue | 2 +- components/collections/teams/Request.vue | 140 ++++++++++++++++++++ 6 files changed, 154 insertions(+), 33 deletions(-) rename components/collections/{ => my}/Request.vue (78%) create mode 100644 components/collections/teams/Request.vue diff --git a/components/collections/my/Collection.vue b/components/collections/my/Collection.vue index 1cfa96d4e..a85bbe819 100644 --- a/components/collections/my/Collection.vue +++ b/components/collections/my/Collection.vue @@ -98,7 +98,7 @@ :key="index" class="ml-8 border-l border-brdColor" > - - { - // Result - this.$toast.success(this.$t("deleted"), { - icon: "delete", - }) - }) - .catch((error) => { - // Error - this.$toast.error(this.$t("error_occurred"), { - icon: "done", - }) - console.error(error) - }) - this.$data.confirmRemove = false - } + this.$store.commit("postwoman/removeRequest", { + collectionIndex: this.$props.collectionIndex, + folderName: this.$props.folderName, + requestIndex: this.$props.requestIndex, + flag: "rest", + }) + this.$toast.error(this.$t("deleted"), { + icon: "delete", + }) + this.syncCollections() }, getRequestLabelColor(method) { return this.requestMethodLabels[method.toLowerCase()] || this.requestMethodLabels.default diff --git a/components/collections/teams/Collection.vue b/components/collections/teams/Collection.vue index 77250ef07..3954ed822 100644 --- a/components/collections/teams/Collection.vue +++ b/components/collections/teams/Collection.vue @@ -106,7 +106,7 @@ :key="index" class="ml-8 border-l border-brdColor" > - - +
+
+
+ +
+ + + + +
+ +
+ + + From 853acfda2c40b9bfd7abcdf3db4ba56cefa91e40 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Tue, 11 May 2021 23:38:47 -0400 Subject: [PATCH 21/36] Introduce Intersection component --- components/smart/Intersection.vue | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 components/smart/Intersection.vue diff --git a/components/smart/Intersection.vue b/components/smart/Intersection.vue new file mode 100644 index 000000000..047015bb7 --- /dev/null +++ b/components/smart/Intersection.vue @@ -0,0 +1,36 @@ + + From dd3b51d0b7698793bcb021e916db45d51a166932 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Tue, 11 May 2021 23:39:23 -0400 Subject: [PATCH 22/36] Use Intersection component to fetch team list on visibility --- components/collections/ChooseType.vue | 36 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/components/collections/ChooseType.vue b/components/collections/ChooseType.vue index a726703ba..89222ca28 100644 --- a/components/collections/ChooseType.vue +++ b/components/collections/ChooseType.vue @@ -6,20 +6,22 @@
  • - + + +
@@ -46,10 +48,14 @@ export default { } } `, - pollInterval: 5000, + pollInterval: 10000, }, }, methods: { + onTeamSelectIntersect() { + // Load team data as soon as intersection + this.$apollo.queries.myTeams.refetch() + }, updateCollectionsType(tabID) { this.$emit("update-collection-type", tabID) }, From 2ff0f97295bd75af66c91eddecfb8770a0ae4340 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Wed, 12 May 2021 05:33:15 +0000 Subject: [PATCH 23/36] refactor: request actions + fix: timeout bug --- components/collections/index.vue | 31 ++++++++ components/collections/my/Collection.vue | 9 +++ components/collections/my/Folder.vue | 9 +++ components/collections/my/Request.vue | 20 +---- components/collections/teams/Collection.vue | 9 +++ components/collections/teams/Folder.vue | 9 +++ components/collections/teams/Request.vue | 41 ++-------- components/teams/Edit.vue | 13 +++- components/teams/Team.vue | 6 +- helpers/apollo.ts | 83 ++++++++++----------- 10 files changed, 128 insertions(+), 102 deletions(-) diff --git a/components/collections/index.vue b/components/collections/index.vue index 4772ab5bd..70f256489 100644 --- a/components/collections/index.vue +++ b/components/collections/index.vue @@ -124,6 +124,7 @@ @unselect-collection="$emit('remove-collection', collection)" @expand-collection="expandCollection" @remove-collection="removeCollection" + @remove-request="removeRequest" /> @@ -595,6 +596,36 @@ export default { } } }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + if (this.collectionsType.type == "my-collections") { + this.$store.commit("postwoman/removeRequest", { + collectionIndex: collectionIndex, + folderName: folderName, + requestIndex: requestIndex, + flag: "rest", + }) + this.$toast.error(this.$t("deleted"), { + icon: "delete", + }) + this.syncCollections() + } else if (this.collectionsType.type == "team-collections") { + team_utils + .deleteRequest(this.$apollo, requestIndex) + .then((data) => { + // Result + this.$toast.success(this.$t("deleted"), { + icon: "delete", + }) + }) + .catch((error) => { + // Error + this.$toast.error(this.$t("error_occurred"), { + icon: "done", + }) + console.error(error) + }) + } + }, }, beforeDestroy() { document.removeEventListener("keydown", this._keyListener) diff --git a/components/collections/my/Collection.vue b/components/collections/my/Collection.vue index a85bbe819..d9bf8426b 100644 --- a/components/collections/my/Collection.vue +++ b/components/collections/my/Collection.vue @@ -89,6 +89,7 @@ reqIdx: $event.reqIdx, }) " + @remove-request="removeRequest" /> @@ -115,6 +116,7 @@ reqIdx: $event.idx, }) " + @remove-request="removeRequest" /> @@ -224,6 +226,13 @@ export default { }) this.syncCollections() }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + this.$emit("remove-request", { + collectionIndex, + folderName, + requestIndex, + }) + }, }, } diff --git a/components/collections/my/Folder.vue b/components/collections/my/Folder.vue index cdb7fdbfa..7a1fd8ea4 100644 --- a/components/collections/my/Folder.vue +++ b/components/collections/my/Folder.vue @@ -77,6 +77,7 @@ reqIdx: $event.reqIdx, }) " + @remove-request="removeRequest" /> @@ -103,6 +104,7 @@ reqIdx: $event.idx, }) " + @remove-request="removeRequest" /> @@ -206,6 +208,13 @@ export default { }) this.syncCollections() }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + this.$emit("remove-request", { + collectionIndex, + folderName, + requestIndex, + }) + }, }, } diff --git a/components/collections/my/Request.vue b/components/collections/my/Request.vue index f43e7c2d0..4d49f3845 100644 --- a/components/collections/my/Request.vue +++ b/components/collections/my/Request.vue @@ -88,20 +88,7 @@ export default { confirmRemove: false, } }, - subscriptions() { - return { - SYNC_COLLECTIONS: getSettingSubject("syncCollections"), - } - }, methods: { - syncCollections() { - if (fb.currentUser !== null && this.SYNC_COLLECTIONS) { - fb.writeCollections( - JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)), - "collections" - ) - } - }, selectRequest() { if (this.$props.saveRequest) this.$emit("select-request", { @@ -118,16 +105,11 @@ export default { dataTransfer.setData("requestIndex", this.$props.requestIndex) }, removeRequest() { - this.$store.commit("postwoman/removeRequest", { + this.$emit("remove-request", { collectionIndex: this.$props.collectionIndex, folderName: this.$props.folderName, requestIndex: this.$props.requestIndex, - flag: "rest", }) - this.$toast.error(this.$t("deleted"), { - icon: "delete", - }) - this.syncCollections() }, getRequestLabelColor(method) { return this.requestMethodLabels[method.toLowerCase()] || this.requestMethodLabels.default diff --git a/components/collections/teams/Collection.vue b/components/collections/teams/Collection.vue index 3954ed822..ac81803b3 100644 --- a/components/collections/teams/Collection.vue +++ b/components/collections/teams/Collection.vue @@ -97,6 +97,7 @@ }) " @expand-collection="expandCollection" + @remove-request="removeRequest" /> @@ -123,6 +124,7 @@ reqIdx: $event.idx, }) " + @remove-request="removeRequest" /> @@ -203,6 +205,13 @@ export default { expandCollection(collectionID) { this.$emit("expand-collection", collectionID) }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + this.$emit("remove-request", { + collectionIndex, + folderName, + requestIndex, + }) + }, }, } diff --git a/components/collections/teams/Folder.vue b/components/collections/teams/Folder.vue index b9f363025..758fd3ea6 100644 --- a/components/collections/teams/Folder.vue +++ b/components/collections/teams/Folder.vue @@ -81,6 +81,7 @@ }) " @expand-collection="expandCollection" + @remove-request="removeRequest" /> @@ -107,6 +108,7 @@ reqIdx: $event.idx, }) " + @remove-request="removeRequest" /> @@ -203,6 +205,13 @@ export default { expandCollection(collectionID) { this.$emit("expand-collection", collectionID) }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + this.$emit("remove-request", { + collectionIndex, + folderName, + requestIndex, + }) + }, }, } diff --git a/components/collections/teams/Request.vue b/components/collections/teams/Request.vue index 14ef67d73..8ea33cbb4 100644 --- a/components/collections/teams/Request.vue +++ b/components/collections/teams/Request.vue @@ -85,20 +85,7 @@ export default { confirmRemove: false, } }, - subscriptions() { - return { - SYNC_COLLECTIONS: getSettingSubject("syncCollections"), - } - }, methods: { - syncCollections() { - if (fb.currentUser !== null && this.SYNC_COLLECTIONS) { - fb.writeCollections( - JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)), - "collections" - ) - } - }, selectRequest() { if (this.$props.saveRequest) this.$emit("select-request", { @@ -107,30 +94,12 @@ export default { }) else this.$store.commit("postwoman/selectRequest", { request: this.request }) }, - dragStart({ dataTransfer }) { - this.dragging = !this.dragging - dataTransfer.setData("oldCollectionIndex", this.$props.collectionIndex) - dataTransfer.setData("oldFolderIndex", this.$props.folderIndex) - dataTransfer.setData("oldFolderName", this.$props.folderName) - dataTransfer.setData("requestIndex", this.$props.requestIndex) - }, removeRequest() { - team_utils - .deleteRequest(this.$apollo, this.$props.requestIndex) - .then((data) => { - // Result - this.$toast.success(this.$t("deleted"), { - icon: "delete", - }) - }) - .catch((error) => { - // Error - this.$toast.error(this.$t("error_occurred"), { - icon: "done", - }) - console.error(error) - }) - this.$data.confirmRemove = false + this.$emit("remove-request", { + collectionIndex: this.$props.collectionIndex, + folderName: this.$props.folderName, + requestIndex: this.$props.requestIndex, + }) }, getRequestLabelColor(method) { return this.requestMethodLabels[method.toLowerCase()] || this.requestMethodLabels.default diff --git a/components/teams/Edit.vue b/components/teams/Edit.vue index f80fda497..a40f77e0a 100644 --- a/components/teams/Edit.vue +++ b/components/teams/Edit.vue @@ -6,7 +6,7 @@

{{ $t("edit_team") }}

-
@@ -53,15 +53,17 @@ />