Skip to content

Commit

Permalink
Merge pull request #649 from avantifellows/copy_from_workspace_to_wor…
Browse files Browse the repository at this point in the history
…kspace

allow copy from one workspace to another
  • Loading branch information
deepansh96 authored May 12, 2024
2 parents 1b3b4ad + c608b82 commit a643248
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
10 changes: 9 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 10 additions & 6 deletions src/components/Collections/ListItems/PlioListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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({
Expand Down
4 changes: 4 additions & 0 deletions src/pages/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand All @@ -141,6 +144,7 @@ export default {
},
methods: {
...mapActions("sync", ["startLoading", "stopLoading"]),
...mapActions("auth", ["setActiveWorkspace"]),
plioDeleted() {
// invoked when a plio is deleted
Expand Down
13 changes: 11 additions & 2 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -168,7 +172,12 @@ 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 != "")
if (
existingActiveWorkspace != "" && (
to.params.workspace == undefined ||
to.params.workspace == ""
)
)
to.params.workspace = existingActiveWorkspace;

if (to.matched.some((record) => record.meta.requiresAuth)) {
Expand Down

0 comments on commit a643248

Please sign in to comment.