index.html.haml 3.6 KB
Newer Older
1
- page_title "Personal Access Tokens"
C
Connor Shea 已提交
2
= render 'profiles/head'
3 4 5 6 7 8

.row.prepend-top-default
  .col-lg-3.profile-settings-sidebar
    %h4.prepend-top-0
      = page_title
    %p
T
Timothy Andrew 已提交
9
      You can generate a personal access token for each application you use that needs access to the GitLab API.
10
    %p
11 12
      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.
13

14
  .col-lg-9
15 16

    - if flash[:personal_access_token]
17
      .created-personal-access-token-container
T
Timothy Andrew 已提交
18 19 20
        %h5.prepend-top-0
          Your New Personal Access Token
        .form-group
21
          = text_field_tag 'created-personal-access-token', flash[:personal_access_token], readonly: true, class: "form-control", 'aria-describedby' => "created-personal-access-token-help-block"
22
          = clipboard_button(clipboard_text: flash[:personal_access_token], title: "Copy personal access token to clipboard", placement: "left")
23
          %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.
T
Timothy Andrew 已提交
24 25

      %hr
26

27 28 29 30 31
    %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.

32
    = render "form", personal_access_token: @personal_access_token, scopes: @scopes
33 34 35

    %hr

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

38
    - if @active_personal_access_tokens.present?
39
      .table-responsive
T
Timothy Andrew 已提交
40
        %table.table.active-personal-access-tokens
41 42 43
          %thead
            %tr
              %th Name
44 45
              %th Created
              %th Expires
46
              %th Scopes
T
Timothy Andrew 已提交
47
              %th
48
          %tbody
49
            - @active_personal_access_tokens.each do |token|
50 51
              %tr
                %td= token.name
52
                %td= token.created_at.to_date.to_s(:medium)
T
Timothy Andrew 已提交
53
                %td
54 55 56
                  - if token.expires?
                    %span{ class: ('text-warning' if token.expires_soon?) }
                      In #{distance_of_time_in_words_to_now(token.expires_at)}
T
Timothy Andrew 已提交
57
                  - else
58
                    %span.personal-access-tokens-never-expires-label Never
59
                %td= token.scopes.present? ? token.scopes.join(", ") : "<no scopes selected>"
T
Timothy Andrew 已提交
60
                %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." }
61

62
    - else
T
Timothy Andrew 已提交
63 64
      .settings-message.text-center
        You don't have any active tokens yet.
65 66 67

    %hr

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

70
    - if @inactive_personal_access_tokens.present?
71
      .table-responsive
T
Timothy Andrew 已提交
72
        %table.table.inactive-personal-access-tokens
73 74 75 76 77
          %thead
            %tr
              %th Name
              %th Created
          %tbody
78
            - @inactive_personal_access_tokens.each do |token|
79 80
              %tr
                %td= token.name
81
                %td= token.created_at.to_date.to_s(:medium)
82 83

    - else
T
Timothy Andrew 已提交
84 85
      .settings-message.text-center
        There are no inactive tokens.
86

87 88

:javascript
P
Phil Hughes 已提交
89 90 91 92 93
  var $dateField = $('#personal_access_token_expires_at');
  var date = $dateField.val();

  new Pikaday({
    field: $dateField.get(0),
P
Phil Hughes 已提交
94
    theme: 'gitlab-theme',
P
Phil Hughes 已提交
95
    format: 'yyyy-mm-dd',
P
Phil Hughes 已提交
96 97 98 99
    minDate: new Date(),
    onSelect: function(dateText) {
      $dateField.val(dateFormat(new Date(dateText), 'yyyy-mm-dd'));
    }
T
Timothy Andrew 已提交
100 101 102 103 104
  });

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