Skip to content

Commit 3189396

Browse files
committed
Admin: can see providers dashboards
1 parent 19557c0 commit 3189396

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Admin::ProviderDashboardsController < AdminController
2+
def index
3+
@providers = provider_klass.all
4+
end
5+
6+
def show
7+
@provider = provider_klass.find(params[:id])
8+
@stats_facade = ProviderStatsFacade.new(@provider)
9+
10+
render 'provider/dashboard/show'
11+
end
12+
13+
private
14+
15+
def provider_klass
16+
Kernel.const_get("API#{namespace.classify}::Provider")
17+
end
18+
19+
def current_provider
20+
@provider
21+
end
22+
23+
helper_method :current_provider
24+
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div class="fr-grid-row fr-grid-row--gutters">
2+
<div class="fr-col-12">
3+
<h1>Tableaux de bords des fournisseurs</h1>
4+
5+
<div class="fr-table">
6+
<table>
7+
<caption>Liste des fournisseurs</caption>
8+
<thead>
9+
<tr>
10+
<th scope="col">Nom</th>
11+
<th scope="col">Scopes</th>
12+
<th scope="col">Actions</th>
13+
</tr>
14+
</thead>
15+
<tbody>
16+
<% @providers.each do |provider| %>
17+
<tr>
18+
<td><%= provider.name %></td>
19+
<td><%= provider.scopes.join(", ") %></td>
20+
<td>
21+
<%= link_to "Tableau de bord", admin_provider_dashboard_path(provider.uid), class: "fr-btn" %>
22+
</td>
23+
</tr>
24+
<% end %>
25+
</tbody>
26+
</table>
27+
</div>
28+
</div>
29+
</div>

app/views/shared/admin/_header.html.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
Éditeurs
5656
</a>
5757
</li>
58+
59+
<li class="fr-nav__item">
60+
<a class="fr-nav__link center" href="<%= admin_provider_dashboards_path %>" target="_self" >
61+
Fournisseurs
62+
</a>
63+
</li>
5864
</ul>
5965
</nav>
6066
</div>

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
post :stop_impersonating, on: :collection
1414
end
1515
resources :editors, only: %i[index edit update]
16+
resources :provider_dashboards, only: %i[index show], path: 'providers'
1617
end
1718

1819
get '/editeur', to: redirect('/editeur/habilitations'), as: :editor
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
RSpec.describe 'Admin: provider dashboards', app: :api_entreprise do
2+
let(:admin) { create(:user, :admin) }
3+
4+
before do
5+
login_as(admin)
6+
end
7+
8+
describe 'index page' do
9+
it 'displays the providers list linked to API Entreprise' do
10+
visit admin_provider_dashboards_path
11+
12+
expect(page).to have_content('Tableaux de bords des fournisseurs')
13+
14+
expect(page).to have_content('INSEE')
15+
expect(page).to have_no_content('France Travail')
16+
end
17+
end
18+
19+
describe 'show page' do
20+
it 'renders the provider dashboard page' do
21+
visit admin_provider_dashboards_path
22+
23+
first(:link, 'Tableau de bord').click
24+
25+
expect(page).to have_css('h1')
26+
expect(page).to have_css('iframe')
27+
end
28+
end
29+
end

0 commit comments

Comments
 (0)