summaryrefslogtreecommitdiff
path: root/app/views/shared/access_tokens/_table.html.haml
blob: aa579b4a672058d962c3339b720868da9e056144 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
- no_active_tokens_message = local_assigns.fetch(:no_active_tokens_message, _('This user has no active %{type}.') % { type: type_plural })
- impersonation = local_assigns.fetch(:impersonation, false)
- resource = local_assigns.fetch(:resource, false)
- personal = !impersonation && !resource

%hr

%h5
  = _('Active %{type} (%{token_length})') % { type: type_plural, token_length: active_tokens.length }

- if personal && !personal_access_token_expiration_enforced?
  %p.profile-settings-content
    = _("Personal access tokens are not revoked upon expiration.")
- if impersonation
  %p.profile-settings-content
    = _("To see all the user's personal access tokens you must impersonate them first.")

- if personal
  = render_if_exists 'profiles/personal_access_tokens/token_expiry_notification', active_tokens: active_tokens

- if active_tokens.present?
  .table-responsive
    %table.table.active-tokens
      %thead
        %tr
          %th= _('Token name')
          %th= _('Scopes')
          %th= s_('AccessTokens|Created')
          %th
            = _('Last Used')
            = link_to sprite_icon('question-o'), help_page_path('user/profile/personal_access_tokens.md', anchor: 'view-the-last-time-a-token-was-used'), target: '_blank', rel: 'noopener noreferrer'
          %th= _('Expires')
          - if resource
            %th= _('Role')
          %th
      %tbody
        - active_tokens.each do |token|
          %tr
            %td= token.name
            %td= token.scopes.present? ? token.scopes.join(', ') : _('no scopes selected')
            %td= token.created_at.to_date.to_s(:medium)
            %td
              - if token.last_used_at?
                %span.token-last-used-label= _(time_ago_with_tooltip(token.last_used_at))
              - else
                %span.token-never-used-label= _('Never')
            %td
              - if token.expires?
                - if token.expired? || token.expired_but_not_enforced?
                  %span{ class: 'text-danger has-tooltip', title: _('Token valid until revoked') }
                    = _('Expired')
                - else
                  %span{ class: ('text-warning' if token.expires_soon?) }
                    = time_ago_with_tooltip(token.expires_at)
              - else
                %span.token-never-expires-label= _('Never')
            - if resource
              %td= resource.member(token.user).human_access
            %td= link_to _('Revoke'), revoke_route_helper.call(token), method: :put, class: "gl-button btn btn-danger btn-sm float-right qa-revoke-button #{'btn-danger-secondary' unless token.expires?}", data: { confirm: _('Are you sure you want to revoke this %{type}? This action cannot be undone.') % { type: type } }
- else
  .settings-message.text-center
    = no_active_tokens_message