summaryrefslogtreecommitdiff
path: root/app/views/profiles/personal_access_tokens/index.html.haml
blob: 77726d34fbc8aac56b48f84a53829ae967578930 (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
- page_title "Personal Access Tokens"
- header_title page_title, profile_personal_access_tokens_path

.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 GitLab.
  .col-lg-9
    %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.
    = form_for [:profile, @personal_access_token], method: :post, html: { class: 'js-requires-input' } do |f|

      .form-group
        = f.label :name, class: 'label-light'
        = f.text_field :name, class: "form-control", required: true

      .form-group
        = f.label :expires_at, class: 'label-light'
        = f.text_field :expires_at, class: "form-control datepicker", required: false

      .prepend-top-default
        = f.submit 'Add Personal Access Token', class: "btn btn-create"

    %hr

    %h5= "Active Personal Access Tokens (#{@active_personal_access_tokens.count})"

    - if @active_personal_access_tokens.exists?
      .table-responsive
        %table.table.table-striped.table-hover
          %thead
            %tr
              %th Name
              %th Token
              %th Created
              %th Expires
              %th Actions
          %tbody
            - @active_personal_access_tokens.active.each do |token|
              %tr
                %td= token.name
                %td.input-group.personal-access-tokens-token-column
                  %input.form-control{type: "text", value: token.token, readonly: true}
                  %div.input-group-btn
                    %button.btn.btn-default{type: "button", data: {clipboard_text: token.token}}
                      %i.fa.fa-clipboard
                %td= token.created_at.to_date
                - if token.expires_at.present?
                  %td= token.expires_at.to_date
                - else
                  %td
                    %span.personal-access-tokens-never-expires-label Never
                %td= link_to "Revoke", revoke_profile_personal_access_token_path(token), method: :put, class: "btn btn-danger", data: {confirm: t('profile.personal_access_tokens.revoke.confirmation')}

    - else
      %span You don't have any active tokens yet.

    %hr

    %h5= "Inactive Personal Access Tokens (#{@inactive_personal_access_tokens.count})"

    - if @inactive_personal_access_tokens.exists?
      .table-responsive
        %table.table.table-striped.table-hover
          %thead
            %tr
              %th Name
              %th Token
              %th Created
          %tbody
            - @inactive_personal_access_tokens.order("revoked, expires_at").each do |token|
              %tr
                %td= token.name
                %td.input-group.personal-access-tokens-token-column
                  %input.form-control{type: "text", value: token.token, readonly: true}
                  %div.input-group-btn
                    %button.btn.btn-default{type: "button", data: {clipboard_text: token.token}}
                      %i.fa.fa-clipboard
                %td= token.created_at.to_date

    - else
      %span No inactive tokens.


:javascript
  $(".datepicker").datepicker({
    dateFormat: "yy-mm-dd",
    onSelect: function(dateText, inst) { $("#personal_access_token_expires_at").val(dateText) }
  }).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $('#personal_access_token_expires_at').val()));