BigW Consortium Gitlab

index.html.haml 3.62 KB
Newer Older
1
- page_title "Personal Access Tokens"
Connor Shea committed
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
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
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.
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
40
        %table.table.active-personal-access-tokens
41 42 43
          %thead
            %tr
              %th Name
44 45
              %th Created
              %th Expires
46
              %th Scopes
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)
53 54 55 56
                %td
                  - if token.expires_at.present?
                    = token.expires_at.to_date.to_s(:medium)
                  - else
57
                    %span.personal-access-tokens-never-expires-label Never
58
                %td= token.scopes.present? ? token.scopes.join(", ") : "<no scopes selected>"
59
                %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." }
60

61
    - else
62 63
      .settings-message.text-center
        You don't have any active tokens yet.
64 65 66

    %hr

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

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

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

86 87

:javascript
88 89 90 91 92
  var $dateField = $('#personal_access_token_expires_at');
  var date = $dateField.val();

  new Pikaday({
    field: $dateField.get(0),
93
    theme: 'gitlab-theme',
Phil Hughes committed
94
    format: 'YYYY-MM-DD',
95 96 97 98
    minDate: new Date(),
    onSelect: function(dateText) {
      $dateField.val(dateFormat(new Date(dateText), 'yyyy-mm-dd'));
    }
99 100 101 102 103
  });

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

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