Commit 26664203 authored by Filipa Lacerda's avatar Filipa Lacerda

Small fixes

parent 2207528c
/* globals Vue */ /* globals Vue */
/* eslint-disable no-param-reassign, no-return-assign */
(() => { (() => {
/** /**
* Envrionment Item Component * Envrionment Item Component
...@@ -112,12 +111,28 @@ ...@@ -112,12 +111,28 @@
return this.hasLastDeploymentKey && this.model.last_deployment && this.$options.hasKey(this.model.last_deployment, 'deployable'); return this.hasLastDeploymentKey && this.model.last_deployment && this.$options.hasKey(this.model.last_deployment, 'deployable');
}, },
/**
* Human readable date.
*
* @returns {String}
*/
createdDate() { createdDate() {
return $.timeago(this.model.created_at); return $.timeago(this.model.created_at);
}, },
/**
* Returns the manual actions with the name parsed.
*
* @returns {Array.<Object>}
*/
manualActions() { 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;
});
}, },
}, },
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
//= require_tree ./services //= require_tree ./services
//= require ./components/environment_item //= require ./components/environment_item
//= require ../boards/vue_resource_interceptor //= require ../boards/vue_resource_interceptor
/* globals Vue, EnvironmentsService */
/* eslint-disable no-param-reassign */
/* eslint-disable */
$(() => { $(() => {
const environmentsListApp = document.getElementById('environments-list-view'); const environmentsListApp = document.getElementById('environments-list-view');
const Store = gl.environmentsList.EnvironmentsStore; const Store = gl.environmentsList.EnvironmentsStore;
...@@ -20,26 +20,24 @@ $(() => { ...@@ -20,26 +20,24 @@ $(() => {
const filterState = state => environment => environment.state === state && environment; const filterState = state => environment => environment.state === state && environment;
// recursiveMap :: (Function, Array) -> Array // recursiveMap :: (Function, Array) -> Array
const recursiveMap = (fn, arr) => { const recursiveMap = (fn, arr) => arr.map((item) => {
if (item.children) {
return arr.map((item) => {
if (!item.children) { return fn(item); }
const filteredChildren = recursiveMap(fn, item.children).filter(Boolean); const filteredChildren = recursiveMap(fn, item.children).filter(Boolean);
if (filteredChildren.length) { if (filteredChildren.length) {
item.children = filteredChildren; item.children = filteredChildren;
return item; return item;
} }
}
return fn(item);
}).filter(Boolean);
}).filter(Boolean);
};
gl.EnvironmentsListApp = new Vue({ gl.EnvironmentsListApp = new Vue({
el: '#environments-list-view', el: '#environments-list-view',
components: { components: {
item: gl.environmentsList.EnvironmentItem item: gl.environmentsList.EnvironmentItem,
}, },
data: { data: {
...@@ -50,7 +48,7 @@ $(() => { ...@@ -50,7 +48,7 @@ $(() => {
}, },
computed: { computed: {
filteredEnvironments (){ filteredEnvironments() {
return recursiveMap(filterState(this.visibility), this.state.environments); return recursiveMap(filterState(this.visibility), this.state.environments);
}, },
}, },
...@@ -84,12 +82,12 @@ $(() => { ...@@ -84,12 +82,12 @@ $(() => {
* @param {String} param * @param {String} param
* @returns {String} The value of the requested parameter. * @returns {String} The value of the requested parameter.
*/ */
getQueryParameter(param) { getQueryParameter(parameter) {
return window.location.search.substring(1).split('&').reduce((acc, param) => { return window.location.search.substring(1).split('&').reduce((acc, param) => {
const paramSplited = param.split('='); const paramSplited = param.split('=');
acc[paramSplited[0]] = paramSplited[1]; acc[paramSplited[0]] = paramSplited[1];
return acc; return acc;
}, {})[param]; }, {})[parameter];
} },
}); });
}); });
/* globals Vue */
/* eslint-disable no-unused-vars, no-param-reassign */
class EnvironmentsService { class EnvironmentsService {
constructor (root) { constructor(root) {
Vue.http.options.root = root; Vue.http.options.root = root;
this.environments = Vue.resource(root); this.environments = Vue.resource(root);
...@@ -11,7 +13,7 @@ class EnvironmentsService { ...@@ -11,7 +13,7 @@ class EnvironmentsService {
}); });
} }
all () { all() {
return this.environments.get(); return this.environments.get();
} }
}; }
/* eslint-disable no-param-reassign */
(() => { (() => {
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.environmentsList = window.gl.environmentsList || {}; window.gl.environmentsList = window.gl.environmentsList || {};
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
= custom_icon('icon_play') = custom_icon('icon_play')
= icon('caret-down') = icon('caret-down')
%ul.dropdown-menu.dropdown-menu-align-right %ul.dropdown-menu.dropdown-menu-align-right
%li{ "v-for" => "action in manualActions" } %li{ "v-for" => "action in manualActions" }
%a{ ":ref" => "action.play_url", %a{ ":href" => "action.play_url",
"data-method" => "post", "data-method" => "post",
"rel" => "nofollow" } "rel" => "nofollow" }
= custom_icon('icon_play') = custom_icon('icon_play')
%span %span
{{action.name}} {{action.name}}
\ No newline at end of file \ No newline at end of file
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