From 508b4c8b10a6431cf19e39eca995f6e18f1b7855 Mon Sep 17 00:00:00 2001 From: Lukas Krause Date: Mon, 16 Sep 2019 15:05:36 +0200 Subject: [PATCH] Migrate linking packages modal and remove outdated methods and routes Since the linking packages dialog is now a partial which resolves in a bootstrap modal, there are no dedicated controller methods and routes needed anymore. Fixes #8348 --- .../controllers/webui/package_controller.rb | 12 ++---- .../webui/package/_linking_packages.html.haml | 37 ++++++++++--------- .../views/webui/package/_side_links.html.haml | 2 +- .../_show_derived_packages.html.haml | 3 +- src/api/config/routes.rb | 1 - 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/api/app/controllers/webui/package_controller.rb b/src/api/app/controllers/webui/package_controller.rb index 05a541b8964..fe34cc78f5b 100644 --- a/src/api/app/controllers/webui/package_controller.rb +++ b/src/api/app/controllers/webui/package_controller.rb @@ -7,13 +7,13 @@ class Webui::PackageController < Webui::WebuiController include Webui::ManageRelationships include BuildLogSupport - before_action :set_project, only: [:show, :index, :users, :linking_packages, :dependency, :binary, :binaries, :requests, :statistics, :revisions, + before_action :set_project, only: [:show, :index, :users, :dependency, :binary, :binaries, :requests, :statistics, :revisions, :submit_request_dialog, :branch_diff_info, :rdiff, :save_new, :save, :remove, :add_file, :save_file, :remove_file, :save_person, :save_group, :remove_role, :view_file, :abort_build, :trigger_rebuild, :trigger_services, :wipe_binaries, :buildresult, :rpmlint_result, :rpmlint_log, :meta, :save_meta, :files, :binary_download] - before_action :require_package, only: [:show, :linking_packages, :dependency, :binary, :binaries, :requests, :statistics, :revisions, + before_action :require_package, only: [:show, :dependency, :binary, :binaries, :requests, :statistics, :revisions, :submit_request_dialog, :branch_diff_info, :rdiff, :save, :save_meta, :remove, :add_file, :save_file, :remove_file, :save_person, :save_group, :remove_role, :view_file, :abort_build, :trigger_rebuild, :trigger_services, :wipe_binaries, :buildresult, :rpmlint_result, :rpmlint_log, :meta, :files, :users, @@ -25,7 +25,7 @@ class Webui::PackageController < Webui::WebuiController before_action :require_architecture, only: [:binary, :binary_download] before_action :check_ajax, only: [:update_build_log, :devel_project, :buildresult, :rpmlint_result] # make sure it's after the require_, it requires both - before_action :require_login, except: [:show, :index, :linking_packages, :linking_packages, :dependency, :branch_diff_info, :binary, :binaries, + before_action :require_login, except: [:show, :index, :dependency, :branch_diff_info, :binary, :binaries, :users, :requests, :statistics, :commit, :revisions, :rdiff, :view_file, :live_build_log, :update_build_log, :devel_project, :buildresult, :rpmlint_result, :rpmlint_log, :meta, :files] @@ -91,12 +91,6 @@ def main_object @package # used by mixins end - # FIXME: should be replaced by the partial - def linking_packages - switch_to_webui2 - render_dialog - end - # rubocop:disable Lint/NonLocalExitFromIterator def dependency switch_to_webui2 diff --git a/src/api/app/views/webui/package/_linking_packages.html.haml b/src/api/app/views/webui/package/_linking_packages.html.haml index b1019747ab1..c1f8e1665e7 100644 --- a/src/api/app/views/webui/package/_linking_packages.html.haml +++ b/src/api/app/views/webui/package/_linking_packages.html.haml @@ -1,18 +1,19 @@ -.modal-dialog.modal-dialog-centered{ role: 'document' } - .modal-content - .modal-header - %h5.modal-title Derived Packages - .modal-body - %ul.list-unstyled - - @package.linking_packages.each do |linking_package| - :ruby - # FIXME: get rid of these helpers - 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) - end - %li= link_to(name, package_show_path(project: linking_package.project.name, package: linking_package.name)) - .modal-footer - %a.btn.btn-sm.btn-outline-danger.px-4{ data: { dismiss: 'modal' } } - Cancel +.modal.fade#linking-packages-modal{ tabindex: -1, role: 'dialog', aria: { labelledby: 'linking-packages-modal-label', hidden: true } } + .modal-dialog.modal-dialog-centered{ role: 'document' } + .modal-content + .modal-header + %h5.modal-title#linking-packages-modal-label Derived Packages + .modal-body + %ul.list-unstyled + - package.linking_packages.each do |linking_package| + :ruby + # FIXME: get rid of these helpers + 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) + end + %li= link_to(name, package_show_path(project: linking_package.project.name, package: linking_package.name)) + .modal-footer + %a.btn.btn-sm.btn-outline-danger.px-4{ data: { dismiss: 'modal' } } + Cancel diff --git a/src/api/app/views/webui/package/_side_links.html.haml b/src/api/app/views/webui/package/_side_links.html.haml index a2644a084c2..54e29fcf3ee 100644 --- a/src/api/app/views/webui/package/_side_links.html.haml +++ b/src/api/app/views/webui/package/_side_links.html.haml @@ -16,7 +16,7 @@ = render partial: 'webui/package/side_links/show_patchinfo', locals: { package: package, project: project } - if package.linking_packages.present? - = render partial: 'webui/package/side_links/show_derived_packages', locals: { package: package, project: project } + = render partial: 'webui/package/side_links/show_derived_packages', locals: { package: package } - if linkinfo = render partial: 'webui/package/side_links/show_linkinfo', locals: { package: package, project: project, diff --git a/src/api/app/views/webui/package/side_links/_show_derived_packages.html.haml b/src/api/app/views/webui/package/side_links/_show_derived_packages.html.haml index 350282b037b..d9674fd99c0 100644 --- a/src/api/app/views/webui/package/side_links/_show_derived_packages.html.haml +++ b/src/api/app/views/webui/package/side_links/_show_derived_packages.html.haml @@ -1,4 +1,5 @@ %li %i.fas.fa-info-circle.text-info = package.linking_packages.size - = link_to('derived packages', linking_packages_path(project: project, package: package), remote: true) + = link_to('derived packages', '#', title: 'derived packages', data: { toggle: 'modal', target: '#linking-packages-modal'}) + = render partial: 'webui/package/linking_packages', locals: { package: package } diff --git a/src/api/config/routes.rb b/src/api/config/routes.rb index 12c76cbbada..63843c950a3 100644 --- a/src/api/config/routes.rb +++ b/src/api/config/routes.rb @@ -125,7 +125,6 @@ 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, as: 'linking_packages' get 'package/update_build_log/:project/:package/:repository/:arch' => :update_build_log, constraints: cons, as: 'package_update_build_log' get 'package/submit_request_dialog/:project/:package' => :submit_request_dialog, constraints: cons, as: 'package_submit_request_dialog' post 'package/trigger_rebuild/:project/:package' => :trigger_rebuild, constraints: cons, as: 'package_trigger_rebuild'