Commit e4ff8dd2 authored by Filipa Lacerda's avatar Filipa Lacerda

Recursive component

parent 96152f17
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
* *
* Used in a hierarchical structure to show folders with children * Used in a hierarchical structure to show folders with children
* in a table. * in a table.
* Based on [Tree View](https://vuejs.org/examples/tree-view.html) * Recursive component 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) * See this [issue](https://gitlab.com/gitlab-org/gitlab-ce/issues/22539)
* for more information. * for more information.
...@@ -17,7 +16,7 @@ ...@@ -17,7 +16,7 @@
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.environmentsList = window.gl.environmentsList || {}; window.gl.environmentsList = window.gl.environmentsList || {};
gl.environmentsList.EnvironmentItem = Vue.extend({ gl.environmentsList.EnvironmentItem = Vue.component("environment-item", {
template: '#environment-item-template', template: '#environment-item-template',
...@@ -25,7 +24,7 @@ ...@@ -25,7 +24,7 @@
model: Object model: Object
}, },
data: function () { data () {
return { return {
open: false open: false
}; };
...@@ -40,7 +39,7 @@ ...@@ -40,7 +39,7 @@
* *
* @returns {Number} The length of the children array * @returns {Number} The length of the children array
*/ */
isFolder: function () { isFolder () {
return this.model.children && this.model.children.length return this.model.children && this.model.children.length
} }
}, },
...@@ -50,7 +49,7 @@ ...@@ -50,7 +49,7 @@
/** /**
* Toggles the visibility of a folders' children. * Toggles the visibility of a folders' children.
*/ */
toggle: function () { toggle () {
if (this.isFolder) { if (this.isFolder) {
this.open = !this.open; this.open = !this.open;
} }
......
...@@ -20,7 +20,7 @@ $(() => { ...@@ -20,7 +20,7 @@ $(() => {
el: '#environments-list-view', el: '#environments-list-view',
components: { components: {
'environment-item': gl.environmentsList.EnvironmentItem 'item': gl.environmentsList.EnvironmentItem
}, },
data: { data: {
......
%script#environment-item-template{ "type"=> "text/x-template" } %script#environment-item-template{ "type"=> "text/x-template" }
%tr.environment %tr
%td.folder-name{ "@click" => "toggle" } %td.folder-name
%a{ "v-if" => "!isFolder", %a{ "v-if" => "!isFolder",
":href" => "'#{namespace_project_environments_path(@project.namespace, @project)}/' + model.id" } ":href" => "'#{namespace_project_environments_path(@project.namespace, @project)}/' + model.id" }
{{model.name}} {{model.name}}
%span{ "v-if" => "isFolder",
"@click" => "toggle" }
%span{ "v-if" => "isFolder" } %i.folder-icon{ "v-show" => "open"}
%i.folder-icon{ "v-show" => "open" } =icon ("caret-down")
= icon("caret-down") %i.folder-icon{ "v-show" => "!open"}
=icon("caret-right")
%i.folder-icon{ "v-show" => "!open" }
= icon("caret-right")
{{model.name}} {{model.name}}
%td.deployment-column %td.deployment-column
%span{ "v-if" => "!isFolder && model.last_deployment && model.last_deployment.iid" } %span{ "v-if" => "!isFolder && model.last_deployment && model.last_deployment.iid"}
= precede '#' do = precede "#" do
{{model.last_deployment.iid}} {{model.last_deployment.iid}}
%span{ "v-if" => "model.last_deployment.user" } %span{ "v-if" => "model.last_deployment.user"}
by by
%a{":href" => "'/' + model.last_deployment.user.username"} %a{":href" => "'/' + model.last_deployment.user.username"}
%img.avatar.has_tooltip.s20{ ":src" => "model.last_deployment.user.avatar_url",
%img.avatar.has-tooltip.s20{ ":src" => "model.last_deployment.user.avatar_url", ":alt" => "model.last_deployment.user.username + 'avatar'",
":alt" => "model.last_deployment.user.username + ' avatar'",
":title" => "model.last_deployment.user.username", ":title" => "model.last_deployment.user.username",
data: { container: 'body'}, data: {container: "body"},
width: 20, height: 20 } width: 20, height: 20}
%td %td
%a.build-link{ "v-if" => "!isFolder && model.last_deployment && model.last_deployment.deployable", %a.build-link{ "v-if" => "!isFolder && model.last_deployment && model.last_deployment.deployable",
":href" => "'#{namespace_project_builds_path(@project.namespace, @project)}/' + model.last_deployment.deployable.id" } ":href" => "'#{namespace_project_builds_path(@project.namespace, @project)}/' + model.last_deployment.deployable.id"}
{{model.last_deployment.deployable.name}} {{model.last_deployment.deployble.name}}
= precede '#' do = precede "#" do
({{model.last_deployment.deployable.id}}) {{model.last_deployment.deployable.id}}
%td %td
%a{ "v-if" => "!isFolder && model.last_deployment" } %a{ "v-if" => "!isFolder && model.last_deployment"}
-# = render "projects/deployments/commit", deployment: "{{model.last_deployment}}" commit message goes here
%p.commit-title{ "v-if" => "!isFolder && !model.last_deployment"} %p.commit-title{ "v-if" => "!isFolder && !model.last_deployment"}
No deployments yet No deployments yet
%td %td
%span{ "v-if" => "!isFolder && model.last_deployment" } %span{ "v-if" => "!isFolder && model.last_deployment"}
{{model.last_deployment.created_at}} {{model.last_deployment.created_at}}
%td.hidden-xs %td.hidden-xs
.pull-right{ "v-if" => "!isFolder"} .pull-right{ "v-if" => "!isFolder"}
-# = render "projects/environments/external_url", environment: "{{model}}" actions will go here
-# = render "projects/deployments/actions", deployment: "{{model.last_deployment}}"
-# = render "projects/environments/stop", environment: "{{model}}" %tr{"v-if" => "open && isFolder", "is" => "environment-item", "v-for" => "model in model.children", ":model" => "model"}
-# = render "projects/deployments/rollback", deployment: "{{model.last_deployment}}"
%tr{ "v-show" => "open",
"v-if"=>"isFolder",
"v-for" => "child in model.children",
":model" => "child" }
%td
%a.children-name{ ":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" }
= precede '#' do
{{child.last_deployment.iid}}
%span{ "v-if" => "child.last_deployment.user" }
by
%a{":href" => "'/' + child.last_deployment.user.username"}
%img.avatar.has-tooltip.s20{ ":src" => "child.last_deployment.user.avatar_url",
":alt" => "child.last_deployment.user.username + ' avatar'",
":title" => "child.last_deployment.user.username",
data: { container: 'body'},
width: 20, height: 20 }
%td
%a.build-link{ "v-if" => "child.last_deployment && child.last_deployment.deployable",
":href" => "'#{namespace_project_builds_path(@project.namespace, @project)}/' + child.last_deployment.deployable.id" }
{{child.last_deployment.deployable.name}}
= precede '#' do
({{child.last_deployment.deployable.id}})
%td
%a{ "v-if" => "child.last_deployment" }
-# = render "projects/deployments/commit", deployment: "{{child.last_deployment}}"
%p.commit-title{ "v-if" => "!child.last_deployment"}
No deployments yet
%td
%span{ "v-if" => "child.last_deployment" }
{{child.last_deployment.created_at}}
%td.hidden-xs
.pull-right
-# = render "projects/environments/external_url", environment: "{{child}}"
-# = render "projects/deployments/actions", deployment: "{{child.last_deployment}}"
-# = render "projects/environments/stop", environment: "{{child}}"
-# = render "projects/deployments/rollback", deployment: "{{child.last_deployment}}"
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
= 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
.table-holder{ "v-if" => "!loading && state.environments.length" } .table-holder{ "v-if" => "!loading && state.environments" }
%table.table.ci-table.environments %table.table.ci-table.environments
%thead %thead
%th Environment %th Environment
...@@ -51,9 +51,6 @@ ...@@ -51,9 +51,6 @@
%th %th
%th.hidden-xs %th.hidden-xs
%tbody %tbody
%tr{ "is"=>"environment-item", %tr{"is" => "environment-item", "v-for" => "model in state.environments", ":model" => "model"}
"inline-template" => true,
"v-for" => "environment in state.environments",
":model" => "environment" }
=render "projects/environments/components/environment" =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