mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
Add users management to site settings (#126)
This commit is contained in:
committed by
GitHub
parent
bc15140512
commit
37fb99a868
@@ -1,20 +0,0 @@
|
||||
<%#
|
||||
# Flash Partial
|
||||
|
||||
This partial renders flash messages on every page.
|
||||
|
||||
## Relevant Helpers:
|
||||
|
||||
- `flash`:
|
||||
Returns a hash,
|
||||
where the keys are the type of flash (alert, error, notice, etc)
|
||||
and the values are the message to be displayed.
|
||||
%>
|
||||
|
||||
<% if flash.any? %>
|
||||
<div class="flashes">
|
||||
<% flash.each do |key, value| -%>
|
||||
<div class="flash flash-<%= key %>"><%= value.html_safe %></div>
|
||||
<% end -%>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,45 +0,0 @@
|
||||
<%#
|
||||
# Form Partial
|
||||
|
||||
This partial is rendered on a resource's `new` and `edit` pages,
|
||||
and renders all form fields for a resource's editable attributes.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<%= form_for([namespace, page.resource], html: { class: "form" }) do |f| %>
|
||||
<% if page.resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2 style="text-align: center;">
|
||||
<%= t(
|
||||
"administrate.form.errors",
|
||||
pluralized_errors: pluralize(page.resource.errors.count, t("administrate.form.error")),
|
||||
resource_name: display_resource_name(page.resource_name)
|
||||
) %>
|
||||
</h2>
|
||||
|
||||
<ul>
|
||||
<% page.resource.errors.full_messages.each do |message| %>
|
||||
<li class="flash-error"><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% page.attributes.each do |attribute| -%>
|
||||
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
||||
<%= render_field attribute, f: f %>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,13 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
||||
<symbol id="icon-cancel" viewBox="0 0 48 48">
|
||||
<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" />
|
||||
</symbol>
|
||||
|
||||
<symbol id="icon-eyeglass" viewBox="0 0 48 48">
|
||||
<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" />
|
||||
</symbol>
|
||||
|
||||
<symbol id="icon-up-caret" viewBox="0 0 48 48">
|
||||
<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" />
|
||||
</symbol>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
@@ -1,21 +0,0 @@
|
||||
<%#
|
||||
# Javascript Partial
|
||||
|
||||
This partial imports the necessary javascript on each page.
|
||||
By default, it includes the application JS,
|
||||
but each page can define additional JS sources
|
||||
by providing a `content_for(:javascript)` block.
|
||||
%>
|
||||
|
||||
<% Administrate::Engine.javascripts.each do |js_path| %>
|
||||
<%= javascript_include_tag js_path %>
|
||||
<% end %>
|
||||
|
||||
<%= yield :javascript %>
|
||||
|
||||
<% if Rails.env.test? %>
|
||||
<%= javascript_tag do %>
|
||||
$.fx.off = true;
|
||||
$.ajaxSetup({ async: false });
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -1,26 +0,0 @@
|
||||
<%#
|
||||
# Navigation
|
||||
|
||||
This partial is used to display the navigation in Administrate.
|
||||
By default, the navigation contains navigation links
|
||||
for all resources in the admin dashboard,
|
||||
as defined by the routes in the `admin/` namespace
|
||||
%>
|
||||
|
||||
<nav class="navigation" role="navigation">
|
||||
<%= link_to(
|
||||
"⇦ Back to site",
|
||||
root_path,
|
||||
class: "navigation__link button",
|
||||
style: "color: #f6f7f7; background-color: #293f54; font-size: 15pt;",
|
||||
"data-turbolinks": "false"
|
||||
) %>
|
||||
|
||||
<% Administrate::Namespace.new(namespace).resources_with_index_route.each do |resource| %>
|
||||
<%= link_to(
|
||||
display_resource_name(resource),
|
||||
resource_index_route(resource),
|
||||
class: "navigation__link navigation__link--#{nav_link_state(resource)}"
|
||||
) if valid_action?(:index, resource) && show_action?(:index, model_from_resource(resource)) %>
|
||||
<% end %>
|
||||
</nav>
|
||||
@@ -1,14 +0,0 @@
|
||||
<%#
|
||||
# Stylesheet Partial
|
||||
|
||||
This partial imports the necessary stylesheets on each page.
|
||||
By default, it includes the application CSS,
|
||||
but each page can define additional CSS sources
|
||||
by providing a `content_for(:stylesheet)` block.
|
||||
%>
|
||||
|
||||
<% Administrate::Engine.stylesheets.each do |css_path| %>
|
||||
<%= stylesheet_link_tag css_path %>
|
||||
<% end %>
|
||||
|
||||
<%= yield :stylesheet %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<div class="field-unit__label">
|
||||
<%= f.label field.attribute %>
|
||||
</div>
|
||||
<div class="field-unit__field">
|
||||
<%= f.color_field field.attribute, style: 'height: 40px;' %>
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div
|
||||
style="background-color: <%= field.to_s %>; width: 32px; height: 32px; border-radius: 32px;">
|
||||
</div>
|
||||
@@ -1,4 +0,0 @@
|
||||
<div
|
||||
style="background-color: <%= field.to_s %>; width: 32px; height: 32px; border-radius: 32px;">
|
||||
</div>
|
||||
(<%= field.to_s %>)
|
||||
@@ -1,14 +0,0 @@
|
||||
<div class="field-unit__label">
|
||||
<%= f.label field.attribute %>
|
||||
</div>
|
||||
<div class="field-unit__field">
|
||||
<%= f.select field.attribute, field.select_field_values(f) %>
|
||||
</div>
|
||||
|
||||
<div
|
||||
title="Click to learn more"
|
||||
style="margin-left: 8px; cursor: pointer;"
|
||||
onclick="alert('If you add a user with role \'admin\', it will have same powers as you!')"
|
||||
>
|
||||
⚠️
|
||||
</div>
|
||||
@@ -1 +0,0 @@
|
||||
<%= field.to_s.titleize %>
|
||||
@@ -1 +0,0 @@
|
||||
<%= field.to_s.titleize %>
|
||||
@@ -35,13 +35,15 @@
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<% if current_user.power_user? %>
|
||||
<%= link_to t('header.menu.site_settings'), site_settings_boards_path, class: 'dropdown-item' %>
|
||||
<%= link_to t('header.menu.admin_panel'), admin_root_path, class: 'dropdown-item', 'data-turbolinks': 'false' %>
|
||||
<%=
|
||||
link_to t('header.menu.site_settings'),
|
||||
current_user.admin? ? site_settings_boards_path : site_settings_users_path,
|
||||
class: 'dropdown-item'
|
||||
%>
|
||||
<div class="dropdown-divider"></div>
|
||||
<% end %>
|
||||
|
||||
<%= link_to t('header.menu.profile_settings'), edit_user_registration_path, class: 'dropdown-item' %>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<%= link_to t('header.menu.sign_out'), destroy_user_session_path, method: :delete, class: 'dropdown-item' %>
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<%#
|
||||
# Application Layout
|
||||
|
||||
This view template is used as the layout
|
||||
for every page that Administrate generates.
|
||||
|
||||
By default, it renders:
|
||||
- Navigation
|
||||
- Content for a search bar
|
||||
(if provided by a `content_for` block in a nested page)
|
||||
- Flashes
|
||||
- Links to stylesheets and JavaScripts
|
||||
%>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%= I18n.locale %>">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="ROBOTS" content="NOODP">
|
||||
<meta name="viewport" content="initial-scale=1">
|
||||
<title>
|
||||
<%= content_for(:title) %> - Admin Panel - <%= Rails.application.name %>
|
||||
</title>
|
||||
<%= render "stylesheet" %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
<%= render "icons" %>
|
||||
|
||||
<div class="app-container">
|
||||
<%= render "navigation" -%>
|
||||
|
||||
<main class="main-content" role="main">
|
||||
<%= render "flashes" -%>
|
||||
<%= yield %>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<%= render "javascript" %>
|
||||
</body>
|
||||
</html>
|
||||
@@ -3,9 +3,13 @@
|
||||
<span class="boxTitleText"><%= t('site_settings.menu.title') %></span>
|
||||
|
||||
<div class="verticalNavigation" role="tablist" aria-orientation="vertical">
|
||||
<%= render 'menu_link', label: t('site_settings.menu.boards'), path: site_settings_boards_path %>
|
||||
<%= render 'menu_link', label: t('site_settings.menu.post_statuses'), path: site_settings_post_statuses_path %>
|
||||
<%= render 'menu_link', label: t('site_settings.menu.roadmap'), path: site_settings_roadmap_path %>
|
||||
<% if current_user.admin? %>
|
||||
<%= render 'menu_link', label: t('site_settings.menu.boards'), path: site_settings_boards_path %>
|
||||
<%= render 'menu_link', label: t('site_settings.menu.post_statuses'), path: site_settings_post_statuses_path %>
|
||||
<%= render 'menu_link', label: t('site_settings.menu.roadmap'), path: site_settings_roadmap_path %>
|
||||
<% end %>
|
||||
|
||||
<%= render 'menu_link', label: t('site_settings.menu.users'), path: site_settings_users_path %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
15
app/views/site_settings/users.html.erb
Normal file
15
app/views/site_settings/users.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="twoColumnsContainer">
|
||||
<%= render 'menu' %>
|
||||
<div>
|
||||
<%=
|
||||
react_component(
|
||||
'SiteSettings/Users',
|
||||
{
|
||||
currentUserEmail: current_user.email,
|
||||
currentUserRole: current_user.role,
|
||||
authenticityToken: form_authenticity_token
|
||||
}
|
||||
)
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user