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

Handle leave group action

parent 184e67da
...@@ -20,6 +20,16 @@ export default { ...@@ -20,6 +20,16 @@ export default {
return eventHub.$emit('toggleSubGroups', this.group); 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: { computed: {
groupDomId() { groupDomId() {
...@@ -73,10 +83,13 @@ export default { ...@@ -73,10 +83,13 @@ export default {
:class="rowClass" :class="rowClass"
> >
<div class="controls"> <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> <i aria-hidden="true" class="fa fa-cogs"></i>
</a> </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> <i aria-hidden="true" class="fa fa-sign-out"></i>
</a> </a>
</div> </div>
......
...@@ -52,7 +52,7 @@ $(() => { ...@@ -52,7 +52,7 @@ $(() => {
store.setGroups(response.json(), parentGroup); store.setGroups(response.json(), parentGroup);
}) })
.catch(() => { .catch(() => {
// TODO: Handler error // TODO: Handle error
}); });
return getGroups; return getGroups;
...@@ -65,6 +65,15 @@ $(() => { ...@@ -65,6 +65,15 @@ $(() => {
GroupsStore.toggleSubGroups(parentGroup); GroupsStore.toggleSubGroups(parentGroup);
}, },
leaveGroup(endpoint) {
service.leaveGroup(endpoint)
.then(() => {
// TODO: Refresh?
})
.catch(() => {
// TODO: Handle error
});
},
}, },
created() { created() {
let groupFilterList = null; let groupFilterList = null;
...@@ -81,6 +90,7 @@ $(() => { ...@@ -81,6 +90,7 @@ $(() => {
}); });
eventHub.$on('toggleSubGroups', this.toggleSubGroups); eventHub.$on('toggleSubGroups', this.toggleSubGroups);
eventHub.$on('leaveGroup', this.leaveGroup);
}, },
}); });
}); });
...@@ -6,6 +6,7 @@ Vue.use(VueResource); ...@@ -6,6 +6,7 @@ Vue.use(VueResource);
export default class GroupsService { export default class GroupsService {
constructor(endpoint) { constructor(endpoint) {
this.groups = Vue.resource(endpoint); this.groups = Vue.resource(endpoint);
this.groups = Vue.resource(endpoint);
} }
getGroups(parentId, page) { getGroups(parentId, page) {
...@@ -20,4 +21,8 @@ export default class GroupsService { ...@@ -20,4 +21,8 @@ export default class GroupsService {
return this.groups.get(data); return this.groups.get(data);
} }
leaveGroup(endpoint) {
return Vue.http.delete(endpoint);
}
} }
...@@ -121,6 +121,8 @@ export default class GroupsStore { ...@@ -121,6 +121,8 @@ export default class GroupsStore {
webUrl: rawGroup.web_url, webUrl: rawGroup.web_url,
parentId: rawGroup.parent_id, parentId: rawGroup.parent_id,
visibility: rawGroup.visibility, visibility: rawGroup.visibility,
leavePath: rawGroup.leave_path,
editPath: rawGroup.edit_path,
isOpen: false, isOpen: false,
isOrphan: false, isOrphan: false,
numberProjects: 10, 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