summaryrefslogtreecommitdiff
path: root/app/views/profiles/personal_access_tokens/index.html.haml
blob: b10f5fc08e2bdda5cc0e5c0631a310815e78b62e (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
- page_title "Personal Access Tokens"
= render 'profiles/head'

.row.prepend-top-default
  .col-lg-3.profile-settings-sidebar
    %h4.prepend-top-0
      = page_title
    %p
      You can generate a personal access token for each application you use that needs access to the GitLab API.
    %p
      You can also use personal access tokens to authenticate against Git over HTTP.
      They are the only accepted password when you have Two-Factor Authentication (2FA) enabled.

  .col-lg-9

    - if flash[:personal_access_token]
      .created-personal-access-token-container
        %h5.prepend-top-0
          Your New Personal Access Token
        .form-group
          = text_field_tag 'created-personal-access-token', flash[:personal_access_token], readonly: true, class: "form-control", 'aria-describedby' => "created-personal-access-token-help-block"
          = clipboard_button(clipboard_text: flash[:personal_access_token], title: "Copy personal access token to clipboard", placement: "left")
          %span#created-personal-access-token-help-block.help-block.text-danger Make sure you save it - you won't be able to access it again.

      %hr

    %h5.prepend-top-0
      Add a Personal Access Token
    %p.profile-settings-content
      Pick a name for the application, and we'll give you a unique token.

    = render "form", personal_access_token: @personal_access_token, scopes: @scopes

    %hr

    %h5 Active Personal Access Tokens (#{@active_personal_access_tokens.length})

    - if @active_personal_access_tokens.present?
      .table-responsive
        %table.table.active-personal-access-tokens
          %thead
            %tr
              %th Name
              %th Created
              %th Expires
              %th Scopes
              %th
          %tbody
            - @active_personal_access_tokens.each do |token|
              %tr
                %td= token.name
                %td= token.created_at.to_date.to_s(:medium)
                %td
                  - if token.expires_at.present?
                    = token.expires_at.to_date.to_s(:medium)
                  - else
                    %span.personal-access-tokens-never-expires-label Never
                %td= token.scopes.present? ? token.scopes.join(", ") : "<no scopes selected>"
                %td= link_to "Revoke", revoke_profile_personal_access_token_path(token), method: :put, class: "btn btn-danger pull-right", data: { confirm: "Are you sure you want to revoke this token? This action cannot be undone." }

    - else
      .settings-message.text-center
        You don't have any active tokens yet.

    %hr

    %h5 Inactive Personal Access Tokens (#{@inactive_personal_access_tokens.length})

    - if @inactive_personal_access_tokens.present?
      .table-responsive
        %table.table.inactive-personal-access-tokens
          %thead
            %tr
              %th Name
              %th Created
          %tbody
            - @inactive_personal_access_tokens.each do |token|
              %tr
                %td= token.name
                %td= token.created_at.to_date.to_s(:medium)

    - else
      .settings-message.text-center
        There are no inactive tokens.


:javascript
  var $dateField = $('#personal_access_token_expires_at');
  var date = $dateField.val();

  new Pikaday({
    field: $dateField.get(0),
    theme: 'gitlab-theme',
    format: 'yyyy-mm-dd',
    minDate: new Date(),
    onSelect: function(dateText) {
      $dateField.val(dateFormat(new Date(dateText), 'yyyy-mm-dd'));
    }
  });

  $("#created-personal-access-token").click(function() {
    this.select();
  });

  $("#created-personal-access-token").effect('highlight', { color: '#ffff99' }, 2000);