diff --git a/src/components/namespaces/EditNamespace.vue b/src/components/namespaces/EditNamespace.vue
index 49348824..30910144 100644
--- a/src/components/namespaces/EditNamespace.vue
+++ b/src/components/namespaces/EditNamespace.vue
@@ -41,158 +41,9 @@
-
+
-
-
-
-
-
-
- {{u.username}}
-
-
- You
-
-
-
-
-
-
-
- Admin
-
-
-
-
-
- Write
-
-
-
-
-
- Read-only
-
-
-
-
- Make
-
- Member
-
-
- Admin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{t.name}}
-
-
-
-
-
-
-
- Admin
-
-
-
-
-
- Write
-
-
-
-
-
- Read-only
-
-
-
-
- Make
-
- Member
-
-
- Admin
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Are you sure you want to delete this namespace and all of its contents?
This includes lists & tasks and CANNOT BE UNDONE!
-
-
-
- Remove a user from the namespace
- Are you sure you want to remove this user from the namespace?
- This CANNOT BE UNDONE!
-
-
-
-
- Remove a team from the namespace
- Are you sure you want to remove this team from the namespace?
- This CANNOT BE UNDONE!
-
@@ -230,6 +61,8 @@
import router from '../../router'
import {HTTP} from '../../http-common'
import message from '../../message'
+ import manageusers from '../sharing/user'
+ import manageteams from '../sharing/team'
export default {
name: "EditNamespace",
@@ -241,23 +74,19 @@
showDeleteModal: false,
user: auth.user,
userIsAdmin: false,
-
- namespaceUsers: [],
- newUser: {user_id: 0},
- showUserDeleteModal: false,
- userToDelete: 0,
-
- namespaceTeams: [],
- newTeam: {team_id: 0},
- showTeamDeleteModal: false,
- teamToDelete: 0,
}
},
+ components: {
+ manageusers,
+ manageteams,
+ },
beforeMount() {
// Check if the user is already logged in, if so, redirect him to the homepage
if (!auth.user.authenticated) {
router.push({name: 'home'})
}
+
+ this.namespace.id = this.$route.params.id
},
created() {
this.loadNamespace()
@@ -276,8 +105,6 @@
if (response.data.owner.id === this.user.infos.id) {
this.userIsAdmin = true
}
- this.loadUsers()
- this.loadTeams()
this.loading = false
})
.catch(e => {
@@ -312,97 +139,6 @@
this.handleError(e)
})
},
- loadUsers() {
- HTTP.get(`namespaces/` + this.$route.params.id + `/users`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
- .then(response => {
- response.data.push(this.namespace.owner)
- this.$set(this, 'namespaceUsers', response.data)
- this.loading = false
- })
- .catch(e => {
- this.handleError(e)
- })
- },
- deleteUser() {
- HTTP.delete(`namespaces/` + this.$route.params.id + `/users/` + this.userToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
- .then(() => {
- this.showUserDeleteModal = false;
- this.handleSuccess({message: 'The user was successfully deleted from the namespace.'})
- this.loadUsers()
- })
- .catch(e => {
- this.handleError(e)
- })
- },
- addUser(admin) {
- if(admin === null) {
- admin = false
- }
- this.newUser.right = 0
- if (admin) {
- this.newUser.right = 2
- }
-
- HTTP.put(`namespaces/` + this.$route.params.id + `/users`, this.newUser, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
- .then(() => {
- this.loadUsers()
- this.handleSuccess({message: 'The user was successfully added.'})
- })
- .catch(e => {
- this.handleError(e)
- })
- },
- toggleUserType(userid, current) {
- this.userToDelete = userid
- this.newUser.user_id = userid
- this.deleteUser()
- this.addUser(!current)
- },
- loadTeams() {
- HTTP.get(`namespaces/` + this.$route.params.id + `/teams`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
- .then(response => {
- this.$set(this, 'namespaceTeams', response.data)
- this.loading = false
- })
- .catch(e => {
- this.handleError(e)
- })
- },
- deleteTeam() {
- HTTP.delete(`namespaces/` + this.$route.params.id + `/teams/` + this.teamToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
- .then(() => {
- this.showTeamDeleteModal = false;
- this.handleSuccess({message: 'The team was successfully deleted from the namespace.'})
- this.loadTeams()
- })
- .catch(e => {
- this.handleError(e)
- })
- },
- addTeam(admin) {
- if(admin === null) {
- admin = false
- }
- this.newTeam.right = 0
- if (admin) {
- this.newTeam.right = 2
- }
-
- HTTP.put(`namespaces/` + this.$route.params.id + `/teams`, this.newTeam, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
- .then(() => {
- this.loadTeams()
- this.handleSuccess({message: 'The team was successfully added.'})
- })
- .catch(e => {
- this.handleError(e)
- })
- },
- toggleTeamType(teamid, current) {
- this.teamToDelete = teamid
- this.newTeam.team_id = teamid
- this.deleteTeam()
- this.addTeam(!current)
- },
handleError(e) {
this.loading = false
message.error(e, this)