summaryrefslogtreecommitdiff
path: root/app/helpers/active_sessions_helper.rb
blob: 322c5b3b16d73dbebd3a39eebcd2489609ae37d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

module ActiveSessionsHelper
  # Maps a device type as defined in `ActiveSession` to an svg icon name and
  # outputs the icon html.
  #
  # see `DeviceDetector::Device::DEVICE_NAMES` about the available device types
  def active_session_device_type_icon(active_session)
    icon_name =
      case active_session.device_type
      when 'smartphone', 'feature phone', 'phablet'
        'mobile'
      when 'tablet'
        'tablet'
      when 'tv', 'smart display', 'camera', 'portable media player', 'console'
        'media'
      when 'car browser'
        'car'
      else
        'monitor-o'
      end

    sprite_icon(icon_name, css_class: 'gl-mt-2')
  end

  def revoke_session_path(active_session)
    if active_session.session_private_id
      profile_active_session_path(active_session.session_private_id)
    else
      # TODO: remove in 13.7
      profile_active_session_path(active_session.public_id)
    end
  end
end