Skip to content

Commit

Permalink
simplify team dispatch calls
Browse files Browse the repository at this point in the history
  • Loading branch information
cstns committed Dec 19, 2024
1 parent 5bf6a22 commit 5da7751
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
14 changes: 6 additions & 8 deletions frontend/src/components/TeamSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ export default {
methods: {
selectTeam (team) {
if (team) {
this.$store.dispatch('account/setTeam', team.slug)
.then(() => this.$router.push({
name: 'Team',
params: {
team_slug: team.slug
}
}))
.catch(e => console.warn(e))
this.$router.push({
name: 'Team',
params: {
team_slug: team.slug
}
})
}
},
createTeam () {
Expand Down
14 changes: 6 additions & 8 deletions frontend/src/pages/account/Teams/Invitations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ export default {
await this.$store.dispatch('account/refreshTeams')
Alerts.emit(`Invite to "${invite.team.name}" has been accepted.`, 'confirmation')
// navigate to team dashboad once invite accepted
this.$store.dispatch('account/setTeam', invite.team.slug)
.then(() => this.$router.push({
name: 'Team',
params: {
team_slug: invite.team.slug
}
}))
.catch(e => console.warn(e))
this.$router.push({
name: 'Team',
params: {
team_slug: invite.team.slug
}
})
},
async rejectInvite (invite) {
await userApi.rejectTeamInvitation(invite.id, invite.team.id)
Expand Down
14 changes: 6 additions & 8 deletions frontend/src/pages/admin/Teams.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,12 @@ export default {
this.loading = false
},
viewTeam (row) {
this.$store.dispatch('account/setTeam', row.slug)
.then(() => this.$router.push({
name: 'Team',
params: {
team_slug: row.slug
}
}))
.catch(e => console.warn(e))
this.$router.push({
name: 'Team',
params: {
team_slug: row.slug
}
})
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/pages/team/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ export default {
return this.isAdminUser || this.teamMembership?.role >= Roles.Viewer
}
},
watch: {
'$route.params.team_slug' (slug) {
this.$store.dispatch('account/setTeam', slug)
}
},
mounted () {
this.mounted = true
},
Expand Down

0 comments on commit 5da7751

Please sign in to comment.