Skip to content

Commit

Permalink
Switch Package#show to bootstrap
Browse files Browse the repository at this point in the history
Added initial version of views for package show

Co-authored-by: David Kang <dkang@suse.com>
Co-authored-by: Saray Cabrera Padrón <scabrerapadron@suse.de>
Co-authored-by: Stasiek Michalski <hellcp@opensuse.org>
  • Loading branch information
4 people committed Sep 4, 2018
1 parent 7f6eeee commit f916c13
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def show
@comment = Comment.new
@requests = []
@services = Backend::Api::Sources::Package.service(@project.name, @package.name)

switch_to_webui2
end

def main_object
Expand Down
25 changes: 25 additions & 0 deletions src/api/app/views/webui2/webui/package/_branch_dialog.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.modal.fade#branchModal{ "tabindex": "-1", "role": "dialog", "aria-labelledby": "branchModalLabel", "aria-hidden": "true"}
.modal-dialog{ "role": "document" }
.modal-content
.modal-header
%h5.modal-title#branchModalLabel Branch Confirmation
%button.close{ "type": "button", "data-dismiss": "modal", "aria-label": "Close" }
%span{ "aria-hidden": "true" } &times;
.modal-body
- branch_project = User.current.branch_project_name(@project.name)
%strong Source
%p
= package_link(@package, short: true)
%strong Destination
%p
= project_or_package_link(project: branch_project, short: true)
= form_tag({controller: :package, action: :branch}, method: :post) do
.modal-body
%details
%summary More options
= hidden_field_tag :linked_project, @project.name
= hidden_field_tag :linked_package, @package.name
= render partial: 'shared/package_branch_form', locals: {show_project_field: true, target_project: branch_project}
.modal-footer
%button.btn.btn-secondary{ "type": "button", "data-dismiss": "modal"} Cancel
= submit_tag('Ok', class: "btn btn-primary")
41 changes: 41 additions & 0 deletions src/api/app/views/webui2/webui/package/_buildstatus.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
- unless @buildresults.excluded_counter.zero? && !@buildresults.show_all
.text-center.card-body.custom-control.custom-checkbox
= check_box_tag "show_all_#{@index}", true, @buildresults.show_all, class: "custom-control-input"
- label_message = @buildresults.excluded_counter.zero? ? 'Hide' : "Show #{@buildresults.excluded_counter}"
= label_tag "show_all_#{@index}", "#{label_message} excluded results", class: "custom-control-label"

- @buildresults.results.each_pair do |package, results|
%h5.text-center= package
#package-buildstatus
%table.table.table-striped.table-sm.mb-0.small
- if results.present?
- previous_repo = nil
- results.each do |result|
- repository = @project.repositories.find_by_name(result.repository)
%tr
%td{ title: "#{result.repository}" }
- if result.repository != previous_repo
= link_to(word_break(result.repository, 22), package_binaries_path(project: @project, package: package, repository: result.repository), { title: "Binaries for #{result.repository}" })
%td.arch
- if !(repository && repository.architectures.pluck(:name).include?(result.architecture))
= sprite_tag "time_error", alt: "Outdated result", title: "This result is outdated"
- else
= repo_status_icon_webui2(result.state, result.details)
= result.architecture
= arch_repo_table_cell(result.repository, result.architecture, package, { "code" => result.code, "details" => result.details })
- previous_repo = result.repository
- else
%tr
%td
All the results have state
%strong excluded


:javascript
$('.unresolvable, .blocked').click(function() {
var title = $(this).attr('title');
alert(title);
});

$("#show_all_#{h @index}").change(function(){ update_build_result_#{h @index}(); })

56 changes: 56 additions & 0 deletions src/api/app/views/webui2/webui/package/_files_view.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.card-body
- unless @files.blank?
%table.table.table-striped.table-bordered.table-responsive.table-sm.dt-responsive.nowrap#files_table
%thead
%tr
%th Filename
%th Size
%th Changed
%th{:style => "width: 1%"} Actions
%tbody
- @files.each do |file|
%tr{:id => "file-#{valid_xml_id(file[:name])}"}
%td
- link_opts = {action: :view_file, project: @project, package: @package, filename: file[:name], expand: @expand}
- unless @is_current_rev
- link_opts[:rev] = file[:srcmd5]
= link_to_if(file[:viewable], nbsp(file[:name]), link_opts)
%td
%span{style: "display: none"}= file[:size].rjust(10, '0')
= human_readable_fsize(file[:size])
%td
%span{style: "display: none"}= file[:mtime]
= fuzzy_time_string(Time.at(file[:mtime].to_i).to_s)
/ limit download for anonymous user to avoid getting killed by crawlers
%td
- if !User.current.is_nobody? || file[:size].to_i < (4 * 1024 * 1024)
= link_to image_tag('icons/page_white_put', title: 'Download File'), file_url(@project.name, @package.name, file[:name], file[:srcmd5])
- unless file[:name] =~ /^_service:/
- if User.current.can_modify? @package
= link_to image_tag('icons/page_white_delete', title: 'Remove File'), {:action => :remove_file, :project => @project.to_param, |
:package => @package.to_param, :filename => file[:name]}, |
{data: {confirm: "Really remove file '#{file[:name]}'?"}, :method => :post} |

:javascript
$(document).ready(function() {
$('#files_table').dataTable({
'columns': [null, null, null, {'orderable': false}],
});
});
- else
%i This package has no files yet
- if User.current.can_modify? @package
.p-3
= link_to image_tag('icons/page_white_add', title: 'Add file') + ' Add file', :action => :add_file, :project => @project, :package => @package
- unless @files.blank? || @spider_bot
- if @revision.present?
- unless @is_current_rev
%h5.card-header.border-top.mt-3
Revision #{@revision} (latest revision is #{@current_rev})
- else
%h5.card-header.border-top.mt-3 Latest Revision
.card-body
= render :partial => 'commit_item', :locals => { revision: @revision, commit: @package.commit(@revision) }
- elsif @srcmd5
%h5
Source MD5 is #{@srcmd5} (latest revision is #{@current_rev})
143 changes: 143 additions & 0 deletions src/api/app/views/webui2/webui/package/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
- @pagetitle = "Show #{@project} / #{@package}"
- @layouttype = 'custom'
- dpackage = @package.develpackage
- package_bread_crumb

.card.mb-3
= render :partial => 'tabs'
.card-body
.row
.col-9
%h3#package_title
- title = @package.title
- title = @package.name if title.blank?
= title
- if @package.url.present?
%small
= link_to(@package.url, @package.url)
= description_wrapper(@package.description)
.col-3
= possibly_empty_ul class: :clean_list do
- if @failures > 0
%li.nav-item
= image_tag 'icons/exclamation', title: ''
= @failures
= link_to "error#{@failures == 1 ? '' : 's'}", :action => :monitor, :project => @project, :succeeded => 0, :blocked => 0, :finished => 0, :signing => 0, :dispatching => 0, :scheduled => 0, :building => 0, :controller => :project, :pkgname => @package.name

= render :partial => 'shared/open_requests'

- if dpackage
%li.nav-item
= image_tag 'icons/information', title: ''
Developed at
= link_to(elide(dpackage.project.name, 44), :action => :show, :controller => :package, :project => dpackage.project.name, :package => dpackage.name)
- if @package.project != @project
%li.nav-item
= image_tag 'icons/information', title: ''
Sources inherited from project
= link_to("#{elide(@package.project.name, 40)}", :action => 'show', :project => @package.project.name, :package => @package.name)
- if @package.developed_packages.present?
%li.nav-item
= image_tag 'icons/information', title: ''
Devel package for
- @package.developed_packages.each_with_index do |pkg, index|
= ',' if index > 0
= link_to("#{elide(pkg.project.name, 40)}", :action => 'show', :project => pkg.project.name, :package => pkg.name)
- if @package.is_patchinfo?
%li.nav-item
= image_tag 'icons/information', title: ''
Has a
= link_to 'patchinfo', :controller => :patchinfo, :action => :show, :package => @package, :project => @project
for
= link_to 'maintenance updates', 'http://en.opensuse.org/Portal:Maintenance'
#TODO: Fix this hard link
- if @package.linking_packages.present?
%li.nav-item
= image_tag 'icons/information', title: ''
= @package.linking_packages.size
= link_to('derived packages', { :action => :linking_packages, :project => @project, :package => @package }, :remote => true)
- if @linkinfo
- linked_package = @linkinfo[:package]
= image_tag('icons/package_link')
Links to
= project_or_package_link project: linked_package.project.name, package: linked_package.name, short: true
- if @linkinfo[:error]
%li.nav-item
= image_tag 'icons/exclamation', title: ''
Link has errors:
%i
= @linkinfo[:error]
- elsif @linkinfo[:diff]
%li.nav-item
= image_tag 'icons/information', title: ''
Has a
= link_to 'link diff', :action => :rdiff, :oproject => linked_package.project.name, :opackage => linked_package.name, :project => @project, :package => @package, :rev => @revision
= render partial: 'extra_actions'

%div
= possibly_empty_ul class: 'nav' do
- if @bugowners_mail.present? and @configuration['bugzilla_url']
%li.nav-item
= link_to image_tag('icons/tools-report-bug', title: 'Report Bug') + ' Report Bug', bugzilla_url(@bugowners_mail, "#{@project.name}/#{@package.name}: Bug", class: 'nav-link')
- unless User.current.is_nobody?
- if @current_rev
%li.nav-item
= link_to(image_tag('icons/arrow_branch', title: 'Branch package') + ' Branch package', '#', class: 'nav-link', data: { "toggle": "modal", "target": "#branchModal" })
%li.nav-item
= link_to(image_tag('icons/package_go', title: 'Submit package') + ' Submit package', { :action => :submit_request_dialog, :project => @project, :package => @package, :revision => @revision }, :remote => true, class: 'nav-link')
- if User.current.can_modify? @package
%li.nav-item
= link_to image_tag('icons/package_edit', title: 'Edit description') + ' Edit description', {:action => 'edit', :project => @project, :package => @package, :spec_count => @spec_count}, class: 'nav-link'
%li.nav-item
= link_to(image_tag('icons/package_delete', title: 'Delete package') + ' Delete package', { :action => :delete_dialog, :package => @package, :project => @project }, :remote => true, id: 'delete-package', class: 'nav-link')
- Feature.with(:kiwi_image_editor) do
- if @package.kiwi_image? && policy(@package).update?
%li.nav-item
= link_to(image_tag('icons/package_edit', title: 'View Image') + ' View Image', import_kiwi_image_path(@package.id), id: 'edit-kiwi', class: 'nav-link')
- if Feature.active?(:cloud_upload) && !User.current.is_nobody?
- if @package.kiwi_image?
%li.nav-item
= link_to(image_tag('icons/drive_web', title: 'Cloud Upload') + ' Cloud Upload', cloud_upload_index_path, id: 'cloud-upload', class: 'nav-link')
- if @services.present?
%li.nav-item
= link_to(image_tag('icons/package_link', title: 'Trigger services') + ' Trigger services', { action: :trigger_services, package: @package, project: @project }, method: :post, class: 'nav-link')
%li.nav-item
= link_to(image_tag('icons/user_add', title: 'Request role addition') + ' Request role addition', { :controller => :request, :action => :add_role_request_dialog, :project => @project, :package => @package }, :remote => true, :class => 'nav-link')
%li.nav-item
= link_to(image_tag('icons/package_delete', title: 'Request deletion') + ' Request deletion', { :controller => :request, :action => :delete_request_dialog, :project => @project, :package => @package }, :remote => true, class: 'nav-link')
//TODO: only users w/o rights should see this, maintainers should get a different dialog:
- if @package.develpackage
%li.nav-item
= link_to(image_tag('icons/arrow_switch', title: 'Request devel project change') + ' Request devel project change', { controller: :request, action: :change_devel_request_dialog, project: @project, package: @package }, remote: true, class: 'nav-link')

.row
.col-lg-8
.card.mb-3
%h5.card-header
Source Files
= image_tag('ajax-loader.gif', :id => 'spinner_files', :style => 'display: none')
- if @linkinfo && @revision_parameter.nil?
%small
- if @expand && @expand.to_s == '1' || @forced_unexpand.present?
= link_to '(show unmerged sources)', :project => @project.name, :package => @package.name, :action => :show, :rev => @revision_parameter, :expand => '0'
- else
= link_to '(show merged sources derived from linked package)', :project => @project.name, :package => @package.name, :action => :show, :rev => @revision_parameter, :expand => '1'
- unless @forced_unexpand.blank?
%p.card-body
%i
Sources could not be expanded:
= @forced_unexpand
= link_to 'Show unmerged sources', :project => @project.name, :package => @package.name, :action => :show, :rev => @revision_parameter, :expand => '0'
- else
= render :partial => 'files_view'
.card.mb-3
%h5.card-header
Comments for
= @project.name
(#{ @comments.length})
.card-body
= render :partial => 'webui/comment/show', locals: { commentable: @package }
.col-lg-4
= render :partial => 'shared/buildresult_box', :locals => { :project => @project.name, :package => @package.name }

= render partial: 'webui/package/branch_dialog'

0 comments on commit f916c13

Please sign in to comment.