Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api/app/controllers/concerns/scmsync_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module ScmsyncChecker
extend ActiveSupport::Concern

def check_scmsync
return if Flipper.enabled?(:scmsync, User.session)
return if @project&.scmsync.blank?

flash[:error] = "The project #{@project.name} is configured through scmsync. This is not supported by the OBS frontend"
Expand Down
10 changes: 7 additions & 3 deletions src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ class Webui::PackageController < Webui::WebuiController
save_person save_group remove_role view_file
buildresult rpmlint_result rpmlint_log rpmlint_summary files]

before_action :check_scmsync, only: %i[requests revisions statistics users]
before_action :check_scmsync, only: %i[statistics users requests revisions]

before_action :set_package, only: %i[edit update show requests statistics revisions
branch_diff_info rdiff remove
save_person save_group remove_role view_file
buildresult rpmlint_result rpmlint_log rpmlint_summary files users]
buildresult rpmlint_result rpmlint_log rpmlint_summary files users],
unless: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_package_with_scmsync, only: %i[show revisions branch_diff_info rdiff view_file buildresult
rpmlint_result rpmlint_log rpmlint_summary files users],
if: -> { Flipper.enabled?(:scmsync, User.session) }
# rubocop:enable Rails/LexicallyScopedActionFilter
before_action :lints_list, only: %i[rpmlint_summary]

Expand All @@ -37,7 +41,7 @@ def index

def show
# FIXME: Remove this statement when scmsync is fully supported
if @project.scmsync.present?
if @project.scmsync.present? && !Flipper.enabled?(:scmsync, User.session)
flash[:error] = "Package sources for project #{@project.name} are received through scmsync.
This is not supported by the OBS frontend"
redirect_back_or_to project_show_path(@project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class BinariesController < Webui::WebuiController
before_action :require_login, except: [:index]
before_action :set_project
before_action :check_scmsync
before_action :set_package
before_action :set_package, unless: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_package_with_scmsync, if: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_multibuild_flavor
before_action :set_repository
before_action :set_architecture, only: %i[show dependency filelist]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class BuildReasonController < Webui::WebuiController

before_action :set_project
before_action :check_scmsync
before_action :set_package
before_action :set_package, unless: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_package_with_scmsync, if: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_repository
before_action :set_architecture

Expand Down
3 changes: 2 additions & 1 deletion src/api/app/controllers/webui/packages/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class FilesController < Webui::WebuiController

before_action :set_project
before_action :check_scmsync, only: :show
before_action :set_package
before_action :set_package, unless: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_package_with_scmsync, if: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_filename, only: %i[show update destroy blame]
before_action :ensure_existence, only: %i[show blame]
before_action :ensure_viewable, only: %i[show blame]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class JobHistoryController < Webui::WebuiController

before_action :set_project
before_action :check_scmsync
before_action :set_package
before_action :set_package, unless: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_package_with_scmsync, if: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_repository
before_action :set_architecture

Expand Down
3 changes: 2 additions & 1 deletion src/api/app/controllers/webui/packages/meta_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class MetaController < Webui::WebuiController
include ScmsyncChecker

before_action :set_project
before_action :set_package
before_action :set_package, unless: -> { Flipper.enabled?(:scmsync, User.session) }
before_action :set_package_with_scmsync, if: -> { Flipper.enabled?(:scmsync, User.session) }

before_action :check_scmsync
before_action :validate_xml, only: :update
Expand Down
3 changes: 2 additions & 1 deletion src/api/app/controllers/webui/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class Webui::RepositoriesController < Webui::WebuiController
before_action :check_scmsync, if: -> { params[:package] }
before_action :set_repository, only: %i[state mark_important]
before_action :set_architectures, only: %i[index change_flag]
before_action :set_package, only: %i[index change_flag], if: -> { params[:package] }
before_action :set_package, only: %i[index change_flag], if: -> { params[:package] && !Flipper.enabled?(:scmsync, User.session) }
before_action :set_package_with_scmsync, only: %i[index change_flag], if: -> { params[:package] && Flipper.enabled?(:scmsync, User.session) }
before_action :set_main_object, only: %i[index change_flag]
before_action :check_ajax, only: :change_flag
after_action :verify_authorized, except: %i[index state]
Expand Down
15 changes: 15 additions & 0 deletions src/api/app/controllers/webui/webui_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ def set_package
end
end

def set_package_with_scmsync
@package_name = params[:package] || params[:package_name]

return if @package_name.blank?

begin
@package = Package.get_by_project_and_name(@project.name, @package_name,
follow_multibuild: true,
follow_project_scmsync_links: Flipper.enabled?(:scmsync, User.session))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will expose readonly packages to all controllers that use this before action. I don't think this is a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an scmsync specific method now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this checking about Flipper.enabled?(:scmsync, User.session) getting a bit out of hand by now. Can you simplify this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did for the check_scmsync action

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't you normalize this between remote project and scmsync anyway?
What should we keep the regressions for remote projects and deal with different workarounds there?

(Technical, the only difference between an scmsync and a remote package on api level is just the permission handling for service run and lock. Everything else should be identical, including access to build states, log files and the rest of the commands).

There are multiple pull requests from me open fixing these regressions and come with test cases demonstarting the issues...

# why it's not found is of no concern
rescue APIError
raise Package::UnknownObjectError, "Package not found: #{@project.name}/#{@package_name}"
end
end

def set_repository
repository_name = params[:repository] || params[:repository_name]
@repository = @project.repositories.find_by(name: repository_name)
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,8 @@ def update_instance(namespace = 'OBS', name = 'UpdateProject')
end

def developed_packages
return [] unless persisted?

packages = []
candidates = Package.where(develpackage_id: self).load
candidates.each do |candidate|
Expand Down Expand Up @@ -1046,6 +1048,8 @@ def update_if_dirty
end

def linking_packages
return [] unless persisted?

::Package.joins(:backend_package).where(backend_packages: { links_to_id: id })
end

Expand Down
6 changes: 6 additions & 0 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,12 @@ def very_important_projects_with_categories
# class_methods
end

def backend_only_packages
Nokogiri::XML(Backend::Api::Search.packages_for_project(name)).xpath('//package').map do |package|
Package.get_by_project_and_name(name, package['name'], follow_multibuild: true, follow_project_scmsync_links: true)
end
end

def config
@config ||= ProjectConfigFile.new(project_name: name)
end
Expand Down
9 changes: 8 additions & 1 deletion src/api/app/views/webui/package/_files_view.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- nobody = !User.session

.card-body
- if files.present?
- if files.present? && (!Flipper.enabled?(:scmsync, User.session) || !package.scmsync.present? || revision_parameter.present?)
%table.table.table-bordered.table-hover.table-sm.dt-responsive.w-100#files-table
%thead
%tr
Expand All @@ -16,6 +16,13 @@
can_modify: user_can_modify_package, nobody: nobody, srcmd5: srcmd5 }
= render partial: 'file', collection: files,
cached: proc { |file| [file['name'], file['mtime'], file['md5'], file_locals].hash }, locals: file_locals
- elsif Flipper.enabled?(:scmsync, User.session) && package.scmsync.present?
%i
This package is managed with
#{link_to('SCM', package.scmsync)}.
You can also
= link_to('browse source', package_show_path(project, package, rev: revision))
here
- else
%i This package has no files yet
- if user_can_modify_package
Expand Down
31 changes: 16 additions & 15 deletions src/api/app/views/webui/package/_show_actions.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
%li.nav-item.action-report-bug
= render partial: 'webui/package/show_actions/bugzilla_owner', locals: { url: package.report_bug_or_bugzilla_url }
- if User.session
- if current_rev && is_working && is_branchable
- if current_rev && is_working && is_branchable && !package.readonly?
= render partial: 'webui/package/show_actions/branch_package', locals: { package: package, project: project,
revision: revision }
- if current_rev && is_working
= render partial: 'webui/package/show_actions/submit_package', locals: { package: package, project: project,
revision: revision }
- if User.possibly_nobody.can_modify?(package)
= render partial: 'webui/package/show_actions/delete_package'
- unless package.readonly?
- if User.possibly_nobody.can_modify?(package)
= render partial: 'webui/package/show_actions/delete_package'

- if package.kiwi_image? && policy(package).update?
= render partial: 'webui/package/show_actions/view_kiwi', locals: { package_id: package.id }
- if package.kiwi_image? && policy(package).update?
= render partial: 'webui/package/show_actions/view_kiwi', locals: { package_id: package.id }

- if services.present?
= render partial: 'webui/package/show_actions/trigger_services', locals: { package: package, project: project }
- else
= render partial: 'webui/package/show_actions/request_role_addition', locals: { package: package, project: project }
= render partial: 'webui/package/show_actions/request_deletion', locals: { package: package, project: project }
- if services.present?
= render partial: 'webui/package/show_actions/trigger_services', locals: { package: package, project: project }
- else
= render partial: 'webui/package/show_actions/request_role_addition', locals: { package: package, project: project }
= render partial: 'webui/package/show_actions/request_deletion', locals: { package: package, project: project }

//TODO: only users w/o rights should see this, maintainers should get a different dialog:
- if package.develpackage
= render partial: 'webui/package/show_actions/request_devel_project_change', locals: { package: package, project: project }
//TODO: only users w/o rights should see this, maintainers should get a different dialog:
- if package.develpackage
= render partial: 'webui/package/show_actions/request_devel_project_change', locals: { package: package, project: project }

= render partial: 'webui/shared/lock_unlock_comment', locals: { commentable: package }
= render partial: 'webui/package/show_actions/report_package', locals: { package: package }
= render partial: 'webui/shared/lock_unlock_comment', locals: { commentable: package }
= render partial: 'webui/package/show_actions/report_package', locals: { package: package }
18 changes: 10 additions & 8 deletions src/api/app/views/webui/package/_tabs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
- if Flipper.enabled?(:request_show_redesign, User.possibly_nobody)
= tab_link('RPM Lint', rpmlint_result_path(project, package), 'scrollable-tab-link')
= tab_link('Revisions', package_view_revisions_path(project, package), 'scrollable-tab-link')
- if Flipper.enabled?(:request_index, User.session)
= tab_link('Requests', packages_requests_path(project,
package,
state: %w[new review]),
'scrollable-tab-link', active: controller_name == 'bs_requests')
- else
= tab_link('Requests', package_requests_path(project, package), 'scrollable-tab-link')
- unless package.readonly?
- if Flipper.enabled?(:request_index, User.session)
= tab_link('Requests', packages_requests_path(project,
package,
state: %w[new review]),
'scrollable-tab-link', active: controller_name == 'bs_requests')
- else
= tab_link('Requests', package_requests_path(project, package), 'scrollable-tab-link')
= tab_link('Users', package_users_path(project, package), 'scrollable-tab-link')
= tab_link('Attributes', index_attribs_path(project, package), 'scrollable-tab-link')
- unless package.readonly?
= tab_link('Attributes', index_attribs_path(project, package), 'scrollable-tab-link')
= tab_link('Meta', project_package_meta_path(project, package), 'scrollable-tab-link')
20 changes: 11 additions & 9 deletions src/api/app/views/webui/package/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,19 @@
is_current_rev: @is_current_rev,
current_rev: @current_rev,
revision: @revision,
revision_parameter: @revision_parameter,
srcmd5: @srcmd5,
spider_bot: @spider_bot }
.comments
.card#comments-list
%h5.card-header.text-word-break-all
Comments
%span.badge.text-bg-primary{ id: "comment-counter-package-#{@package.id}" }
= @comments.length
.card-body#comments
= render partial: 'webui/comment/show', locals: { commentable: @package,
comment_counter_id: "#comment-counter-package-#{@package.id}" }
- unless @package.readonly?
.comments
.card#comments-list
%h5.card-header.text-word-break-all
Comments
%span.badge.text-bg-primary{ id: "comment-counter-package-#{@package.id}" }
= @comments.length
.card-body#comments
= render partial: 'webui/comment/show', locals: { commentable: @package,
comment_counter_id: "#comment-counter-package-#{@package.id}" }
- if User.session && User.possibly_nobody.can_modify?(@package)
= render partial: 'delete_dialog', locals: { project: @project, package: @package, cleanup_source: @cleanup_source }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%p.mb-0.link-danger
%i.fas.fa-user-minus
Unassign
- else
- elsif !package.readonly?
.dropdown#assignment-search
%button.btn.btn-sm.dropdown-toggle.ps-0.border-0{ data: { 'bs-toggle': 'dropdown', 'bs-auto-close': 'outside' }, aria: { expanded: 'false' } }
%strong
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- @metarobots = 'noindex,nofollow'

.card.mb-3
- unless @project.scmsync
- if Flipper.enabled?(:scmsync, User.session) || !@project.scmsync
= render partial: 'webui/package/tabs', locals: { project: @project, package: @package }
.card-body
%h3= @pagetitle
Expand Down
70 changes: 46 additions & 24 deletions src/api/app/views/webui/project/_project_packages.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,25 @@

.card-body
- if project.scmsync.present?
%p
= link_to project.scmsync do
This project is managed in SCM
- if Flipper.enabled?(:scmsync, User.session)
%table.table.table-sm.table-bordered.table-hover.w-100#packages-table-scm
%thead
%tr
%th Name
%th SCM
%tbody
- project.backend_only_packages.each do |package|
%tr
%td
= link_to(package.name, package_show_path(project, package.name))
%td
= link_to(package.scmsync) do
%i.fas.fa-up-right-from-square
= URI.parse(package.scmsync).path[1..-1]
- else
%p
= link_to project.scmsync do
This project is managed in SCM
- elsif packages.present?
.obs-dataTable
%table.table.table-sm.table-bordered.table-hover.w-100#packages-table{ data: { source: package_index_path(project: project) } }
Expand All @@ -28,29 +44,35 @@
- if User.possibly_nobody.can_modify?(project) && show_package_actions?
.pt-4
%ul.nav
%li.nav-item
= link_to(new_package_path(project), class: 'nav-link') do
%i.fas.fa-plus-circle.text-primary
Create Package
%li.nav-item
= link_to(project_new_packages_branch_path(project), class: 'nav-link') do
%i.fas.fa-code-branch.text-primary
Branch Package
- if policy(Package.new(project: project)).create?
%li.nav-item
= link_to(new_package_path(project), class: 'nav-link') do
%i.fas.fa-plus-circle.text-primary
Create Package
- if policy(Package.new(project: project)).create_branch?
%li.nav-item
= link_to(project_new_packages_branch_path(project), class: 'nav-link') do
%i.fas.fa-code-branch.text-primary
Branch Package

- content_for :ready_function do
:plain
var package_datatable_columns = [{"data": "name"}]

- if Flipper.enabled?(:package_version_tracking, User.session)
- if project.scmsync.present? && Flipper.enabled?(:scmsync, User.session)
:plain
package_datatable_columns.push({"data": "version", "orderable": false})

- if Flipper.enabled?(:labels, User.session)
initializeDataTable('#packages-table-scm');
- else
:plain
package_datatable_columns.push({"data": "labels", "orderable": false})
var package_datatable_columns = [{"data": "name"}]

- if Flipper.enabled?(:package_version_tracking, User.session)
:plain
package_datatable_columns.push({"data": "version", "orderable": false})

:plain
package_datatable_columns.push({"data": "changed"})
initializeRemoteDatatable('#packages-table', {
"columns": package_datatable_columns
});
- if Flipper.enabled?(:labels, User.session)
:plain
package_datatable_columns.push({"data": "labels", "orderable": false})

:plain
package_datatable_columns.push({"data": "changed"})
initializeRemoteDatatable('#packages-table', {
"columns": package_datatable_columns
});
5 changes: 4 additions & 1 deletion src/api/app/views/webui/project/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
aria: { controls: 'packages', selected: 'false' } }
Packages
%span.badge.text-bg-primary
= @packages.length
- if @project.scmsync.present? && Flipper.enabled?(:scmsync, User.session)
= @project.backend_only_packages.count
- else
= @packages.length
- if @inherited_packages.present?
%li.nav-item
%a.nav-link#inherited-packages-tab{ href: '#inherited-packages', role: 'tab', data: { 'bs-toggle': 'tab' },
Expand Down
3 changes: 2 additions & 1 deletion src/api/config/initializers/flipper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
{ name: :labels, description: 'Allow to apply labels to packages, submit requests and projects to improve collaboration between build service users.' },
{ name: :request_index, description: 'Redesign of listing requests' },
{ name: :canned_responses, description: 'Create messages using templates' },
{ name: :package_version_tracking, description: 'Track the local and upstream versions of your packages' }
{ name: :package_version_tracking, description: 'Track the local and upstream versions of your packages' },
{ name: :scmsync, description: 'Display extended information about packages from external SCMs' }
].freeze

Flipper.configure do
Expand Down
Loading
Loading