Skip to content

Commit

Permalink
Move method from component to helper
Browse files Browse the repository at this point in the history
The helper that returns the type of request action in a humanized
manner, is going to be used from another part of the code as well.
  • Loading branch information
saraycp committed Apr 25, 2022
1 parent 5fba5a8 commit 9eba086
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/api/app/components/notification_notifiable_link_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def call
def notifiable_link_text
case @notification.event_type
when 'Event::RequestStatechange', 'Event::RequestCreate', 'Event::ReviewWanted'
"#{type_of_action(@notification.notifiable)} Request ##{@notification.notifiable.number}"
"#{helpers.request_type_of_action(@notification.notifiable)} Request ##{@notification.notifiable.number}"
when 'Event::CommentForRequest'
bs_request = @notification.notifiable.commentable
"Comment on #{type_of_action(bs_request)} Request ##{bs_request.number}"
"Comment on #{helpers.request_type_of_action(bs_request)} Request ##{bs_request.number}"
when 'Event::CommentForProject'
'Comment on Project'
when 'Event::CommentForPackage'
Expand Down Expand Up @@ -46,11 +46,4 @@ def notifiable_link_path
anchor: 'comments-list')
end
end

# Returns strings like "Add Role", "Submit", etc.
def type_of_action(bs_request)
return 'Multiple Actions\'' if bs_request.bs_request_actions.size > 1

bs_request.bs_request_actions.first.type.titleize
end
end
7 changes: 7 additions & 0 deletions src/api/app/helpers/webui/request_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,11 @@ def list_maintainers(maintainers)
user_with_realname_and_icon(maintainer, short: true)
end.to_sentence.html_safe
end

# Returns strings like "Add Role", "Submit", etc.
def request_type_of_action(bs_request)
return 'Multiple Actions\'' if bs_request.bs_request_actions.size > 1

bs_request.bs_request_actions.first.type.titleize
end
end

0 comments on commit 9eba086

Please sign in to comment.