Compare commits

...

2 Commits

Author SHA1 Message Date
8747ce4eb0
Remove multi-domain support on admin user pages
All checks were successful
continuous-integration/drone/push Build is passing
refs #166
2024-02-10 08:55:15 +01:00
fcda3b9c8c
WIP Make dropdowns more configurable, add invitations menu to admin page 2024-02-09 18:57:07 +01:00
6 changed files with 47 additions and 27 deletions

View File

@ -2,13 +2,21 @@
<div class="relative inline-block">
<div role="button" tabindex="0" data-dropdown-target="button"
class="inline-block select-none">
<% if @size == :large %>
<span class="appearance-none flex items-center inline-block">
<span class="p-2 bg-gray-50 hover:bg-gray-100 rounded-full">
<%= render partial: "icons/kebab-menu", locals: {
custom_class: "inline text-gray-500 h-6 w-6"
} %>
<%= render partial: "icons/#{@icon_name}",
locals: { custom_class: "inline text-gray-500 h-6 w-6" } %>
</span>
</span>
<% elsif @size == :small %>
<span class="appearance-none flex items-center inline-block">
<span class="text-gray-500 hover:text-blue-600">
<%= render partial: "icons/#{@icon_name}",
locals: { custom_class: "inline h-4 w-4" } %>
</span>
</span>
<% end %>
</div>
<div data-dropdown-target="menu"
data-transition-enter="transition ease-out duration-200"

View File

@ -1,5 +1,8 @@
# frozen_string_literal: true
class DropdownComponent < ViewComponent::Base
def initialize(size: :large, icon_name: "kebap-menu")
@size = size.to_sym
@icon_name = icon_name
end
end

View File

@ -4,8 +4,7 @@ class Admin::UsersController < Admin::BaseController
def index
ldap = LdapService.new
@ou = params[:ou] || Setting.primary_domain
@orgs = ldap.fetch_organizations
@ou = Setting.primary_domain
@pagy, @users = pagy(User.where(ou: @ou).order(cn: :asc))
@stats = {
@ -27,8 +26,8 @@ class Admin::UsersController < Admin::BaseController
private
def set_user
address = params[:address].split("@")
@user = User.where(cn: address.first, ou: address.last).first
@user = User.find_by(cn: params[:username], ou: Setting.primary_domain)
http_status :not_found unless @user
end
def set_current_section

View File

@ -1,4 +1,4 @@
<%= render HeaderComponent.new(title: "Users: #{@ou}") %>
<%= render HeaderComponent.new(title: "Users") %>
<%= render MainSimpleComponent.new do %>
<section>
@ -16,19 +16,6 @@
<% end %>
</section>
<% if @orgs.length > 1 %>
<section>
<h3 class="hidden">Domains</h3>
<ul>
<% @orgs.each do |org| %>
<li class="inline-block">
<%= link_to org[:ou], admin_users_path(ou: org[:ou]), class: "ks-text-link" %>
</li>
<% end %>
</ul>
</section>
<% end %>
<section>
<table class="divided mb-8">
<thead>
@ -36,13 +23,12 @@
<th>UID</th>
<th>Status</th>
<th>Roles</th>
<!-- <th>Password</th> -->
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= link_to(user.cn, admin_user_path(user.address), class: 'ks-text-link') %></td>
<td><%= link_to(user.cn, admin_user_path(user.cn), class: 'ks-text-link') %></td>
<td><%= user.confirmed_at.nil? ? badge("pending", :yellow) : "" %></td>
<td><%= user.is_admin? ? badge("admin", :red) : "" %></td>
</tr>

View File

@ -1,4 +1,4 @@
<%= render HeaderComponent.new(title: "User: #{@user.address}") %>
<%= render HeaderComponent.new(title: "User: #{@user.cn}") %>
<%= render MainSimpleComponent.new do %>
<div class="mb-12 sm:flex sm:flex-row sm:gap-x-8">
@ -43,7 +43,26 @@
<tr>
<th>Invitations available</th>
<td>
<%= @user.invitations.count %>
<div class="flex justify-between">
<span>
<%= @user.invitations.count %>
</span>
<span>
<%= render DropdownComponent.new(size: :small, icon_name: "edit") do %>
<%= render DropdownLinkComponent.new(
href: ""
) do %>
Add more
<% end %>
<%= render DropdownLinkComponent.new(
href: "",
separator: true, add_class: "text-red-700"
) do %>
Remove all
<% end %>
<% end %>
</span>
</div>
</td>
</tr>
<tr>

View File

@ -73,9 +73,14 @@ Rails.application.routes.draw do
namespace :admin do
root to: 'dashboard#index'
resources 'users', param: 'address', only: ['index', 'show'], constraints: { address: /.*/ }
resources 'users', param: 'username', only: ['index', 'show'] do
end
get 'invitations', to: 'invitations#index'
resources :donations
get 'lightning', to: 'lightning#index'
namespace :app_catalog do