Commit adb22344 authored by Filipa Lacerda's avatar Filipa Lacerda

Beautifies sent data into human readable formats

parent d418d499
...@@ -43,25 +43,41 @@ ...@@ -43,25 +43,41 @@
*/ */
storeEnvironments(environments) { storeEnvironments(environments) {
const environmentsTree = environments.reduce((acc, environment) => { const environmentsTree = environments.reduce((acc, environment) => {
const data = Object.assign({}, environment);
if (data.last_deployment) {
//humanizes actions names if there are any actions
if (data.last_deployment.manual_actions) {
data.last_deployment.manual_actions = data.last_deployment.manual_actions.map((action) => Object.assign({}, action, {name: gl.text.humanize(action.name)}));
}
//transforms created date for deployment in a human readable format
if (data.last_deployment.created_at) {
// TODO - how to do this without jquery
}
}
if (environment.environment_type !== null) { if (environment.environment_type !== null) {
const occurs = acc.find((element, index, array) => { const occurs = acc.find((element, index, array) => {
return element.name === environment.environment_type; return element.name === environment.environment_type;
}); });
data["vue-isChildren"] = true;
if (occurs !== undefined) { if (occurs !== undefined) {
acc[acc.indexOf(occurs)].children.push( acc[acc.indexOf(occurs)].children.push(data);
Object.assign({}, environment, {"vue-isChildren": true}));
acc[acc.indexOf(occurs)].children.sort(); acc[acc.indexOf(occurs)].children.sort();
} else { } else {
acc.push({ acc.push({
name: environment.environment_type, name: environment.environment_type,
children: [ children: [
Object.assign({}, environment, {"vue-isChildren": true}) Object.assign(data)
] ]
}); });
} }
} else { } else {
acc.push(environment); acc.push(data);
} }
return acc; return acc;
......
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