Commit de990812 authored by Filipa Lacerda's avatar Filipa Lacerda

Creates component

parent 52c4f8ef
(() => {
const Store = gl.environmentsList.EnvironmentsStore;
window.gl = window.gl || {};
window.gl.environmentsList = window.gl.environmentsList || {};
gl.environmentsList.EnvironmentItem = Vue.extend({
props: {
model: Object
},
data: function () {
return {
open: false
};
},
computed: {
isFolder: function() {
debugger;
return this.model.children && this.model.children.length
}
},
methods: {
toggle: function () {
if (this.isFolder) {
this.open = !this.open;
}
}
}
})
})();
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
//= require vue-resource //= require vue-resource
//= require_tree ./stores //= require_tree ./stores
//= require_tree ./services //= require_tree ./services
//= require ./components/environment_item
$(() => { $(() => {
...@@ -20,10 +20,11 @@ $(() => { ...@@ -20,10 +20,11 @@ $(() => {
el: $environmentsListApp, el: $environmentsListApp,
components: { components: {
'tree-view': gl.environmentsList.TreeView 'environment-item': gl.environmentsList.EnvironmentItem
}, },
data: { data: {
state: Store.state,
endpoint: $environmentsListApp.dataset.endpoint, endpoint: $environmentsListApp.dataset.endpoint,
loading: true loading: true
}, },
......
...@@ -3,8 +3,6 @@ class EnvironmentsService { ...@@ -3,8 +3,6 @@ class EnvironmentsService {
constructor (root) { constructor (root) {
Vue.http.options.root = root; Vue.http.options.root = root;
debugger;
this.environments = Vue.resource(root); this.environments = Vue.resource(root);
Vue.http.interceptors.push((request, next) => { Vue.http.interceptors.push((request, next) => {
......
...@@ -31,10 +31,13 @@ ...@@ -31,10 +31,13 @@
* }, * },
* {name: "environment_1", environment_type: null} * {name: "environment_1", environment_type: null}
* ] * ]
* @param {Array} environments List of environments *
*
* @param {Array} environments List of environments.
* @returns {Array} Tree structured array with the received environments.
*/ */
storeEnvironments(environments) { storeEnvironments(environments) {
this.state.environments = environments.reduce((acc, environment) => { const environmentsTree = environments.reduce((acc, environment) => {
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;
...@@ -55,6 +58,10 @@ ...@@ -55,6 +58,10 @@
return acc; return acc;
}, []).sort(); }, []).sort();
this.state.environments = environmentsTree;
return environmentsTree;
} }
} }
})(); })();
\ No newline at end of file
%environment-item{"inline-template" => true,
"v-for" => "environment in state.environments",
":model" => "environment"}
%i{"v-if" => "isFolder"}
= icon("plus")
%i{"v-if" => ""}
= icon("less")
{{model.name}}
...@@ -26,26 +26,29 @@ ...@@ -26,26 +26,29 @@
New environment New environment
.environments-container#environments-list-view{ "v-cloak" => true, data: environments_list_data } .environments-container#environments-list-view{ "v-cloak" => true, data: environments_list_data }
- if @all_environments.blank? .environments-list-viewtext-center{ "v-if" => "loading" }
.blank-state.blank-state-no-icon = icon("spinner spin")
%h2.blank-state-title
You don't have any environments right now. .blank-state.blank-state-no-icon{ "v-if" => "state.environments.length === 0" }
%p.blank-state-text %h2.blank-state-title
Environments are places where code gets deployed, such as staging or production. You don't have any environments right now.
%br %p.blank-state-text
= succeed "." do Environments are places where code gets deployed, such as staging or production.
= link_to "Read more about environments", help_page_path("ci/environments") %br
- if can?(current_user, :create_environment, @project) = succeed "." do
= link_to new_namespace_project_environment_path(@project.namespace, @project), class: 'btn btn-create' do = link_to "Read more about environments", help_page_path("ci/environments")
New environment - if can?(current_user, :create_environment, @project)
- else = link_to new_namespace_project_environment_path(@project.namespace, @project), class: 'btn btn-create' do
.table-holder New environment
%table.table.ci-table.environments
%tbody .table-holder{ "v-if" => "state.environments.length" }
%th Environment %table.table.ci-table.environments
%th Last Deployment %thead
%th Build %th Environment
%th Commit %th Last Deployment
%th %th Build
%th.hidden-xs %th Commit
/ = render @environments %th
%th.hidden-xs
%tbody
=render "projects/environments/components/environment"
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