Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2016-11-07 21:44:16 +0300
committerFilipa Lacerda <filipa@gitlab.com>2016-11-16 14:58:08 +0300
commit2207528c376f0c64469f077f82dfb49a3f7e7993 (patch)
treee092689e608657f2e0181446036abda67005cef4 /app/assets/javascripts/environments/stores
parent4ea04c4035368efa007abbf560e7ca6882a361b8 (diff)
Uses vue computed data
Fixes some eslint errors Adds some documentation Improves data manipulation
Diffstat (limited to 'app/assets/javascripts/environments/stores')
-rw-r--r--app/assets/javascripts/environments/stores/environmnets_store.js.es636
1 files changed, 10 insertions, 26 deletions
diff --git a/app/assets/javascripts/environments/stores/environmnets_store.js.es6 b/app/assets/javascripts/environments/stores/environmnets_store.js.es6
index 11c481c22e3..587e213a17b 100644
--- a/app/assets/javascripts/environments/stores/environmnets_store.js.es6
+++ b/app/assets/javascripts/environments/stores/environmnets_store.js.es6
@@ -5,7 +5,7 @@
gl.environmentsList.EnvironmentsStore = {
state: {},
- create () {
+ create() {
this.state.environments = [];
this.state.stoppedCounter = 0;
this.state.availableCounter = 0;
@@ -44,39 +44,23 @@
* @returns {Array} Tree structured array with the received environments.
*/
storeEnvironments(environments = []) {
-
this.state.stoppedCounter = this.countByState(environments, 'stopped');
this.state.availableCounter = this.countByState(environments, 'available');
const environmentsTree = environments.reduce((acc, environment) => {
-
- if (environment.last_deployment) {
-
- //humanizes actions names if there are any actions
- if (environment.last_deployment.manual_actions) {
- environment.last_deployment.manual_actions = environment.last_deployment.manual_actions.map((action) => action.name = gl.text.humanize(action.name));
- }
-
- //transforms created date for deployment in a human readable format
- if (environment.last_deployment.created_at) {
- // TODO - how to do this without jquery
- }
- }
-
if (environment.environment_type !== null) {
- const occurs = acc.filter((element, index, array) => {
- return element.children && element.name === environment.environment_type;
- });
+ const occurs = acc.filter(element => element.children &&
+ element.name === environment.environment_type);
- environment["vue-isChildren"] = true;
+ environment['vue-isChildren'] = true;
if (occurs.length) {
acc[acc.indexOf(occurs[0])].children.push(environment);
- acc[acc.indexOf(occurs[0])].children.sort(this.sortByName)
+ acc[acc.indexOf(occurs[0])].children.sort(this.sortByName);
} else {
acc.push({
name: environment.environment_type,
- children: [environment]
+ children: [environment],
});
}
} else {
@@ -100,7 +84,7 @@
* @returns {Number}
*/
countByState(environments, state) {
- return environments.filter((env) => env.state === state).length;
+ return environments.filter(env => env.state === state).length;
},
/**
@@ -110,7 +94,7 @@
* @param {Object} b
* @returns {Number}
*/
- sortByName (a, b) {
+ sortByName(a, b) {
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
@@ -123,6 +107,6 @@
}
return 0;
- }
- }
+ },
+ };
})();