Commit 88b60cf6 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Handle leave group action

parent 184e67da
......@@ -20,6 +20,16 @@ export default {
return eventHub.$emit('toggleSubGroups', this.group);
},
onLeaveGroup(e) {
e.preventDefault();
if (confirm(`Are you sure you want to leave the "${this.group.fullName}" group?`)) {
this.leaveGroup();
}
},
leaveGroup() {
eventHub.$emit('leaveGroup', this.group.leavePath);
}
},
computed: {
groupDomId() {
......@@ -73,10 +83,13 @@ export default {
:class="rowClass"
>
<div class="controls">
<a class="edit-group btn" href="#edit">
<a class="edit-group btn" :href="group.editPath">
<i aria-hidden="true" class="fa fa-cogs"></i>
</a>
<a class="leave-group btn" title="Leave this group" href="#leave">
<a @click="onLeaveGroup"
:href="group.leavePath"
class="leave-group btn"
title="Leave this group">
<i aria-hidden="true" class="fa fa-sign-out"></i>
</a>
</div>
......
......@@ -52,7 +52,7 @@ $(() => {
store.setGroups(response.json(), parentGroup);
})
.catch(() => {
// TODO: Handler error
// TODO: Handle error
});
return getGroups;
......@@ -65,6 +65,15 @@ $(() => {
GroupsStore.toggleSubGroups(parentGroup);
},
leaveGroup(endpoint) {
service.leaveGroup(endpoint)
.then(() => {
// TODO: Refresh?
})
.catch(() => {
// TODO: Handle error
});
},
},
created() {
let groupFilterList = null;
......@@ -81,6 +90,7 @@ $(() => {
});
eventHub.$on('toggleSubGroups', this.toggleSubGroups);
eventHub.$on('leaveGroup', this.leaveGroup);
},
});
});
......@@ -6,6 +6,7 @@ Vue.use(VueResource);
export default class GroupsService {
constructor(endpoint) {
this.groups = Vue.resource(endpoint);
this.groups = Vue.resource(endpoint);
}
getGroups(parentId, page) {
......@@ -20,4 +21,8 @@ export default class GroupsService {
return this.groups.get(data);
}
leaveGroup(endpoint) {
return Vue.http.delete(endpoint);
}
}
......@@ -121,6 +121,8 @@ export default class GroupsStore {
webUrl: rawGroup.web_url,
parentId: rawGroup.parent_id,
visibility: rawGroup.visibility,
leavePath: rawGroup.leave_path,
editPath: rawGroup.edit_path,
isOpen: false,
isOrphan: false,
numberProjects: 10,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment