summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-02-09 15:21:09 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-02-28 22:15:40 +0000
commitf0ea7130f7bf0e7a3702d863b4d246f524b6c14a (patch)
treeec626d2d42c7942fa1cbc1505275ed7d4de52fa5 /app/views
parentc2b1cdef7e8cdaec35bd0844301ce8f06ed742b7 (diff)
downloadgitlab-ce-f0ea7130f7bf0e7a3702d863b4d246f524b6c14a.tar.gz
refactors documentation and personal access tokens form to not allow admins to generate non impersionation tokens
Diffstat (limited to 'app/views')
-rw-r--r--app/views/admin/personal_access_tokens/_form.html.haml28
-rw-r--r--app/views/admin/personal_access_tokens/index.html.haml23
-rw-r--r--app/views/profiles/personal_access_tokens/_form.html.haml2
-rw-r--r--app/views/profiles/personal_access_tokens/index.html.haml2
4 files changed, 13 insertions, 42 deletions
diff --git a/app/views/admin/personal_access_tokens/_form.html.haml b/app/views/admin/personal_access_tokens/_form.html.haml
deleted file mode 100644
index d194a0fd511..00000000000
--- a/app/views/admin/personal_access_tokens/_form.html.haml
+++ /dev/null
@@ -1,28 +0,0 @@
-- personal_access_token = local_assigns.fetch(:personal_access_token)
-- scopes = local_assigns.fetch(:scopes)
-
-= form_for [:admin_user, personal_access_token], method: :post, html: { class: 'js-requires-input' } do |f|
-
- = form_errors(personal_access_token)
-
- .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: "datepicker form-control"
-
- .form-group
- = f.label :scopes, class: 'label-light'
- = render 'shared/tokens/scopes_form', prefix: 'personal_access_token', token: personal_access_token, scopes: scopes
-
- .form-group
- = f.label :impersonation, class: 'label-light'
- %fieldset
- = f.check_box :impersonation
- = f.label 'impersonation', 'You can impersonate the user'
- %span= "(Normal users will not see this type of token)"
-
- .prepend-top-default
- = f.submit 'Create Personal Access Token', class: "btn btn-create"
diff --git a/app/views/admin/personal_access_tokens/index.html.haml b/app/views/admin/personal_access_tokens/index.html.haml
index 90aade17e1b..c4646afcee3 100644
--- a/app/views/admin/personal_access_tokens/index.html.haml
+++ b/app/views/admin/personal_access_tokens/index.html.haml
@@ -3,18 +3,15 @@
.row.prepend-top-default
.col-lg-12
-
%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
+ = render "profiles/personal_access_tokens/form", user: :admin_user, 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
@@ -44,7 +41,6 @@
= clipboard_button(clipboard_text: personal_access_token.token)
%td= personal_access_token.impersonation
%td= link_to "Revoke", revoke_admin_user_personal_access_token_path(id: personal_access_token.id, user_id: personal_access_token.user.username), 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
This user has no active tokens.
@@ -52,7 +48,6 @@
%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
@@ -65,16 +60,20 @@
%tr
%td= token.name
%td= token.created_at.to_date.to_s(:medium)
-
- else
.settings-message.text-center
This user has no inactive tokens.
-
:javascript
- var date = $('#personal_access_token_expires_at').val();
+ var $dateField = $('#personal_access_token_expires_at');
+ var date = $dateField.val();
- var datepicker = $(".datepicker").datepicker({
- dateFormat: "yy-mm-dd",
- minDate: 0
+ 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'));
+ }
});
diff --git a/app/views/profiles/personal_access_tokens/_form.html.haml b/app/views/profiles/personal_access_tokens/_form.html.haml
index 3f6efa33953..286d35d1f3b 100644
--- a/app/views/profiles/personal_access_tokens/_form.html.haml
+++ b/app/views/profiles/personal_access_tokens/_form.html.haml
@@ -1,7 +1,7 @@
- personal_access_token = local_assigns.fetch(:personal_access_token)
- scopes = local_assigns.fetch(:scopes)
-= form_for [:profile, personal_access_token], method: :post, html: { class: 'js-requires-input' } do |f|
+= form_for [user, personal_access_token], method: :post, html: { class: 'js-requires-input' } do |f|
= form_errors(personal_access_token)
diff --git a/app/views/profiles/personal_access_tokens/index.html.haml b/app/views/profiles/personal_access_tokens/index.html.haml
index e35691d7300..c74cc1b6906 100644
--- a/app/views/profiles/personal_access_tokens/index.html.haml
+++ b/app/views/profiles/personal_access_tokens/index.html.haml
@@ -29,7 +29,7 @@
%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
+ = render "form", user: :profile, personal_access_token: @personal_access_token, scopes: @scopes
%hr