Commit 71899e10 authored by Filipa Lacerda's avatar Filipa Lacerda

Adjustments for the new response with counters

a
parent 2aeb45bd
...@@ -7,6 +7,7 @@ window.Vue = require('vue'); ...@@ -7,6 +7,7 @@ window.Vue = require('vue');
window.Vue.use(require('vue-resource')); window.Vue.use(require('vue-resource'));
require('../services/environments_service'); require('../services/environments_service');
require('./environment_item'); require('./environment_item');
require('../../vue_pagination/index');
(() => { (() => {
window.gl = window.gl || {}; window.gl = window.gl || {};
...@@ -79,7 +80,9 @@ require('./environment_item'); ...@@ -79,7 +80,9 @@ require('./environment_item');
return gl.environmentsService.all() return gl.environmentsService.all()
.then(resp => resp.json()) .then(resp => resp.json())
.then((json) => { .then((json) => {
this.store.storeEnvironments(json); this.store.storeAvailableCount(json.available_count);
this.store.storeStoppedCount(json.stopped_count);
this.store.storeEnvironments(json.environments);
}) })
.then(() => { .then(() => {
this.isLoading = false; this.isLoading = false;
...@@ -131,7 +134,8 @@ require('./environment_item'); ...@@ -131,7 +134,8 @@ require('./environment_item');
{{state.availableCounter}} {{state.availableCounter}}
</span> </span>
</a> </a>
</li><li v-bind:class="{ 'active' : scope === 'stopped' }"> </li>
<li v-bind:class="{ 'active' : scope === 'stopped' }">
<a :href="projectStoppedEnvironmentsPath"> <a :href="projectStoppedEnvironmentsPath">
Stopped Stopped
<span class="badge js-stopped-environments-count"> <span class="badge js-stopped-environments-count">
......
...@@ -42,8 +42,26 @@ ...@@ -42,8 +42,26 @@
return filteredEnvironments; return filteredEnvironments;
}, },
storeCounts() { /**
//TODO * Stores the number of available environments.
*
* @param {Number} count = 0
* @return {Number}
*/
storeAvailableCount(count = 0) {
this.state.availableCounter = count;
return count;
},
/**
* Stores the number of closed environments.
*
* @param {Number} count = 0
* @return {Number}
*/
storeStoppedCount(count = 0) {
this.state.stoppedCounter = count;
return count;
}, },
}; };
......
...@@ -22,7 +22,7 @@ require('./mock_data'); ...@@ -22,7 +22,7 @@ require('./mock_data');
it('should store environments', () => { it('should store environments', () => {
expect( expect(
gl.environmentsList.EnvironmentsStore.state.environments.length gl.environmentsList.EnvironmentsStore.state.environments.length,
).toBe(environmentsList.length); ).toBe(environmentsList.length);
}); });
}); });
......
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