Commit 26664203 authored by Filipa Lacerda's avatar Filipa Lacerda

Small fixes

parent 2207528c
/* 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.<Object>}
*/
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 @@
//= 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];
},
});
});
/* 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();
}
};
}
/* eslint-disable no-param-reassign */
(() => {
window.gl = window.gl || {};
window.gl.environmentsList = window.gl.environmentsList || {};
......
......@@ -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
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