Skip to content

Commit

Permalink
Refactoring: move in the component everything belongs to its logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Apr 11, 2023
1 parent a2e8302 commit 7257571
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
17 changes: 16 additions & 1 deletion src/api/app/components/bs_request_state_badge_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@ def call
content_tag(
:span,
tag.i(class: 'fas fa-code-pull-request me-1').concat(@bs_request.state),
class: ['badge', "bg-#{helpers.request_badge_color(@bs_request.state)}", @css_class]
class: ['badge', "bg-#{decode_state_color(@bs_request.state)}", @css_class]
)
end

def decode_state_color(state)
case state
when :review, :new
'secondary'
when :declined, :revoke
'danger'
when :superseded
'warning'
when :accepted
'success'
else
'dark'
end
end
end
15 changes: 0 additions & 15 deletions src/api/app/helpers/webui/notification_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,6 @@ def link_to_show_less_or_more
link_to("Show #{less_or_more}", my_notifications_path(parameters))
end

def request_badge_color(state)
case state
when :review, :new
'secondary'
when :declined, :revoke
'danger'
when :superseded
'warning'
when :accepted
'success'
else
'dark'
end
end

private

def mark_as_read_or_unread_button(notification)
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/request/beta_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
-# superseded
- if @bs_request.superseded_by.present?
%li
%mark.text-nowrap.text-light{ class: "bg-#{request_badge_color(@bs_request.state)}" } Superseded
%mark.text-nowrap.text-light{ class: "bg-#{BsRequestStateBadgeComponent.decode_state_color(@bs_request.state)}" } Superseded
by
= link_to "##{@bs_request.superseded_by}", number: @bs_request.superseded_by
-# superseding statement
Expand Down

0 comments on commit 7257571

Please sign in to comment.