Skip to content

Commit

Permalink
Migrate project package table to bootstrap.
Browse files Browse the repository at this point in the history
Since we are moving the project view to bootstrap,
the package table need to be migrated as well
  • Loading branch information
krauselukas committed Nov 29, 2018
1 parent 2d816a9 commit 972a5de
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/api/app/assets/javascripts/webui2/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@
//= require webui2/jquery-ui.min.js
//= require webui2/cm2/use-codemirror.js
//= require webui2/package-view_file.js
//= require webui2/project.js
4 changes: 4 additions & 0 deletions src/api/app/assets/javascripts/webui2/project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function setPackageTable() { // jshint ignore:line
$('#packages-table').DataTable();
$('#inherited-packages-table').DataTable();
}
5 changes: 5 additions & 0 deletions src/api/app/helpers/webui/project_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,9 @@ def escape_list(list)
"']".html_safe
end.join(',').html_safe
end

def show_package_actions?
!@project.defines_remote_instance? && !(@is_incident_project && @packages.present? &&
@has_patchinfo && @open_release_requests.empty?) && !@is_maintenance_project
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.card-body
- if ipackages.present?
%table.table.table-striped.table-bordered#inherited-packages-table
%thead
%tr
%th Name
%th From
%tbody
- ipackages.each do |ipackage|
%tr
%td
= link_to(ipackage[0], package_show_path(package: ipackage[0], project: ipackage[1]))
%td
= ipackage[1]
29 changes: 29 additions & 0 deletions src/api/app/views/webui2/webui/project/_project_packages.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.card-body
- if packages.present?
%table.table.table-striped.table-bordered#packages-table
%thead
%tr
%th Name
%th Changed
%tbody
- packages.each do |package|
%tr
%td
= link_to(package[0], package_show_path(package: package[0], project: project))
%td
= time_ago_in_words(Time.at(package[1].to_i))
- else
%p This project does not contain any packages

- if project.is_a?(Project) && 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
25 changes: 21 additions & 4 deletions src/api/app/views/webui2/webui/project/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,24 @@
= 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{ role: 'tablist', id: 'packages-tabs' }
%li.nav-item
%a.nav-link.active{ id: '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{ id: 'inherited-packages-tab', href: '#inherited-packages', role: 'tab', data: { toggle: 'tab' },
aria: { controls: 'inherited-packages', selected: 'false' } }
Inherited Packages
= "(#{@ipackages.length})"
.tab-content{ id: 'packages-tabs-content' }
.tab-pane.fade.show.active{ id: 'packages', role: 'tabpanel', aria: { labelledby: 'packages-tab' } }
= render partial: 'project_packages', locals: { project: @project, packages: @packages }
.tab-pane.fade{ id: 'inherited-packages', role: 'tabpanel', aria: { labelledby: 'inherited-packages-tab' } }
= render partial: 'project_inherited_packages', locals: { ipackages: @ipackages }
.comments
.card
%h5.card-header
Expand All @@ -36,3 +50,6 @@
(#{ @comments.length})
.card-body#comments
= render partial: 'webui2/webui/comment/show', locals: { commentable: @project }

= content_for :ready_function do
setPackageTable();
2 changes: 1 addition & 1 deletion src/api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 972a5de

Please sign in to comment.