Commit 8f3678f1 authored by Filipa Lacerda's avatar Filipa Lacerda

Use CJS in environments service

parent 26a951b7
......@@ -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);
......
/* 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;
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