From 5a2962abf2faafc97eb25c12cfd532a60b03d4ad Mon Sep 17 00:00:00 2001 From: Deepansh Mathur Date: Sat, 11 May 2024 21:28:17 +0530 Subject: [PATCH 1/2] allow copy from one workspace to another --- src/App.vue | 10 +++++++++- .../Collections/ListItems/PlioListItem.vue | 16 ++++++++++------ src/pages/Home.vue | 4 ++++ src/router/index.js | 15 +++++++++++++-- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/App.vue b/src/App.vue index deb58496c..0ee0283e0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -838,7 +838,15 @@ export default { }) .then(() => { this.hideSpinner(); - this.$router.push({ name: "Home", params: { workspace: selectedOptionValue } }); + // this.$router.push({ name: "Home", params: { workspace: selectedOptionValue } }); + // earlier this used to reload in place, but now we want to open in a new tab + // because if someone is copying multiple plios to another workspace, they shouldn't have to + // go back and forth between the workspaces + const routeData = this.$router.resolve({ + name: "Home", + params: { workspace: selectedOptionValue } + }); + window.open(routeData.href, '_blank'); }) .catch(() => { this.hideSpinner(); diff --git a/src/components/Collections/ListItems/PlioListItem.vue b/src/components/Collections/ListItems/PlioListItem.vue index 34b6ec826..131e2a1b4 100644 --- a/src/components/Collections/ListItems/PlioListItem.vue +++ b/src/components/Collections/ListItems/PlioListItem.vue @@ -129,7 +129,7 @@ export default { }, computed: { ...mapState("auth", ["activeWorkspace"]), - ...mapGetters("auth", ["isPersonalWorkspace", "hasWorkspaces", "workspaces"]), + ...mapGetters("auth", ["isPersonalWorkspace", "hasWorkspaces", "workspaces", "activeWorkspaceDetails"]), ...mapState("sync", ["pending"]), ...mapState("generic", ["selectedPlioId"]), ...mapGetters("generic", ["isTabScreen"]), @@ -215,7 +215,9 @@ export default { icon: "delete2.svg", }, ]; - if (this.inPersonalWorkspaceWithOtherWorkspaces) + + // now we allow people to copy plios from one workspace to another, given they are part of those workspaces + // if (this.inPersonalWorkspaceWithOtherWorkspaces) options.push({ value: "copy", label: this.$t("home.table.plio_list_item.buttons.copy"), @@ -406,10 +408,12 @@ export default { case "copy": { let selectorOptions = []; this.workspaces.forEach((workspace) => { - selectorOptions.push({ - value: workspace.shortcode, - label: workspace.name, - }); + if (workspace.shortcode != this.activeWorkspaceDetails.shortcode) { + selectorOptions.push({ + value: workspace.shortcode, + label: workspace.name, + }); + } }); await this.setSelectedPlioId(this.plioId); this.showSelector({ diff --git a/src/pages/Home.vue b/src/pages/Home.vue index ec114dc9d..35f710bd1 100644 --- a/src/pages/Home.vue +++ b/src/pages/Home.vue @@ -118,6 +118,9 @@ export default { this.tableData = this.dummyTableData; await this.fetchPlios(); this.$mixpanel.track("Visit Home"); + if (this.workspace) { + this.setActiveWorkspace(this.workspace); + } }, computed: { ...mapState("auth", ["activeWorkspace", "userSettings"]), @@ -141,6 +144,7 @@ export default { }, methods: { ...mapActions("sync", ["startLoading", "stopLoading"]), + ...mapActions("auth", ["setActiveWorkspace"]), plioDeleted() { // invoked when a plio is deleted diff --git a/src/router/index.js b/src/router/index.js index f23351ba5..7c6707deb 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -23,7 +23,11 @@ const routes = [ path: "/:workspace?/home", name: "Home", component: () => import(/* webpackChunkName: "home" */ "@/pages/Home.vue"), - props: true, + props: (route) => { + return { + workspace: route.params.workspace, + } + }, meta: { requiresAuth: true, title: "Home - Plio", @@ -168,7 +172,13 @@ router.beforeEach((to, from) => { // are not explicitly specified in the requested URL. This will lead them to the workspace's home // where they left off the in the previous session const existingActiveWorkspace = store.state["auth"]["activeWorkspace"]; - if (existingActiveWorkspace != "" && to.params.workspace != "") + console.log(existingActiveWorkspace, to.params.workspace); + if ( + existingActiveWorkspace != "" && ( + to.params.workspace == undefined || + to.params.workspace == "" + ) + ) to.params.workspace = existingActiveWorkspace; if (to.matched.some((record) => record.meta.requiresAuth)) { @@ -238,6 +248,7 @@ router.beforeEach((to, from) => { // set workspace in vuex state if the route workspace parameter is in vuex user organizations array router.beforeEach((to) => { if (store.getters["auth/isAuthenticated"]) { + console.log(to.params.workspace); if (to.params.workspace != "" && to.params.workspace != undefined) store.dispatch("auth/setActiveWorkspace", to.params.workspace); else store.dispatch("auth/unsetActiveWorkspace"); From c608b82ae0203ca8fb8fc6b1b6eb4692ec9ef220 Mon Sep 17 00:00:00 2001 From: Deepansh Mathur Date: Sat, 11 May 2024 21:32:40 +0530 Subject: [PATCH 2/2] some console log statements removed --- src/router/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 7c6707deb..a83bd51ea 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -172,7 +172,6 @@ router.beforeEach((to, from) => { // are not explicitly specified in the requested URL. This will lead them to the workspace's home // where they left off the in the previous session const existingActiveWorkspace = store.state["auth"]["activeWorkspace"]; - console.log(existingActiveWorkspace, to.params.workspace); if ( existingActiveWorkspace != "" && ( to.params.workspace == undefined || @@ -248,7 +247,6 @@ router.beforeEach((to, from) => { // set workspace in vuex state if the route workspace parameter is in vuex user organizations array router.beforeEach((to) => { if (store.getters["auth/isAuthenticated"]) { - console.log(to.params.workspace); if (to.params.workspace != "" && to.params.workspace != undefined) store.dispatch("auth/setActiveWorkspace", to.params.workspace); else store.dispatch("auth/unsetActiveWorkspace");