2022-07-23 23:45:48 +05:30
- ajax = local_assigns.fetch(:ajax, false)
2020-05-24 23:13:21 +05:30
- title = local_assigns.fetch(:title, _('Add a %{type}') % { type: type })
- prefix = local_assigns.fetch(:prefix, :personal_access_token)
2021-09-30 23:02:18 +05:30
- help_path = local_assigns.fetch(:help_path)
2022-03-02 08:16:31 +05:30
- resource = local_assigns.fetch(:resource, false)
2021-09-30 23:02:18 +05:30
- access_levels = local_assigns.fetch(:access_levels, false)
- default_access_level = local_assigns.fetch(:default_access_level, false)
2020-05-24 23:13:21 +05:30
2020-06-23 00:09:42 +05:30
%h5.gl-mt-0
2020-05-24 23:13:21 +05:30
= title
%p.profile-settings-content
= _("Enter the name of your application, and we'll return a unique %{type}.") % { type: type }
2022-07-23 23:45:48 +05:30
= gitlab_ui_form_for token, as: prefix, url: path, method: :post, html: { id: 'js-new-access-token-form', class: 'js-requires-input' }, remote: ajax do |f|
2020-05-24 23:13:21 +05:30
2022-07-23 23:45:48 +05:30
= form_errors(token, pajamas_alert: true)
2020-05-24 23:13:21 +05:30
.row
2021-09-30 23:02:18 +05:30
.form-group.col
.row
= f.label :name, _('Token name'), class: 'label-bold col-md-12'
.col-md-6
2022-05-07 20:08:51 +05:30
- resource_type = resource.is_a?(Group) ? "group" : "project"
2021-09-30 23:02:18 +05:30
= f.text_field :name, class: 'form-control gl-form-input', required: true, data: { qa_selector: 'access_token_name_field' }, :'aria-describedby' => 'access_token_help_text'
2022-05-07 20:08:51 +05:30
%span.form-text.text-muted.col-md-12#access_token_help_text= _("For example, the application using the token or the purpose of the token. Do not give sensitive information for the name of the token, as it will be visible to all %{resource_type} members.") % { resource_type: resource_type }
2020-05-24 23:13:21 +05:30
.row
2022-05-07 20:08:51 +05:30
.col
.js-access-tokens-expires-at{ data: expires_at_field_data }
2022-08-27 11:52:29 +05:30
= f.text_field :expires_at, class: 'gl-datepicker-input form-control gl-form-input', placeholder: 'YYYY-MM-DD', autocomplete: 'off', data: { js_name: 'expiresAt' }
2020-05-24 23:13:21 +05:30
2022-03-02 08:16:31 +05:30
- if resource
2021-09-30 23:02:18 +05:30
.row
.form-group.col-md-6
= label_tag :access_level, _("Select a role"), class: "label-bold"
.select-wrapper
2022-03-02 08:16:31 +05:30
= select_tag :"#{prefix}[access_level]", options_for_select(access_levels, default_access_level), class: "form-control select-control", data: { qa_selector: 'access_token_access_level' }
2021-09-30 23:02:18 +05:30
= sprite_icon('chevron-down', css_class: "gl-icon gl-absolute gl-top-3 gl-right-3 gl-text-gray-200")
2020-05-24 23:13:21 +05:30
.form-group
2021-09-30 23:02:18 +05:30
%b{ :'aria-describedby' => 'select_scope_help_text' }
= s_('Tokens|Select scopes')
%p.text-secondary#select_scope_help_text
= s_('Tokens|Scopes set the permission levels granted to the token.')
2022-03-02 08:16:31 +05:30
= link_to _("Learn more."), help_path, target: '_blank', rel: 'noopener noreferrer'
2022-06-21 17:19:12 +05:30
= render 'shared/tokens/scopes_form', prefix: prefix, token: token, scopes: scopes, f: f
2020-05-24 23:13:21 +05:30
2020-07-28 23:09:34 +05:30
.gl-mt-3
2021-04-17 20:07:23 +05:30
= f.submit _('Create %{type}') % { type: type }, class: 'gl-button btn btn-confirm', data: { qa_selector: 'create_token_button' }