From d40e0d3c682b7d1081729b417be747b14b627212 Mon Sep 17 00:00:00 2001 From: Lukas Krause Date: Wed, 28 Nov 2018 15:55:28 +0100 Subject: [PATCH] Migrate project package table to bootstrap. The project show view get migrated to bootstrap. The package table is a partial of it. In order to get this done and to serve it to the beta users, the table needs to be moved to bootstrap. --- src/api/app/helpers/webui/project_helper.rb | 7 +++++ .../_project_inherited_packages.html.haml | 14 +++++++++ .../webui/project/_project_packages.html.haml | 29 +++++++++++++++++++ .../views/webui2/webui/project/show.html.haml | 27 ++++++++++++----- src/api/config/routes.rb | 2 +- 5 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 src/api/app/views/webui2/webui/project/_project_inherited_packages.html.haml diff --git a/src/api/app/helpers/webui/project_helper.rb b/src/api/app/helpers/webui/project_helper.rb index 78ddf5c52f8b..12fa761e6253 100644 --- a/src/api/app/helpers/webui/project_helper.rb +++ b/src/api/app/helpers/webui/project_helper.rb @@ -122,4 +122,11 @@ def escape_list(list) "']".html_safe end.join(',').html_safe end + + def show_package_actions? + return false if @is_maintenance_project + return false if @project.defines_remote_instance? + return true unless @is_incident_project && @packages.present? && + @has_patchinfo && @open_release_requests.empty? + end end diff --git a/src/api/app/views/webui2/webui/project/_project_inherited_packages.html.haml b/src/api/app/views/webui2/webui/project/_project_inherited_packages.html.haml new file mode 100644 index 000000000000..e307e9d28661 --- /dev/null +++ b/src/api/app/views/webui2/webui/project/_project_inherited_packages.html.haml @@ -0,0 +1,14 @@ +.card-body + - if inherited_packages.present? + %table.table.table-striped.table-bordered#inherited-packages-table + %thead + %tr + %th.w-75 Name + %th From + %tbody + - inherited_packages.each do |package| + %tr + %td + = link_to(package.first, package_show_path(package: package.first, project: package.second)) + %td + = package.second diff --git a/src/api/app/views/webui2/webui/project/_project_packages.html.haml b/src/api/app/views/webui2/webui/project/_project_packages.html.haml index e69de29bb2d1..712860658d6b 100644 --- a/src/api/app/views/webui2/webui/project/_project_packages.html.haml +++ b/src/api/app/views/webui2/webui/project/_project_packages.html.haml @@ -0,0 +1,29 @@ +.card-body + - if packages.present? + %table.table.table-striped.table-bordered#packages-table + %thead + %tr + %th.w-75 Name + %th Changed + %tbody + - packages.each do |package| + %tr + %td + = link_to(package.first, package_show_path(package: package.first, project: project)) + %td + = time_ago_in_words(Time.at(package.second.to_i)) + - else + %p This project does not contain any packages + + - if User.current.can_modify?(project) + - if show_package_actions? + .pt-4 + %ul.list-inline + %li.list-inline-item + = link_to(project_new_package_path(project: project)) do + %i.fas.fa-plus-circle.text-primary + Create package + %li.list-inline-item + = link_to(project_new_package_branch_path(project: project)) do + %i.fas.fa-code-branch.text-primary + Branch existing package diff --git a/src/api/app/views/webui2/webui/project/show.html.haml b/src/api/app/views/webui2/webui/project/show.html.haml index 55a4663e80bb..31f6766feaa6 100644 --- a/src/api/app/views/webui2/webui/project/show.html.haml +++ b/src/api/app/views/webui2/webui/project/show.html.haml @@ -24,15 +24,28 @@ = render partial: 'webui2/shared/buildresult_box', locals: { project: @project.name } .list .card - %h5.card-header - Packages - = "(#{@packages.length})" - = render partial: 'project_packages' + .bg-light + %ul.nav.nav-tabs.pt-2.px-3.flex-nowrap#packages-tabs{ role: 'tablist' } + %li.nav-item + %a.nav-link.active#packages-tab{ href: '#packages', role: 'tab', data: { toggle: 'tab' }, + aria: { controls: 'packages', selected: 'true' } } + Packages (#{@packages.length}) + - if @ipackages.present? + %li.nav-item + %a.nav-link#inherited-packages-tab{ href: '#inherited-packages', role: 'tab', data: { toggle: 'tab' }, + aria: { controls: 'inherited-packages', selected: 'false' } } + Inherited Packages (#{@ipackages.length}) + .tab-content#packages-tabs-content + .tab-pane.fade.show.active#packages{ role: 'tabpanel', aria: { labelledby: 'packages-tab' } } + = render partial: 'project_packages', locals: { project: @project, packages: @packages } + .tab-pane.fade#inherited-packages{ role: 'tabpanel', aria: { labelledby: 'inherited-packages-tab' } } + = render partial: 'project_inherited_packages', locals: { inherited_packages: @ipackages } .comments .card %h5.card-header - Comments for - = @project - (#{ @comments.length}) + Comments for #{@project} (#{@comments.length}) .card-body#comments = render partial: 'webui2/webui/comment/show', locals: { commentable: @project } + += content_for :ready_function do + $('#packages-table,#inherited-packages-table').DataTable(); diff --git a/src/api/config/routes.rb b/src/api/config/routes.rb index 82bd5c6ceb7e..666682a0b161 100644 --- a/src/api/config/routes.rb +++ b/src/api/config/routes.rb @@ -245,7 +245,7 @@ def self.public_or_about_path?(request) get 'project/attributes/:project', to: redirect('/attribs/%{project}'), constraints: cons post 'project/new_incident' => :new_incident get 'project/new_package/:project' => :new_package, constraints: cons, as: 'project_new_package' - get 'project/new_package_branch/:project' => :new_package_branch, constraints: cons + get 'project/new_package_branch/:project' => :new_package_branch, constraints: cons, as: 'project_new_package_branch' get 'project/incident_request_dialog' => :incident_request_dialog post 'project/new_incident_request' => :new_incident_request get 'project/release_request_dialog' => :release_request_dialog