Skip to content

Commit

Permalink
Migrate linking packages modal and remove outdated methods and routes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
krauselukas committed Sep 17, 2019
1 parent 72b7dfa commit 508b4c8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
12 changes: 3 additions & 9 deletions src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]

Expand Down Expand Up @@ -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
Expand Down
37 changes: 19 additions & 18 deletions src/api/app/views/webui/package/_linking_packages.html.haml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/api/app/views/webui/package/_side_links.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }
1 change: 0 additions & 1 deletion src/api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 508b4c8

Please sign in to comment.