Skip to content

Commit

Permalink
Get rid of 'rubocop:enable ViewComponent/AvoidGlobalState'
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Feb 23, 2024
1 parent d562e13 commit 4834edf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
14 changes: 1 addition & 13 deletions src/api/app/components/notification_notifiable_link_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def notifiable_link_path
when 'Event::ReportForProject', 'Event::ReportForPackage'
@notification.event_type.constantize.notification_link_path(@notification)
when 'Event::ReportForUser'
Rails.application.routes.url_helpers.user_path(@notification.event_payload['user_login'], notification_id: @notification.id) if !user_event.is_deleted? || current_user_is_admin
Rails.application.routes.url_helpers.user_path(@notification.event_payload['user_login'], notification_id: @notification.id) if !helpers.user_by_login(@notification.event_payload['user_login']).is_deleted? || helpers.current_user_is_admin
when 'Event::ReportForRequest'
bs_request = @notification.notifiable.reportable
Rails.application.routes.url_helpers.request_show_path(bs_request.number, notification_id: @notification.id)
Expand Down Expand Up @@ -206,17 +206,5 @@ def path_to_commentables_on_reports(event_payload:, notification_id:)
anchor: 'comments-list')
end
end

# rubocop:disable ViewComponent/AvoidGlobalState
def user_event
User.find_by_login(@notification.event_payload['user_login'])
end
# rubocop:enable ViewComponent/AvoidGlobalState

# rubocop:disable ViewComponent/AvoidGlobalState
def current_user_is_admin
User.admin_session?
end
# rubocop:enable ViewComponent/AvoidGlobalState
end
# rubocop:enable Metrics/ClassLength
8 changes: 8 additions & 0 deletions src/api/app/helpers/webui/user_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ def filter_message(params)
"#{result}."
end

def user_by_login(user_login)
User.find_by_login(user_login)
end

def current_user_is_admin
User.admin_session?
end

private

def project_package_message
Expand Down

0 comments on commit 4834edf

Please sign in to comment.