feature(api): setup name

This commit is contained in:
simon lehericey 2024-01-17 11:05:56 +01:00
parent 47076063bb
commit 1d7b6a6a54
4 changed files with 40 additions and 1 deletions

View file

@ -2,6 +2,10 @@ class APITokensController < ApplicationController
before_action :authenticate_administrateur! before_action :authenticate_administrateur!
before_action :set_api_token, only: [:destroy] before_action :set_api_token, only: [:destroy]
def nom
@name = params[:name]
end
def create def create
@api_token, @packed_token = APIToken.generate(current_administrateur) @api_token, @packed_token = APIToken.generate(current_administrateur)

View file

@ -0,0 +1,22 @@
- content_for :title, 'Nouveau jeton dʼAPI'
= render partial: 'administrateurs/breadcrumbs',
locals: { steps: [['Tableau de bord', tableau_de_bord_helper_path],
[t('users.profil.show.profile'), profil_path],
[t('api_tokens.nom.new_token')]] }
.fr-container.fr-mt-2w
%h1= t('.new_token')
= form_with url: autorisations_api_tokens_path, method: :get, html: { class: 'fr-mt-2w' } do |f|
.fr-input-group
= f.label :name, class: 'fr-label' do
= t('.name')
%span.fr-hint-text= t('.name-hint')
= f.text_field :name, class: 'fr-input width-33', autocomplete: 'off', autocapitalize: 'off', autocorrect: 'off', spellcheck: false, required: true, value: @name, autofocus: true
%ul.fr-btns-group.fr-btns-group--inline
%li
= f.button type: :submit, class: "fr-btn fr-btn--primary" do
= t('.continue')
%li
= link_to t('.cancel'), profil_path, class: "fr-btn fr-btn--secondary"

View file

@ -0,0 +1,9 @@
---
fr:
api_tokens:
nom:
new_token: Création d'un nouveau jeton
name: Nom du jeton
name-hint: 'exemples: prod orus, test presta'
continue: continuer
cancel: retour

View file

@ -208,7 +208,11 @@ Rails.application.routes.draw do
resources :attachments, only: [:show, :destroy] resources :attachments, only: [:show, :destroy]
resources :recherche, only: [:index] resources :recherche, only: [:index]
resources :api_tokens, only: [:create, :destroy] resources :api_tokens, only: [:create, :destroy] do
collection do
get :nom
end
end
get "patron" => "root#patron" if Rails.env.development? || Rails.env.test? get "patron" => "root#patron" if Rails.env.development? || Rails.env.test?
get "suivi" => "root#suivi" get "suivi" => "root#suivi"