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

Properly filter all environments

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