diff options
Diffstat (limited to 'app/assets/javascripts/groups/index.js')
-rw-r--r-- | app/assets/javascripts/groups/index.js | 61 |
1 files changed, 8 insertions, 53 deletions
diff --git a/app/assets/javascripts/groups/index.js b/app/assets/javascripts/groups/index.js index df2a23dc0f7..e71ff6d9107 100644 --- a/app/assets/javascripts/groups/index.js +++ b/app/assets/javascripts/groups/index.js @@ -7,92 +7,49 @@ import Translate from '../vue_shared/translate'; import GroupsApp from './components/app.vue'; import GroupFolderComponent from './components/group_folder.vue'; -import { GROUPS_LIST_HOLDER_CLASS, CONTENT_LIST_CLASS } from './constants'; import GroupFilterableList from './groups_filterable_list'; import GroupsService from './service/groups_service'; import GroupsStore from './store/groups_store'; Vue.use(Translate); -export default (containerId = 'js-groups-tree', endpoint, action = '') => { - const containerEl = document.getElementById(containerId); - let dataEl; +export default () => { + const el = document.getElementById('js-groups-tree'); // eslint-disable-next-line no-new new UserCallout(); - // Don't do anything if element doesn't exist (No groups) - // This is for when the user enters directly to the page via URL - if (!containerEl) { + if (!el) { return; } - const el = action ? containerEl.querySelector(GROUPS_LIST_HOLDER_CLASS) : containerEl; - - if (action) { - dataEl = containerEl.querySelector(CONTENT_LIST_CLASS); - } - Vue.component('GroupFolder', GroupFolderComponent); Vue.component('GroupItem', GroupItemComponent); Vue.use(GlToast); + const { dataset } = el; + // eslint-disable-next-line no-new new Vue({ el, components: { GroupsApp, }, - provide() { - const { - dataset: { - newSubgroupPath, - newProjectPath, - newSubgroupIllustration, - newProjectIllustration, - emptyProjectsIllustration, - emptySubgroupIllustration, - canCreateSubgroups, - canCreateProjects, - currentGroupVisibility, - }, - } = this.$options.el; - - return { - newSubgroupPath, - newProjectPath, - newSubgroupIllustration, - newProjectIllustration, - emptyProjectsIllustration, - emptySubgroupIllustration, - canCreateSubgroups: parseBoolean(canCreateSubgroups), - canCreateProjects: parseBoolean(canCreateProjects), - currentGroupVisibility, - }; - }, data() { - const { dataset } = dataEl || this.$options.el; const showSchemaMarkup = parseBoolean(dataset.showSchemaMarkup); const renderEmptyState = parseBoolean(dataset.renderEmptyState); - const service = new GroupsService(endpoint || dataset.endpoint); + const service = new GroupsService(dataset.endpoint); const store = new GroupsStore({ hideProjects: true, showSchemaMarkup }); return { - action, store, service, renderEmptyState, loading: true, - containerId, }; }, beforeMount() { - if (this.action) { - return; - } - - const { dataset } = dataEl || this.$options.el; let groupFilterList = null; const form = document.querySelector(dataset.formSel); const filter = document.querySelector(dataset.filterSel); @@ -102,11 +59,11 @@ export default (containerId = 'js-groups-tree', endpoint, action = '') => { form, filter, holder, - filterEndpoint: endpoint || dataset.endpoint, + filterEndpoint: dataset.endpoint, pagePath: dataset.path, dropdownSel: dataset.dropdownSel, filterInputField: 'filter', - action: this.action, + action: '', }; groupFilterList = new GroupFilterableList(opts); @@ -115,11 +72,9 @@ export default (containerId = 'js-groups-tree', endpoint, action = '') => { render(createElement) { return createElement('groups-app', { props: { - action: this.action, store: this.store, service: this.service, renderEmptyState: this.renderEmptyState, - containerId: this.containerId, }, }); }, |