Commit 98a0f72d authored by Filipa Lacerda's avatar Filipa Lacerda

Properly filter all environments

parent 9c41191a
...@@ -15,13 +15,14 @@ $(() => { ...@@ -15,13 +15,14 @@ $(() => {
gl.EnvironmentsListApp.$destroy(true); gl.EnvironmentsListApp.$destroy(true);
} }
const filters = { const filterEnvironments = (environments = [], filter = "") => {
stopped (environments) { return environments.filter((env) => {
return environments.filter((env) => env.state === 'stopped') if (env.children) {
}, return env.children.filter((child) => child.state === filter).length;
available (environments) { } else {
return environments.filter((env) => env.state === 'available') return env.state === filter;
} };
});
}; };
gl.EnvironmentsListApp = new Vue({ gl.EnvironmentsListApp = new Vue({
...@@ -41,15 +42,15 @@ $(() => { ...@@ -41,15 +42,15 @@ $(() => {
computed: { computed: {
filteredEnvironments () { filteredEnvironments () {
return filters[this.visibility](this.state.environments); return filterEnvironments(this.state.environments, this.visibility);
}, },
countStopped () { countStopped () {
return filters['stopped'](this.state.environments).length; return filterEnvironments(this.state.environments, 'stopped').length;
}, },
counAvailable () { counAvailable () {
return filters['available'](this.state.environments).length; return filterEnvironments(this.state.environments, 'available').length;
} }
}, },
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
return element.environment_type === environment.environment_type; return element.environment_type === environment.environment_type;
}); });
data["vue-isChildren"] = true; data["vue-isChildren"] = true;
if (occurs !== undefined) { if (occurs !== undefined) {
......
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