Skip to content

Commit

Permalink
Adapt dialogs for Package#show
Browse files Browse the repository at this point in the history
We adapt the view of the dialogs related with Package#show to use the
new frontend framework.

Afected dialogs:

  * Submit request dialog
  * Delete dialog
  * Branch dialog
  * Add role dialog
  * Linking package dialog
  * Change devel request project dialog

Co-authored-by: Ana María Martínez Gómez <ammartinez@suse.de>
Co-authored-by: Moises Deniz Aleman <mdeniz@suse.com>
  • Loading branch information
3 people committed Sep 4, 2018
1 parent 30164e4 commit 8c83347
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/api/app/controllers/webui/package_controller.rb
Expand Up @@ -92,6 +92,7 @@ def main_object
end

def linking_packages
switch_to_webui2
render_dialog
end

Expand Down Expand Up @@ -256,6 +257,7 @@ def submit_request_dialog

@description = @package.commit_message(@tprj, @tpkg)

switch_to_webui2
render_dialog
end

Expand Down Expand Up @@ -616,6 +618,7 @@ def save
end

def delete_dialog
switch_to_webui2
render_dialog
end

Expand Down
10 changes: 10 additions & 0 deletions src/api/app/controllers/webui/request_controller.rb
Expand Up @@ -178,12 +178,16 @@ def diff
def list_small
redirect_to(user_show_path(User.current)) && return unless request.xhr? # non ajax request
requests = BsRequest.list(params)
switch_to_webui2
render partial: 'requests_small', locals: { requests: requests }
end

def delete_request_dialog
@project = params[:project]
@package = params[:package] if params[:package]

switch_to_webui2

render_dialog
end

Expand All @@ -210,6 +214,9 @@ def delete_request
def add_role_request_dialog
@project = params[:project]
@package = params[:package] if params[:package]

switch_to_webui2

render_dialog
end

Expand Down Expand Up @@ -252,6 +259,9 @@ def change_devel_request_dialog
@current_devel_package = @package.develpackage.name
@current_devel_project = @package.develpackage.project.name
end

switch_to_webui2

render_dialog
end

Expand Down
1 change: 1 addition & 0 deletions src/api/app/views/layouts/webui2/webui.html.haml
Expand Up @@ -32,6 +32,7 @@
.row.justify-content-center
.col-12
= render partial: "layouts/webui2/flash", object: flash
.modal.fade#modal{ tabindex: '-1', role: 'dialog', aria: { labelledby: 'modalLabel', hidden: true }}
.container.flex-grow#content
= yield
.container-fluid.py-4.mt-4#footer
Expand Down
@@ -0,0 +1,4 @@
%button.btn.btn-sm.btn-outline-danger.px-4{ data: { dismiss: 'modal' }}
Cancel
= submit_tag('Accept', class: 'btn btn-sm btn-primary px-4')

26 changes: 26 additions & 0 deletions src/api/app/views/webui2/shared/_package_branch_form.html.haml
@@ -0,0 +1,26 @@
- if show_project_field
%p
%strong Change Branch Destination
.form-group
%label{ for: 'target_project' }
%strong Branch project name
= text_field_tag 'target_project', target_project, size: 80, maxlength: 200, class: 'form-control'
.form-group
%label{ for: 'target_package' }
%strong Branch package name
= text_field_tag 'target_package', @package.try(:name), size: 80, maxlength: 200, class: 'form-control'
.form-group.form-check
= check_box_tag(:current_revision, false, class: 'form-check-input')
= label_tag(:current_revision, class: 'form-check-label') do
Stay on current revision
- if @revision
(##{@revision})
- if show_project_field && Configuration.cleanup_after_days
.form-group.form-check
%input.form-check-input#disable-autocleanup{ type: "checkbox" }
%label.form-check-label{ for: 'disable-autocleanup' } Disable Autocleanup
= hidden_field_tag(:autocleanup, true)
:javascript
$("#disable-autocleanup").click(function(){
$("#autocleanup").val($("#disable-autocleanup").prop("checked") ? "false" : "true");
});
Expand Up @@ -13,13 +13,12 @@
%strong Destination
%p
= project_or_package_link(project: branch_project, short: true)
= form_tag({controller: :package, action: :branch}, method: :post) do
= 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}
= render partial: 'webui2/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")
= render partial: 'webui2/shared/dialog_action_buttons'
25 changes: 25 additions & 0 deletions src/api/app/views/webui2/webui/package/_delete_dialog.html.haml
@@ -0,0 +1,25 @@
.modal-dialog{ role: 'document' }
.modal-content
.modal-header
%h5.modal-title Do you really want to delete this package?
.modal-body
- if @package.develpackages.any?
%p
%i.fas.fa-exclamation-circle.text-danger
%span.small Warning: This package is used by the following packages for development
%ul.no-list-style
- @package.develpackages.each do |package|
%li.small
= project_or_package_link(project: package.project.name, package: package.name, short: true)
- else
%p Please confirm deletion of #{package_link @package}
= form_tag({controller: :package, action: :remove}, method: :post) do
= hidden_field_tag(:project, @project)
= hidden_field_tag(:package, @package)
- if @package.develpackages.any?
.form-group.form-check
= check_box_tag(:force, 'cleanup', @cleanup_source, class: 'form-check-input')
= label_tag(:force, 'Delete anyway?', class: 'form-check-label')

.modal-footer
= render partial: 'webui2/shared/dialog_action_buttons'
15 changes: 15 additions & 0 deletions src/api/app/views/webui2/webui/package/_linking_packages.html.haml
@@ -0,0 +1,15 @@
.modal-dialog{ role: 'document' }
.modal-content
.modal-header
%h5.modal-title Derived Packages
.modal-body
%ul.no-list-style
- @package.linking_packages.each do |linking_package|
- if linking_package.name != @package.name
- name = elide_two(linking_package.project.name, linking_package.name, 46).join(' / ')
- else
- name = elide(linking_package.project.name, 46)
%li= link_to(name, package_show_path(project: linking_package.project.name, package: linking_package.name))
.modal-footer
%button.btn.btn-sm.btn-outline-danger.px-4{ data: { dismiss: 'modal' }}
Cancel
@@ -0,0 +1,52 @@
.modal-dialog{ role: 'document' }
.modal-content
= form_tag({controller: 'package', action: 'submit_request'}, method: 'post') do
.modal-header
%h5.modal-title Create Submit Request
.modal-body
%p
Do you want to submit #{package_link @package, rev: @revision}?

= hidden_field_tag(:project, @project)
= hidden_field_tag(:package, @package)
= hidden_field_tag(:rev, @revision)
.form-group
= label_tag(:sourceproject, 'From source project:')
= text_field_tag(:sourceproject, elide(@project.name, 40), disabled: true, class: 'form-control')
.form-group
= label_tag(:targetproject, 'To target project:')
= text_field_tag(:targetproject, @tprj, disabled: params[:readonly], required: true, class: 'form-control', |
data: { autocomplete_url: url_for(controller: :project, action: :autocomplete_projects), |
requests_url: url_for(controller: :request, action: :list_small), |
develpackage_url: url_for(controller: :package, action: :devel_project) })
- if params[:readonly]
= hidden_field_tag(:targetproject, @tprj)

.form-group
= label_tag(:targetpackage, 'To target package:')
= text_field_tag(:targetpackage, @tpkg, disabled: params[:readonly], class: 'form-control')
- if params[:readonly]
= hidden_field_tag(:targetpackage, @tpkg)

.form-group
= label_tag(:description, 'Description:')
~ text_area_tag(:description, @description, size: '40x3', class: 'form-control')

.form-group.d-none#supersede-display
= label_tag(:supersede_requests, 'Supersede requests:')
%br/
%span#supersede-requests

.form-group.form-check#sourceupdate-display
= check_box_tag(:sourceupdate, 'cleanup', @cleanup_source, class: 'form-check-input')
= label_tag(:sourceupdate, 'Remove local package if request is accepted', class: 'form-check-label')

%p.d-none#devel-project-warning
You are about to bypass the devel project, please submit to
%b#devel-project-name
instead.

.modal-footer
= render partial: 'webui2/shared/dialog_action_buttons'

= javascript_tag 'setup_request_dialog();'
6 changes: 3 additions & 3 deletions src/api/app/views/webui2/webui/package/show.html.haml
Expand Up @@ -52,9 +52,9 @@
//TODO: Fix this hard link
- if @package.linking_packages.present?
%li
= image_tag 'icons/information', title: ''
%i.fas.fa-info-circle.text-info
= @package.linking_packages.size
= link_to('derived packages', { :action => :linking_packages, :project => @project, :package => @package }, :remote => true)
= link_to('derived packages', linking_packages_path(project: @project, package: @package), remote: true)
- if @linkinfo
- linked_package = @linkinfo[:package]
%i.fas.fa-link.text-dark
Expand Down Expand Up @@ -159,4 +159,4 @@
.col-lg-4
= render partial: 'webui2/shared/buildresult_box', locals: { project: @project.name, package: @package.name }

= render partial: 'webui/package/branch_dialog'
= render partial: 'branch_dialog'
@@ -0,0 +1,25 @@
.modal-dialog{ role: 'document' }
.modal-content
= form_tag(action: 'add_role_request', project: @project) do
.modal-header
%h5.modal-title Add Role Request
.modal-body
%p
Do you want to request a role addition to #{project_or_package_link project: @project, package: @package}?
= hidden_field_tag(:package, @package) if defined? @package
.form-group
= label_tag(:role, 'Add role:')
= select_tag(:role, options_for_select([['Maintainer', 'maintainer'], ['Bugowner', 'bugowner']]), class: 'form-control')
.form-group
= label_tag(:user, 'For user:')
= text_field_tag(:user, User.current.login, class: 'form-control' )
- if defined? @package
.form-group
= label_tag(:target_project, 'In target project:')
= text_field_tag(:target_project, @project, disabled: true, class: 'form-control')
.form-group
= label_tag(:description, 'Description:')
= text_area_tag(:description, '', row: 3, class: 'form-control')
.modal-footer
= render partial: 'webui2/shared/dialog_action_buttons'

@@ -0,0 +1,33 @@
.modal-dialog{ role: 'document' }
.modal-content
= form_tag({ action: :change_devel_request, project: @project, package: @package }, method: :post) do
.modal-header
%h5.modal-title Change Devel Project Request
.modal-body
- if @current_devel_project && @current_devel_package
%p
Do you want to request to change the devel project for #{package_link @package} from
\#{project_or_package_link project: @current_devel_project}?
- else
%p
Do you want to request to set the devel project for #{package_link @package}?
.form-group
- if @current_devel_project && @current_devel_package
= label_tag('devel-project', 'New Devel project (leave free to delete the current one):')
- else
= label_tag('devel-project', 'Devel project:')
= text_field_tag('devel-project', '', required: true, class: 'form-control')
.form-group
= label_tag(:description, 'Description:')
= text_area_tag(:description, '', row: 3, class: 'form-control')
.modal-footer
= render partial: 'webui2/shared/dialog_action_buttons'

:javascript
$("#devel_project").autocomplete({source: '#{url_for controller: 'project', action: 'autocomplete_projects'}', search: function(event, ui) {
$(this).addClass('loading-spinner');
},
response: function(event, ui) {
$(this).removeClass('loading-spinner');
}, minLength: 2});

@@ -0,0 +1,20 @@
.modal-dialog{ role: 'document' }
.modal-content
= form_tag({ action: :delete_request, project: @project }, method: :post) do
.modal-header
%h5.modal-title Create Delete Request
.modal-body
%p
Do you really want to request the deletion of #{project_or_package_link project: @project, package: @package}?
= hidden_field_tag(:package, @package) if defined? @package
%p
- if defined? @package
.form-group
= label_tag(:target_project, 'In target project:')
= text_field_tag(:target_project, @project, disabled: true, class: 'form-control')
.form-group
= label_tag(:description, 'Please explain why:')
= text_area_tag(:description, '', row: 3, class: 'form-control')
.modal-footer
= render partial: 'webui2/shared/dialog_action_buttons'

12 changes: 12 additions & 0 deletions src/api/app/views/webui2/webui/request/_requests_small.html.haml
@@ -0,0 +1,12 @@
- if requests.blank?
%p No requests.
- else
%ul.no-list-style
- requests.each do |req|
%li
.form-group.form-check
= check_box_tag('supersede_request_numbers[]', req.number, false, id: "supersede_request_numbers#{req.number}", class: 'form-check-input')
= link_to(req.number, controller: :request, action: :show, number: req.number)
by
= user_with_realname_and_icon(req.creator, short: true)
(#{fuzzy_time(req.created_at)})
5 changes: 5 additions & 0 deletions src/api/app/views/webui2/webui/webui/_dialog.js.erb
@@ -0,0 +1,5 @@
$('#modal').html('<%= raw @dialog_html %>');
<% unless @dialog_init.blank? -%>
<%= @dialog_init %>();
<% end -%>
$('#modal').modal('show');
2 changes: 1 addition & 1 deletion src/api/config/routes.rb
Expand Up @@ -129,7 +129,7 @@ def self.public_or_about_path?(request)
get 'package/view_file/:project/:package/(:filename)' => :view_file, constraints: cons, as: 'package_view_file'
get 'package/live_build_log/:project/:package/:repository/:arch' => :live_build_log, constraints: cons, as: 'package_live_build_log'
defaults format: 'js' do
get 'package/linking_packages/:project/:package' => :linking_packages, constraints: cons
get 'package/linking_packages/:project/:package' => :linking_packages, constraints: cons, as: 'linking_packages'
get 'package/update_build_log/:project/:package/:repository/:arch' => :update_build_log, constraints: cons
get 'package/submit_request_dialog/:project/:package' => :submit_request_dialog, constraints: cons, as: 'package_submit_request_dialog'
get 'package/delete_dialog/:project/:package' => :delete_dialog, constraints: cons, as: 'package_delete_dialog'
Expand Down

0 comments on commit 8c83347

Please sign in to comment.