Commit d5093ef5 authored by Filipa Lacerda's avatar Filipa Lacerda

Use webpack to require files

Changes after review
parent d97b9622
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
/* global Vue, CommitsPipelineStore, PipelinesService, Flash */ /* global Vue, CommitsPipelineStore, PipelinesService, Flash */
window.Vue = require('vue'); window.Vue = require('vue');
require('./pipelines_store');
require('./pipelines_service');
require('./pipelines_table'); require('./pipelines_table');
/** /**
* Commits View > Pipelines Tab > Pipelines Table. * Commits View > Pipelines Tab > Pipelines Table.
......
...@@ -18,7 +18,7 @@ class PipelinesService { ...@@ -18,7 +18,7 @@ class PipelinesService {
* *
* @return {Promise} * @return {Promise}
*/ */
get() { all() {
return this.pipelines.get(); return this.pipelines.get();
} }
} }
......
...@@ -44,4 +44,7 @@ class PipelinesStore { ...@@ -44,4 +44,7 @@ class PipelinesStore {
} }
} }
return PipelinesStore; window.gl = window.gl || {};
gl.commits = gl.commits || {};
gl.commits.pipelines = gl.commits.pipelines || {};
gl.commits.pipelines.PipelinesStore = PipelinesStore;
...@@ -3,9 +3,12 @@ ...@@ -3,9 +3,12 @@
window.Vue = require('vue'); window.Vue = require('vue');
window.Vue.use(require('vue-resource')); window.Vue.use(require('vue-resource'));
require('../../lib/utils/common_utils');
require('../../vue_shared/vue_resource_interceptor'); require('../../vue_shared/vue_resource_interceptor');
require('../../vue_shared/components/pipelines_table'); require('../../vue_shared/components/pipelines_table');
require('../vue_realtime_listener/index'); require('../../vue_realtime_listener/index');
require('./pipelines_service');
require('./pipelines_store');
/** /**
* *
...@@ -62,10 +65,10 @@ require('../vue_realtime_listener/index'); ...@@ -62,10 +65,10 @@ require('../vue_realtime_listener/index');
* *
*/ */
created() { created() {
gl.pipelines.pipelinesService = new PipelinesService(this.endpoint); const pipelinesService = new gl.commits.pipelines.PipelinesService(this.endpoint);
this.isLoading = true; this.isLoading = true;
return gl.pipelines.pipelinesService.all() return pipelinesService.all()
.then(response => response.json()) .then(response => response.json())
.then((json) => { .then((json) => {
this.store.storePipelines(json); this.store.storePipelines(json);
......
...@@ -233,6 +233,9 @@ ...@@ -233,6 +233,9 @@
/** /**
* Transforms a DOMStringMap into a plain object. * Transforms a DOMStringMap into a plain object.
*
* @param {DOMStringMap} DOMStringMapObject
* @returns {Object}
*/ */
w.gl.utils.DOMStringMapToObject = DOMStringMapObject => Object.keys(DOMStringMapObject).reduce((acc, element) => { w.gl.utils.DOMStringMapToObject = DOMStringMapObject => Object.keys(DOMStringMapObject).reduce((acc, element) => {
acc[element] = DOMStringMapObject[element]; acc[element] = DOMStringMapObject[element];
......
...@@ -2,39 +2,35 @@ ...@@ -2,39 +2,35 @@
/* global Vue, VueResource, gl */ /* global Vue, VueResource, gl */
window.Vue = require('vue'); window.Vue = require('vue');
window.Vue.use(require('vue-resource')); window.Vue.use(require('vue-resource'));
require('../lib/utils/common_utils');
require('../vue_shared/vue_resource_interceptor'); require('../vue_shared/vue_resource_interceptor');
require('./pipelines'); require('./pipelines');
$(() => { $(() => new Vue({
return new Vue({ el: document.querySelector('.vue-pipelines-index'),
el: document.querySelector('.vue-pipelines-index'),
data() { data() {
const project = document.querySelector('.pipelines'); const project = document.querySelector('.pipelines');
const svgs = document.querySelector('.pipeline-svgs').dataset; const svgs = document.querySelector('.pipeline-svgs').dataset;
// Transform svgs DOMStringMap to a plain Object. // Transform svgs DOMStringMap to a plain Object.
const svgsObject = Object.keys(svgs).reduce((acc, element) => { const svgsObject = gl.utils.DOMStringMapToObject(svgs);
acc[element] = svgs[element];
return acc;
}, {});
return { return {
scope: project.dataset.url, scope: project.dataset.url,
store: new gl.PipelineStore(), store: new gl.PipelineStore(),
svgs: svgsObject, svgs: svgsObject,
}; };
}, },
components: { components: {
'vue-pipelines': gl.VuePipelines, 'vue-pipelines': gl.VuePipelines,
}, },
template: ` template: `
<vue-pipelines <vue-pipelines
:scope='scope' :scope='scope'
:store='store' :store='store'
:svgs='svgs' :svgs='svgs'
> >
</vue-pipelines> </vue-pipelines>
`, `,
}); }));
});
/* global Vue */ /* global Vue */
window.Vue = require('vue');
(() => { (() => {
window.gl = window.gl || {}; window.gl = window.gl || {};
......
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
/* global Vue */ /* global Vue */
window.Vue = require('vue');
require('./pipelines_table_row'); require('./pipelines_table_row');
/** /**
* Pipelines Table Component. * Pipelines Table Component.
......
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
/* global Vue */ /* global Vue */
window.Vue = require('vue');
require('../../vue_pipelines_index/status'); require('../../vue_pipelines_index/status');
require('../../vue_pipelines_index/pipeline_url'); require('../../vue_pipelines_index/pipeline_url');
require('../../vue_pipelines_index/stage'); require('../../vue_pipelines_index/stage');
......
...@@ -22,4 +22,4 @@ ...@@ -22,4 +22,4 @@
} } } }
- content_for :page_specific_javascripts do - content_for :page_specific_javascripts do
= page_specific_javascript_tag('commit/pipelines/pipelines_bundle.js') = page_specific_javascript_bundle_tag('commit_pipelines')
...@@ -60,5 +60,4 @@ ...@@ -60,5 +60,4 @@
.vue-pipelines-index .vue-pipelines-index
- content_for :page_specific_javascripts do = page_specific_javascript_bundle_tag('vue_pipelines')
= page_specific_javascript_tag('vue_pipelines_index/index.js')
...@@ -19,6 +19,7 @@ var config = { ...@@ -19,6 +19,7 @@ var config = {
boards: './boards/boards_bundle.js', boards: './boards/boards_bundle.js',
boards_test: './boards/test_utils/simulate_drag.js', boards_test: './boards/test_utils/simulate_drag.js',
cycle_analytics: './cycle_analytics/cycle_analytics_bundle.js', cycle_analytics: './cycle_analytics/cycle_analytics_bundle.js',
commit_pipelines: './commit/pipelines/pipelines_bundle.js',
diff_notes: './diff_notes/diff_notes_bundle.js', diff_notes: './diff_notes/diff_notes_bundle.js',
environments: './environments/environments_bundle.js', environments: './environments/environments_bundle.js',
filtered_search: './filtered_search/filtered_search_bundle.js', filtered_search: './filtered_search/filtered_search_bundle.js',
......
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