Skip to content

Commit

Permalink
Add update information to the conversations tab
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp-work committed Nov 24, 2023
1 parent 494a690 commit 9342d99
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 6 deletions.
69 changes: 69 additions & 0 deletions src/api/app/components/patchinfo_component.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.pb-3
%h4
= link_to(@path) do
= @patchinfo['summary']
= category
= rating
= stopped
= retracted
%p
Patch created by
- if (packager = User.find_by(login: patchinfo['packager']) || User.find_by(email: Mail::Address.new(patchinfo['packager']).address))
= render UserAvatarComponent.new(packager.login)
- else
= @patchinfo['packager']
- if @patchinfo.key?('incident')
in the maintenance incident request
- if (incident = BsRequest.find_by(number: @patchinfo['incident']))
= link_to(request_show_path(incident)) do
\##{@patchinfo['incident']}
- else
\##{@patchinfo['incident']}

- if @patchinfo['description'].present?
%h5 Patch description
%p= @patchinfo['description']

- if @patchinfo['message'].present?
%h5 Pop-up message
%p= @patchinfo['message']

- if @patchinfo['releasetarget'].present?
%h5 Targeted for release in the following projects
%ul
- @patchinfo['releasetarget'].each do |releasetarget|
%li
- if (project = Project.find_by_name(releasetarget['project']))
= link_to(project_show_path(project)) do
= releasetarget['project']
- else
= releasetarget['project']
- if releasetarget.key?('repository')
Repository:
= releasetarget['repository']

- if @patchinfo['binary'].present?
%h5 Affected binaries
%ul
- @patchinfo['binary'].each do |binary|
%li= binary

- if @patchinfo['package'].present?
%h5 Affected packages
%ul
- @patchinfo['package'].each do |package|
%li= package

- if @patchinfo['issue'].present?
%h5 Issues related to the patch
%ul
- @patchinfo['issue'].each do |issue_hash|
- if (issue = Issue.find_or_create_by_name_and_tracker(issue_hash['id'], issue_hash['tracker']))
%li
= link_to(issue.url) do
#{issue.label}:
= issue.state
= issue.summary

- properties.each do |property|
%span.badge.text-bg-info= property
58 changes: 58 additions & 0 deletions src/api/app/components/patchinfo_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

class PatchinfoComponent < ApplicationComponent
attr_reader :patchinfo, :path

CATEGORY_COLOR = { ptf: 'text-bg-danger',
security: 'text-bg-warning',
recommended: 'text-bg-info',
optional: 'text-bg-secondary',
feature: 'text-bg-success' }.freeze

RATING_COLOR = { low: 'text-bg-secondary',
moderate: 'text-bg-success',
important: 'text-bg-warning',
critical: 'text-bg-danger' }.freeze

def initialize(patchinfo, path)
super
@patchinfo = Xmlhash.parse(patchinfo)
@path = path
end

def category
badge(patchinfo['category'], CATEGORY_COLOR[patchinfo['category'].to_sym])
end

def rating
badge("#{patchinfo['rating']} priority", RATING_COLOR[patchinfo['rating'].to_sym])
end

def stopped
return '' unless @patchinfo['stopped']

badge('stopped', 'text-bg-danger')
end

def retracted
return '' unless @patchinfo['retracted']

badge('retracted', 'text-bg-danger')
end

def properties
['reboot_needed', 'relogin_needed', 'zypp_restart_needed'].filter_map do |property|
patchinfo.key?(property) ? property : nil
end
end

def render?
patchinfo.present?
end

private

def badge(text, color = 'text-bg-secondary')
tag.span(text.humanize, class: "badge #{color}")
end
end
20 changes: 14 additions & 6 deletions src/api/app/views/webui/request/beta_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@

.col-md-8.order-md-1.order-sm-2
.row
.card.p-4#description-text
- if @bs_request.description.present?
%h4.mb-4 Description
= render partial: 'webui/shared/collapsible_text', locals: { text: @bs_request.description, extra_css_classes: 'full-width' }
- else
%i No description set
.card.p-4
#description-text
- if @bs_request.description.present?
%h3.mb-4 Description
= render partial: 'webui/shared/collapsible_text', locals: { text: @bs_request.description, extra_css_classes: 'full-width' }
- else
%i No description set
#patchinfo-details
- if @bs_request.bs_request_actions.exists?(source_package: 'patchinfo')
%h3.my-4 Patches
- @bs_request.bs_request_actions.where(source_package: 'patchinfo').each do |patchinfo|
- patchinfo_package = Package.find_by_project_and_name(patchinfo.source_project, patchinfo.source_package)
- patchinfo_text = patchinfo_package.source_file('_patchinfo', rev: patchinfo.source_rev || patchinfo_package.rev)
= render PatchinfoComponent.new(patchinfo_text, request_changes_path(number: @bs_request.number, request_action_id: patchinfo.id))

#comments-list
.timeline.pb-2.ms-3{ data: { comment_counter: local_assigns[:comment_counter_id] } }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class PatchinfoComponentPreview < ViewComponent::Preview
# Preview at http://HOST:PORT/rails/view_components/patchinfo_component/preview
def preview
patchinfo_action = BsRequestAction.find_by(source_package: 'patchinfo')
patchinfo_package = Package.find_by_project_and_name(patchinfo_action.source_project, patchinfo_action.source_package)
patchinfo_text = patchinfo_package.source_file('_patchinfo')
render(PatchinfoComponent.new(patchinfo_text, request_changes_path(number: patchinfo_action.bs_request.number, request_action_id: patchinfo_action.id)))
end
end

0 comments on commit 9342d99

Please sign in to comment.