Use CJS in environments service

This commit is contained in:
Filipa Lacerda 2017-02-09 11:38:59 +00:00
parent 26a951b7ab
commit 8f3678f1de
2 changed files with 7 additions and 19 deletions

View File

@ -5,7 +5,7 @@
window.Vue = require('vue');
window.Vue.use(require('vue-resource'));
require('../services/environments_service');
const EnvironmentsService = require('../services/environments_service');
require('./environment_item');
const Store = require('../stores/environments_store');
@ -68,11 +68,11 @@ const Store = require('../stores/environments_store');
const scope = this.$options.getQueryParameter('scope') || this.visibility;
const endpoint = `${this.endpoint}?scope=${scope}`;
gl.environmentsService = new EnvironmentsService(endpoint);
const service = new EnvironmentsService(endpoint);
this.isLoading = true;
return gl.environmentsService.all()
return service.all()
.then(resp => resp.json())
.then((json) => {
this.store.storeAvailableCount(json.available_count);

View File

@ -1,20 +1,8 @@
/* globals Vue */
/* eslint-disable no-unused-vars, no-param-reassign */
const Vue = window.Vue = require('vue');
class EnvironmentsService {
constructor(root) {
Vue.http.options.root = root;
this.environments = Vue.resource(root);
Vue.http.interceptors.push((request, next) => {
// needed in order to not break the tests.
if ($.rails) {
request.headers['X-CSRF-Token'] = $.rails.csrfToken();
}
next();
});
constructor(endpoint) {
this.environments = Vue.resource(endpoint);
}
all() {
@ -22,4 +10,4 @@ class EnvironmentsService {
}
}
window.EnvironmentsService = EnvironmentsService;
module.exports = EnvironmentsService;