summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2017-05-10 03:06:51 -0500
committerAlfredo Sumaran <alfredo@gitlab.com>2017-05-10 03:06:51 -0500
commit3b6ff7fcaf4443b518770f97e437631197297980 (patch)
tree8838bdbe4dc8ff3c08a027c5f069c81aeb7495fc /app
parent4c3753387b9bb46d0d257c90720c6e27a258c37a (diff)
downloadgitlab-ce-3b6ff7fcaf4443b518770f97e437631197297980.tar.gz
Add support to filter by name to Group list
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/dispatcher.js6
-rw-r--r--app/assets/javascripts/filterable_list.js5
-rw-r--r--app/assets/javascripts/groups/components/group_folder.vue2
-rw-r--r--app/assets/javascripts/groups/components/groups.vue42
-rw-r--r--app/assets/javascripts/groups/index.js39
-rw-r--r--app/assets/javascripts/groups_list.js10
-rw-r--r--app/views/dashboard/groups/_groups.html.haml4
7 files changed, 52 insertions, 56 deletions
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js
index 7e469153106..e4c60ef1188 100644
--- a/app/assets/javascripts/dispatcher.js
+++ b/app/assets/javascripts/dispatcher.js
@@ -40,7 +40,6 @@ import Issue from './issue';
import BindInOut from './behaviors/bind_in_out';
import Group from './group';
import GroupName from './group_name';
-import GroupsList from './groups_list';
import ProjectsList from './projects_list';
import MiniPipelineGraph from './mini_pipeline_graph_dropdown';
import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater';
@@ -148,12 +147,7 @@ const ShortcutsBlob = require('./shortcuts_blob');
case 'admin:projects:index':
new ProjectsList();
break;
- case 'dashboard:groups:index':
- new GroupsList();
- break;
case 'explore:groups:index':
- new GroupsList();
-
const landingElement = document.querySelector('.js-explore-groups-landing');
if (!landingElement) break;
const exploreGroupsLanding = new Landing(
diff --git a/app/assets/javascripts/filterable_list.js b/app/assets/javascripts/filterable_list.js
index aaaeb9bddb1..e6d6400ca86 100644
--- a/app/assets/javascripts/filterable_list.js
+++ b/app/assets/javascripts/filterable_list.js
@@ -4,7 +4,8 @@
*/
export default class FilterableList {
- constructor(form, filter, holder) {
+ constructor(form, filter, holder, store) {
+ this.store = store;
this.filterForm = form;
this.listFilterElement = filter;
this.listHolderElement = holder;
@@ -33,7 +34,7 @@ export default class FilterableList {
$(this.listHolderElement).fadeTo(250, 1);
},
success(data) {
- this.listHolderElement.innerHTML = data.html;
+ this.store.setGroups(data);
// Change url so if user reload a page - search results are saved
return window.history.replaceState({
diff --git a/app/assets/javascripts/groups/components/group_folder.vue b/app/assets/javascripts/groups/components/group_folder.vue
index 5485da58ec5..75b20111ca1 100644
--- a/app/assets/javascripts/groups/components/group_folder.vue
+++ b/app/assets/javascripts/groups/components/group_folder.vue
@@ -1,6 +1,4 @@
<script>
-import eventHub from '../event_hub';
-
export default {
props: {
groups: {
diff --git a/app/assets/javascripts/groups/components/groups.vue b/app/assets/javascripts/groups/components/groups.vue
index 797fca9bd49..2ee7ec96dfe 100644
--- a/app/assets/javascripts/groups/components/groups.vue
+++ b/app/assets/javascripts/groups/components/groups.vue
@@ -1,41 +1,9 @@
<script>
-import GroupsStore from '../stores/groups_store';
-import GroupsService from '../services/groups_service';
-import eventHub from '../event_hub';
-
export default {
- 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();
-
- eventHub.$on('toggleSubGroups', this.toggleSubGroups);
- },
-
- methods: {
- fetchGroups() {
- this.service.getGroups()
- .then((response) => {
- this.store.setGroups(response.json());
- })
- .catch(() => {
- // TODO: Handler error
- });
- },
- toggleSubGroups(group) {
- GroupsStore.toggleSubGroups(group);
-
- this.fetchGroups();
+ props: {
+ groups: {
+ type: Array,
+ required: true,
},
},
};
@@ -43,6 +11,6 @@ export default {
<template>
<div>
- <group-folder :groups="state.groups" />
+ <group-folder :groups="groups" />
</div>
</template>
diff --git a/app/assets/javascripts/groups/index.js b/app/assets/javascripts/groups/index.js
index 8a7c01161a1..2b140f696c5 100644
--- a/app/assets/javascripts/groups/index.js
+++ b/app/assets/javascripts/groups/index.js
@@ -1,12 +1,22 @@
/* eslint-disable no-unused-vars */
import Vue from 'vue';
+import GroupsList from '~/groups_list';
import GroupsComponent from './components/groups.vue';
import GroupFolder from './components/group_folder.vue';
import GroupItem from './components/group_item.vue';
+import GroupsStore from './stores/groups_store';
+import GroupsService from './services/groups_service';
+import eventHub from './event_hub';
$(() => {
const appEl = document.querySelector('#dashboard-group-app');
+ const form = document.querySelector('form#group-filter-form');
+ const filter = document.querySelector('.js-groups-list-filter');
+ const holder = document.querySelector('.js-groups-list-holder');
+
+ const store = new GroupsStore();
+ const service = new GroupsService(appEl.dataset.endpoint);
Vue.component('groups-component', GroupsComponent);
Vue.component('group-folder', GroupFolder);
@@ -14,6 +24,33 @@ $(() => {
const GroupsApp = new Vue({
el: appEl,
- render: createElement => createElement('groups-component'),
+ data() {
+ return {
+ store,
+ state: store.state,
+ };
+ },
+ methods: {
+ fetchGroups() {
+ service.getGroups()
+ .then((response) => {
+ store.setGroups(response.json());
+ })
+ .catch(() => {
+ // TODO: Handler error
+ });
+ },
+ toggleSubGroups(group) {
+ GroupsStore.toggleSubGroups(group);
+
+ this.fetchGroups();
+ },
+ },
+ created() {
+ const groupFilterList = new GroupsList(form, filter, holder, store);
+ this.fetchGroups();
+
+ eventHub.$on('toggleSubGroups', this.toggleSubGroups);
+ },
});
});
diff --git a/app/assets/javascripts/groups_list.js b/app/assets/javascripts/groups_list.js
index 56a8cbf6d03..bc0ac9c3ebc 100644
--- a/app/assets/javascripts/groups_list.js
+++ b/app/assets/javascripts/groups_list.js
@@ -5,13 +5,9 @@ import FilterableList from './filterable_list';
* Updates the html content of the page with the received one.
*/
export default class GroupsList {
- constructor() {
- const form = document.querySelector('form#group-filter-form');
- const filter = document.querySelector('.js-groups-list-filter');
- const holder = document.querySelector('.js-groups-list-holder');
-
- if (form && filter && holder) {
- const list = new FilterableList(form, filter, holder);
+ constructor(form, filter, holder, store) {
+ if (form && filter && holder && store) {
+ const list = new FilterableList(form, filter, holder, store);
list.initSearch();
}
}
diff --git a/app/views/dashboard/groups/_groups.html.haml b/app/views/dashboard/groups/_groups.html.haml
index e7a5fa8ba32..dafb58e5370 100644
--- a/app/views/dashboard/groups/_groups.html.haml
+++ b/app/views/dashboard/groups/_groups.html.haml
@@ -1 +1,3 @@
-.js-groups-list-holder#dashboard-group-app{ data: { endpoint: dashboard_groups_path(format: :json) } }
+.js-groups-list-holder
+ #dashboard-group-app{ data: { endpoint: dashboard_groups_path(format: :json) } }
+ %groups-component{ ':groups' => 'state.groups' }