Skip to content

Commit

Permalink
Admin: bootstrap whitelisted verified email module
Browse files Browse the repository at this point in the history
  • Loading branch information
skelz0r committed Jan 23, 2025
1 parent 4bb0d30 commit 16d296c
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Admin::WhitelistedVerifiedEmailsController < AdminController
def index
@verified_emails = VerifiedEmail.where(status: 'whitelisted').order(created_at: :desc).page(params[:page]).per(50)
end
end
6 changes: 5 additions & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
class AdminController < AuthenticatedUserController
before_action :check_user_is_admin!

def index; end
layout 'admin'

def index
render layout: 'application'
end

def check_user_is_admin!
return if current_user.admin?
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<%= render partial: 'shared/alerts' %>

<ul>
<li>Hello</li>
<li><%= link_to 'Emails en liste blanche', admin_whitelisted_verified_emails_path %></li>
</ul>
</div>
44 changes: 44 additions & 0 deletions app/views/admin/whitelisted_verified_emails/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<turbo-frame id="verified_emails_table">
<div class="fr-table fr-table--bordered">
<div class="fr-table__container">
<div class="fr-table__content">
<table>
<thead>
<tr>
<%
%w[
email
created_at
actions
].each do |attr|
%>
<th scope="col">
<%= t(".table.header.#{attr}") %>
</th>
<% end %>
</tr>
</thead>

<tbody>
<% @verified_emails.each do |verified_email| %>
<tr id="<%= dom_id(verified_email) %>">
<td class="verified-email-email">
<%= verified_email.email %>
</td>
<td class="verified-email-created_at">
<%= verified_email.created_at.to_date %>
</td>
<td class="verified-email-actions">
Supprimer
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>

<%= paginate @verified_emails %>
</turbo-frame>

25 changes: 25 additions & 0 deletions app/views/layouts/admin.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<%= content_for(:body) do %>
<div class="fr-container">
<div class="dashboard-sub-header">
<div class="sub-header">
<div>
<h1 class="fr-m-0">
<%= t("admin.#{controller_name}.#{action_name}.title") %>
</h1>
</div>

<% if content_for?(:header_action) %>
<div>
<%= content_for(:header_action) %>
</div>
<% end %>
</div>
</div>

<%= render partial: 'shared/alerts' %>

<%= yield %>
</div>
<% end %>

<%= render template: 'layouts/application' %>
8 changes: 8 additions & 0 deletions config/locales/admin.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ fr:
admin:
index:
title: Espace administrateur
whitelisted_verified_emails:
index:
title: Emails en liste blanche
table:
header:
email: Email
created_at: Date de création
actions: Actions
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@

get '/admin', to: 'admin#index', as: :admin

namespace :admin do
resources :whitelisted_verified_emails, only: %w[index new create], path: 'emails-verifies'
end

namespace :api do
resources :frontal, only: :index
end
Expand Down
16 changes: 16 additions & 0 deletions features/admin/emails_verifies.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# language: fr

Fonctionnalité: Espace admin: emails en liste blanche
En tant qu'administrateur, je peux voir les emails en liste blanche et en ajouter des supplémentaires,
dans le cas où on nous contacte au support et qu'on nous certifie que l'email est bien valide

Contexte:
Sachant que je suis un administrateur
Et que je me connecte

Scénario: Je peux consulter les emails en liste blanche
Quand il y a l'email "[email protected]" marqué en tant que "liste blanche"
Et qu'il y a l'email "[email protected]" marqué en tant que "délivrable"
Et que je me rends sur le module "Emails vérifiés" de l'espace administrateur
Alors la page contient "[email protected]"
Et la page ne contient pas "[email protected]"
4 changes: 4 additions & 0 deletions features/step_definitions/admin_steps.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Quand("je me rends sur le module {string} de l'espace administrateur") do |path|
visit "/admin/#{path.parameterize}"
end

Quand("je vais sur l'espace administrateur") do
visit admin_path
end
Expand Down
10 changes: 10 additions & 0 deletions features/step_definitions/whitelisted_verified_emails_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Quand("il y a l'email {string} marqué en tant que {string}") do |email, kind|
case kind
when 'délivrable'
status = 'deliverable'
when 'liste blanche'
status = 'whitelisted'
end

create(:verified_email, email:, status:)
end

0 comments on commit 16d296c

Please sign in to comment.