BigW Consortium Gitlab

Commit 234c0415 by Filipa Lacerda

Updates Component with documentation and template with links for details

parent 37a100c8
(() => { (() => {
/**
* Envrionment Item Component
*
* Used in a hierarchical structure to show folders with children
* in a table.
* Based on [Tree View](https://vuejs.org/examples/tree-view.html)
* The template used in this Component is non recursive.
*
* See this [issue](https://gitlab.com/gitlab-org/gitlab-ce/issues/22539)
* for more information.
*/
const Store = gl.environmentsList.EnvironmentsStore; const Store = gl.environmentsList.EnvironmentsStore;
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.environmentsList = window.gl.environmentsList || {}; window.gl.environmentsList = window.gl.environmentsList || {};
debugger;
gl.environmentsList.EnvironmentItem = Vue.extend({ gl.environmentsList.EnvironmentItem = Vue.extend({
template: '#environment-item-template', template: '#environment-item-template',
...@@ -21,12 +32,24 @@ ...@@ -21,12 +32,24 @@
}, },
computed: { computed: {
/**
* If an item has a `children` entry it means it is a folder.
* Folder items have different behaviours - it is possible to toggle
* them and show their children.
*
* @returns {Number} The length of the children array
*/
isFolder: function () { isFolder: function () {
return this.model.children && this.model.children.length return this.model.children && this.model.children.length
} }
}, },
methods: { methods: {
/**
* Toggles the visibility of a folders' children.
*/
toggle: function () { toggle: function () {
if (this.isFolder) { if (this.isFolder) {
this.open = !this.open; this.open = !this.open;
......
%environment-item{"inline-template" => true, %script#environment-item-template{ "type"=> "text/x-template" }
"v-for" => "environment in state.environments", %tr.environment
":model" => "environment"} %td.environment-folder-name{ "@click" => "toggle" }
.environment-folder-name{"@click" => "toggle"} %a{ "v-if" => "!isFolder",
%span.icon-container{"v-if" => "isFolder"} ":href" => "'#{namespace_project_environments_path(@project.namespace, @project)}/' + model.id" }
%i{"v-show" => "open"} {{model.name}}
= icon("caret-down")
%span{ "v-if" => "isFolder" }
%i{"v-show" => "!open"} %i{ "v-show" => "open" }
= icon("caret-right") = icon("caret-down")
%span.name-container
{{model.name}} %i{ "v-show" => "!open" }
= icon("caret-right")
// {"name":"review","children":[{"id":8,"project_id":10,"name":"review/app","created_at":"2016-10-13T14:15:33.550Z","updated_at":"2016-10-13T14:15:33.550Z","external_url":"http://gitlab.com","environment_type":"review","state":"opened"}]}
\ No newline at end of file {{model.name}}
%td.deployment-column
%span{ "v-if" => "model.last_deployment && model.last_deployment.iid" }
{{model.last_deployment.iid}}
by
%span{ "v-if" => "model.last_deployment.user" }
{{model.last_deployment.user}}
%td
column 3
%td
column 4
%td
column 5
%td.hidden-xs
.pull-right
actions
-# = render 'projects/environments/external_url', environment: "model"
-# = render 'projects/deployments/actions', deployment: "model.last_deployment"
-# = render 'projects/environments/stop', environment: "model"
-# = render 'projects/deployments/rollback', deployment: "model.last_deployment"
%tr.environment-children{ "v-show" => "open",
"v-if"=>"isFolder",
"v-for" => "child in model.children",
":model" => "child" }
%td
%a{ ":href" => "'#{namespace_project_environments_path(@project.namespace, @project)}/' + child.id" }
{{child.name}}
%td.deployment-column
%span{ "v-if" => "child.last_deployment && child.last_deployment.iid" }
{{child.last_deployment.iid}}
%span{ "v-if" => "child.last_deployment && child.last_deployment.user" }
{{child.last_deployment.user}}
/= user_avatar(user: "child.last_deployment.user", size: 20)
%td
column 3
%td
column 4
%td
column 5
%td.hidden-xs
.pull-right
actions
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
= render "projects/pipelines/head" = render "projects/pipelines/head"
- content_for :page_specific_javascripts do - content_for :page_specific_javascripts do
= page_specific_javascript_tag('environments/environments_bundle.js') = page_specific_javascript_tag("environments/environments_bundle.js")
%div{ class: container_class } %div{ class: container_class }
.top-area .top-area
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
- if can?(current_user, :create_environment, @project) && !@all_environments.blank? - if can?(current_user, :create_environment, @project) && !@all_environments.blank?
.nav-controls .nav-controls
= link_to new_namespace_project_environment_path(@project.namespace, @project), class: 'btn btn-create' do = link_to new_namespace_project_environment_path(@project.namespace, @project), class: "btn btn-create" do
New environment New environment
#environments-list-view{ data: environments_list_data, class: "environments-container" } #environments-list-view{ data: environments_list_data, class: "environments-container" }
...@@ -51,33 +51,9 @@ ...@@ -51,33 +51,9 @@
%th %th
%th.hidden-xs %th.hidden-xs
%tbody %tbody
%tr{"is"=>"environment-item", %tr{ "is"=>"environment-item",
"inline-template" => true, "inline-template" => true,
"v-for" => "environment in state.environments", "v-for" => "environment in state.environments",
":model" => "environment"} ":model" => "environment" }
%script#environment-item-template{"type"=> "text/x-template"}
%tr.environment
%td.environment-folder-name{"@click" => "toggle"}
%span.icon-container{"v-if" => "isFolder"}
%i{"v-show" => "open"}
= icon("caret-down")
%i{"v-show" => "!open"} =render "projects/environments/components/environment"
= icon("caret-right") \ No newline at end of file
%span.name-container
{{model.name}}
%td
%a{{"v-if" => "model.last_deployment"}}
{{model.last_deployment.id}}
%tr.environment-children{"v-show" => "open",
"v-if"=>"isFolder",
"v-for" => "child in model.children",
":model" => "child"}
%td
{{child.name}}
%td.deployment-column
%span{"v-if" => "child.last_deployment && child.last_deployment.iid"}
{{child.last_deployment.iid}}
\ 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