BigW Consortium Gitlab

Commit 5e0e3971 by Alfredo Sumaran

List groups with basic details

- Adds Groups component - Adds GroupItem component
parent 26573605
<script>
export default {
props: {
group: {
type: Object,
required: true,
}
}
};
</script>
<template>
<tr>
<td>
<div>
<a :href="group.web_url">{{group.full_name}}</a>
</div>
<div>{{group.description}}</div>
</td>
</tr>
</template>
<script>
import GroupsStore from '../stores/groups_store';
import GroupsService from '../services/groups_service';
import GroupItem from '../components/group_item.vue';
export default {
components: {
'group-item': GroupItem,
},
data() {
const store = new GroupsStore();
return {
store,
state: store.state,
}
},
created() {
const appEl = document.querySelector('#dashboard-group-app');
this.service = new GroupsService(appEl.dataset.endpoint);
this.fetchGroups();
},
methods: {
fetchGroups() {
this.service.getGroups()
.then((response) => {
this.store.setGroups(response.json());
})
.catch(() => {
// TODO: Handler error
});
},
}
};
</script>
<template>
<table class="table table-bordered">
<group-item :group="group" v-for="group in state.groups" />
</table>
</template>
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import Vue from 'vue'; import Vue from 'vue';
import GroupsStore from './stores/groups_store'; import GroupsComponent from './components/groups.vue'
import GroupsService from './services/groups_service';
$(() => { $(() => {
const appEl = document.querySelector('.js-groups-list-holder'); const appEl = document.querySelector('#dashboard-group-app');
const groupsStore = new GroupsStore();
const groupsService = new GroupsService(appEl.dataset.endpoint);
const GroupsApp = new Vue({ const GroupsApp = new Vue({
el: appEl, el: appEl,
data: groupsStore, components: {
mounted() { 'groups-component': GroupsComponent
groupsService.getGroups()
.then((response) => {
this.groups = response.json();
})
.catch(() => {
// TODO: Handle error
});
}, },
render: createElement => createElement('groups-component'),
}); });
}); });
export default class GroupsStore { export default class GroupsStore {
constructor() { constructor() {
this.groups = []; this.state = {};
this.state.groups = [];
return this;
}
setGroups(groups) {
this.state.groups = groups;
return groups;
} }
} }
.js-groups-list-holder{ data: { endpoint: dashboard_groups_path(format: :json) } } .js-groups-list-holder#dashboard-group-app{ data: { endpoint: dashboard_groups_path(format: :json) } }
%ul.content-list
- @groups.each do |group|
- group_member = group.group_members.find_by(user_id: current_user)
= render 'shared/groups/group', group: group_member.group, group_member: group_member
= paginate @groups, theme: 'gitlab'
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