Skip to content

Commit ad22e4f

Browse files
committed
feat:add logout button only in view admins
1 parent b945e85 commit ad22e4f

File tree

7 files changed

+134
-0
lines changed

7 files changed

+134
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<%#
2+
# Flash Partial
3+
4+
This partial renders flash messages on every page.
5+
6+
## Relevant Helpers:
7+
8+
- `flash`:
9+
Returns a hash,
10+
where the keys are the type of flash (alert, error, notice, etc)
11+
and the values are the message to be displayed.
12+
%>
13+
14+
<% if flash.any? %>
15+
<div class="flashes">
16+
<% flash.each do |key, value| -%>
17+
<% next unless value.respond_to?(:html_safe) %>
18+
<div class="flash flash-<%= key %>"><%= value.html_safe %></div>
19+
<% end -%>
20+
</div>
21+
<% end %>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<svg hidden xmlns="http://www.w3.org/2000/svg">
2+
<symbol id="icon-cancel" viewBox="0 0 48 48">
3+
<path fill-rule="evenodd" d="M24 19.757l-8.485-8.485c-.784-.783-2.047-.782-2.827 0l-1.417 1.416c-.777.777-.78 2.046.002 2.827L19.757 24l-8.485 8.485c-.783.784-.782 2.047 0 2.827l1.416 1.417c.777.777 2.046.78 2.827-.002L24 28.243l8.485 8.485c.784.783 2.047.782 2.827 0l1.417-1.416c.777-.777.78-2.046-.002-2.827L28.243 24l8.485-8.485c.783-.784.782-2.047 0-2.827l-1.416-1.417c-.777-.777-2.046-.78-2.827.002L24 19.757zM24 47c12.703 0 23-10.297 23-23S36.703 1 24 1 1 11.297 1 24s10.297 23 23 23z" />
4+
</symbol>
5+
6+
<symbol id="icon-eyeglass" viewBox="0 0 48 48">
7+
<path d="M27.885 32.515c-2.864 1.966-6.333 3.116-10.07 3.116C7.976 35.63 0 27.656 0 17.817 0 7.976 7.976 0 17.816 0S35.63 7.976 35.63 17.816c0 3.736-1.15 7.205-3.115 10.07l14.53 14.53c1.278 1.277 1.275 3.352 0 4.628-1.28 1.278-3.353 1.278-4.63 0l-14.53-14.53zm-10.07-3.736c6.056 0 10.964-4.91 10.964-10.964 0-6.055-4.91-10.964-10.964-10.964-6.055 0-10.964 4.91-10.964 10.964 0 6.055 4.91 10.963 10.964 10.963z" />
8+
</symbol>
9+
10+
<symbol id="icon-up-caret" viewBox="0 0 48 48">
11+
<path d="M2.988 33.02c-1.66 0-1.943-.81-.618-1.824l20-15.28c.878-.672 2.31-.67 3.188 0l20.075 15.288c1.316 1.003 1.048 1.816-.62 1.816H2.987z" />
12+
</symbol>
13+
</svg>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<%#
2+
# Javascript Partial
3+
4+
This partial imports the necessary javascript on each page.
5+
By default, it includes the application JS,
6+
but each page can define additional JS sources
7+
by providing a `content_for(:javascript)` block.
8+
%>
9+
10+
<% Administrate::Engine.javascripts.each do |js_path| %>
11+
<%= javascript_include_tag js_path %>
12+
<% end %>
13+
14+
<%= yield :javascript %>
15+
16+
<% if Rails.env.test? %>
17+
<%= javascript_tag do %>
18+
$.fx.off = true;
19+
$.ajaxSetup({ async: false });
20+
<% end %>
21+
<% end %>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<%#
2+
# Navigation
3+
4+
This partial is used to display the navigation in Administrate.
5+
By default, the navigation contains navigation links
6+
for all resources in the admin dashboard,
7+
as defined by the routes in the `admin/` namespace
8+
%>
9+
10+
<nav class="navigation">
11+
<%= link_to(t("administrate.navigation.back_to_app"), root_url, class: "button button--alt button--nav") if defined?(root_url) %>
12+
13+
<% Administrate::Namespace.new(namespace).resources_with_index_route.each do |resource| %>
14+
<%= link_to(
15+
display_resource_name(resource),
16+
resource_index_route(resource),
17+
class: "navigation__link navigation__link--#{nav_link_state(resource)}"
18+
) if accessible_action?(model_from_resource(resource), :index) %>
19+
20+
<% end %>
21+
<%= link_to "Logout", destroy_user_session_path, method: :delete, class: "btn-danger" %>
22+
</nav>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<%#
2+
# Stylesheet Partial
3+
4+
This partial imports the necessary stylesheets on each page.
5+
By default, it includes the application CSS,
6+
but each page can define additional CSS sources
7+
by providing a `content_for(:stylesheet)` block.
8+
%>
9+
10+
<% Administrate::Engine.stylesheets.each do |css_path| %>
11+
<%= stylesheet_link_tag css_path %>
12+
<% end %>
13+
14+
<%= yield :stylesheet %>
15+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<%#
2+
# Application Layout
3+
4+
This view template is used as the layout
5+
for every page that Administrate generates.
6+
7+
By default, it renders:
8+
- Navigation
9+
- Content for a search bar
10+
(if provided by a `content_for` block in a nested page)
11+
- Flashes
12+
- Links to stylesheets and JavaScripts
13+
%>
14+
15+
<!DOCTYPE html>
16+
<html lang="<%= I18n.locale %>">
17+
<head>
18+
<meta charset="utf-8">
19+
<meta name="ROBOTS" content="NOODP">
20+
<meta name="viewport" content="initial-scale=1">
21+
<title>
22+
<%= content_for(:title) %> - <%= application_title %>
23+
</title>
24+
<%= render "stylesheet" %>
25+
<%= csrf_meta_tags %>
26+
<%= csp_meta_tag if defined?(csp_meta_tag) %>
27+
</head>
28+
<body>
29+
<%= render "icons" %>
30+
<div class="app-container">
31+
<%= render "navigation" -%>
32+
33+
<main class="main-content">
34+
<%= render "flashes" -%>
35+
<%= yield %>
36+
</main>
37+
</div>
38+
39+
<%= render "javascript" %>
40+
</body>
41+
</html>

app/views/layouts/application.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212

1313
<body>
1414
<%= yield %>
15+
1516
</body>
1617
</html>

0 commit comments

Comments
 (0)