From 26664203eed786961c47eb23bea4fefd89ac3503 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 7 Nov 2016 20:52:04 +0000 Subject: Small fixes --- .../components/environment_item.js.es6 | 19 ++++++++++++++-- .../environments/environments_bundle.js.es6 | 26 ++++++++++------------ .../services/environments_service.js.es6 | 8 ++++--- .../environments/stores/environmnets_store.js.es6 | 1 + .../environments/components/_actions.html.haml | 16 ++++++------- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_item.js.es6 b/app/assets/javascripts/environments/components/environment_item.js.es6 index 0d541f5989d..436ac365788 100644 --- a/app/assets/javascripts/environments/components/environment_item.js.es6 +++ b/app/assets/javascripts/environments/components/environment_item.js.es6 @@ -1,5 +1,4 @@ /* globals Vue */ -/* eslint-disable no-param-reassign, no-return-assign */ (() => { /** * Envrionment Item Component @@ -112,12 +111,28 @@ return this.hasLastDeploymentKey && this.model.last_deployment && this.$options.hasKey(this.model.last_deployment, 'deployable'); }, + /** + * Human readable date. + * + * @returns {String} + */ createdDate() { return $.timeago(this.model.created_at); }, + /** + * Returns the manual actions with the name parsed. + * + * @returns {Array.} + */ manualActions() { - this.model.manual_actions.map(action => action.name = gl.text.humanize(action.name)); + return this.model.manual_actions.map((action) => { + const parsedAction = { + name: gl.text.humanize(action.name), + play_url: action.play_url, + }; + return parsedAction; + }); }, }, diff --git a/app/assets/javascripts/environments/environments_bundle.js.es6 b/app/assets/javascripts/environments/environments_bundle.js.es6 index 53a8353a0bf..1299f64182c 100644 --- a/app/assets/javascripts/environments/environments_bundle.js.es6 +++ b/app/assets/javascripts/environments/environments_bundle.js.es6 @@ -4,9 +4,9 @@ //= require_tree ./services //= require ./components/environment_item //= require ../boards/vue_resource_interceptor +/* globals Vue, EnvironmentsService */ +/* eslint-disable no-param-reassign */ - -/* eslint-disable */ $(() => { const environmentsListApp = document.getElementById('environments-list-view'); const Store = gl.environmentsList.EnvironmentsStore; @@ -20,26 +20,24 @@ $(() => { const filterState = state => environment => environment.state === state && environment; // recursiveMap :: (Function, Array) -> Array - const recursiveMap = (fn, arr) => { - - return arr.map((item) => { - if (!item.children) { return fn(item); } - + const recursiveMap = (fn, arr) => arr.map((item) => { + if (item.children) { const filteredChildren = recursiveMap(fn, item.children).filter(Boolean); if (filteredChildren.length) { item.children = filteredChildren; return item; } + } + return fn(item); + }).filter(Boolean); - }).filter(Boolean); - }; gl.EnvironmentsListApp = new Vue({ el: '#environments-list-view', components: { - item: gl.environmentsList.EnvironmentItem + item: gl.environmentsList.EnvironmentItem, }, data: { @@ -50,7 +48,7 @@ $(() => { }, computed: { - filteredEnvironments (){ + filteredEnvironments() { return recursiveMap(filterState(this.visibility), this.state.environments); }, }, @@ -84,12 +82,12 @@ $(() => { * @param {String} param * @returns {String} The value of the requested parameter. */ - getQueryParameter(param) { + getQueryParameter(parameter) { return window.location.search.substring(1).split('&').reduce((acc, param) => { const paramSplited = param.split('='); acc[paramSplited[0]] = paramSplited[1]; return acc; - }, {})[param]; - } + }, {})[parameter]; + }, }); }); diff --git a/app/assets/javascripts/environments/services/environments_service.js.es6 b/app/assets/javascripts/environments/services/environments_service.js.es6 index 6e0f5b431e3..e10dd87f7ce 100644 --- a/app/assets/javascripts/environments/services/environments_service.js.es6 +++ b/app/assets/javascripts/environments/services/environments_service.js.es6 @@ -1,6 +1,8 @@ +/* globals Vue */ +/* eslint-disable no-unused-vars, no-param-reassign */ class EnvironmentsService { - constructor (root) { + constructor(root) { Vue.http.options.root = root; this.environments = Vue.resource(root); @@ -11,7 +13,7 @@ class EnvironmentsService { }); } - all () { + all() { return this.environments.get(); } -}; +} diff --git a/app/assets/javascripts/environments/stores/environmnets_store.js.es6 b/app/assets/javascripts/environments/stores/environmnets_store.js.es6 index 587e213a17b..ef0188c15bf 100644 --- a/app/assets/javascripts/environments/stores/environmnets_store.js.es6 +++ b/app/assets/javascripts/environments/stores/environmnets_store.js.es6 @@ -1,3 +1,4 @@ +/* eslint-disable no-param-reassign */ (() => { window.gl = window.gl || {}; window.gl.environmentsList = window.gl.environmentsList || {}; diff --git a/app/views/projects/environments/components/_actions.html.haml b/app/views/projects/environments/components/_actions.html.haml index a2c229f1315..f23fdb72353 100644 --- a/app/views/projects/environments/components/_actions.html.haml +++ b/app/views/projects/environments/components/_actions.html.haml @@ -5,12 +5,12 @@ = custom_icon('icon_play') = icon('caret-down') - %ul.dropdown-menu.dropdown-menu-align-right - %li{ "v-for" => "action in manualActions" } - %a{ ":ref" => "action.play_url", - "data-method" => "post", - "rel" => "nofollow" } + %ul.dropdown-menu.dropdown-menu-align-right + %li{ "v-for" => "action in manualActions" } + %a{ ":href" => "action.play_url", + "data-method" => "post", + "rel" => "nofollow" } - = custom_icon('icon_play') - %span - {{action.name}} \ No newline at end of file + = custom_icon('icon_play') + %span + {{action.name}} \ No newline at end of file -- cgit v1.2.1