feat: add approval ui for join requests
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
50433e607f
commit
86d9242d83
22 changed files with 1624 additions and 12 deletions
|
|
@ -44,7 +44,16 @@ defmodule MvWeb.Layouts do
|
|||
|
||||
def app(assigns) do
|
||||
club_name = get_club_name()
|
||||
assigns = assign(assigns, :club_name, club_name)
|
||||
join_form_enabled = get_join_form_enabled()
|
||||
|
||||
unprocessed_join_requests_count =
|
||||
get_unprocessed_join_requests_count(assigns.current_user, join_form_enabled)
|
||||
|
||||
assigns =
|
||||
assigns
|
||||
|> assign(:club_name, club_name)
|
||||
|> assign(:join_form_enabled, join_form_enabled)
|
||||
|> assign(:unprocessed_join_requests_count, unprocessed_join_requests_count)
|
||||
|
||||
~H"""
|
||||
<%= if @current_user do %>
|
||||
|
|
@ -78,7 +87,13 @@ defmodule MvWeb.Layouts do
|
|||
</div>
|
||||
|
||||
<div class="drawer-side z-40">
|
||||
<.sidebar current_user={@current_user} club_name={@club_name} mobile={false} />
|
||||
<.sidebar
|
||||
current_user={@current_user}
|
||||
club_name={@club_name}
|
||||
join_form_enabled={@join_form_enabled}
|
||||
unprocessed_join_requests_count={@unprocessed_join_requests_count}
|
||||
mobile={false}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
|
|
@ -121,6 +136,20 @@ defmodule MvWeb.Layouts do
|
|||
end
|
||||
end
|
||||
|
||||
defp get_join_form_enabled do
|
||||
case Mv.Membership.get_settings() do
|
||||
{:ok, %{join_form_enabled: true}} -> true
|
||||
_ -> false
|
||||
end
|
||||
end
|
||||
|
||||
defp get_unprocessed_join_requests_count(nil, _), do: 0
|
||||
defp get_unprocessed_join_requests_count(_user, false), do: 0
|
||||
|
||||
defp get_unprocessed_join_requests_count(user, true) do
|
||||
Mv.Membership.count_submitted_join_requests(actor: user)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Shows the flash group with standard titles and content.
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,15 @@ defmodule MvWeb.Layouts.Sidebar do
|
|||
|
||||
attr :current_user, :map, default: nil, doc: "The current user"
|
||||
attr :club_name, :string, required: true, doc: "The name of the club"
|
||||
|
||||
attr :join_form_enabled, :boolean,
|
||||
default: false,
|
||||
doc: "Whether the public join form is enabled in settings"
|
||||
|
||||
attr :unprocessed_join_requests_count, :integer,
|
||||
default: 0,
|
||||
doc: "Count of submitted (unprocessed) join requests for sidebar indicator"
|
||||
|
||||
attr :mobile, :boolean, default: false, doc: "Whether this is mobile view"
|
||||
|
||||
def sidebar(assigns) do
|
||||
|
|
@ -96,6 +105,15 @@ defmodule MvWeb.Layouts.Sidebar do
|
|||
/>
|
||||
<% end %>
|
||||
|
||||
<%= if @join_form_enabled and can_access_page?(@current_user, PagePaths.join_requests()) do %>
|
||||
<.menu_item
|
||||
href={~p"/join_requests"}
|
||||
icon="hero-inbox-arrow-down"
|
||||
label={gettext("Join requests")}
|
||||
indicator_dot={@unprocessed_join_requests_count > 0}
|
||||
/>
|
||||
<% end %>
|
||||
|
||||
<%= if admin_menu_visible?(@current_user) do %>
|
||||
<.menu_group
|
||||
icon="hero-cog-6-tooth"
|
||||
|
|
@ -137,6 +155,10 @@ defmodule MvWeb.Layouts.Sidebar do
|
|||
attr :icon, :string, required: true, doc: "Heroicon name"
|
||||
attr :label, :string, required: true, doc: "Menu item label"
|
||||
|
||||
attr :indicator_dot, :boolean,
|
||||
default: false,
|
||||
doc: "Show a small dot on the icon (e.g. for unprocessed items)"
|
||||
|
||||
defp menu_item(assigns) do
|
||||
~H"""
|
||||
<li role="none">
|
||||
|
|
@ -146,7 +168,16 @@ defmodule MvWeb.Layouts.Sidebar do
|
|||
data-tip={@label}
|
||||
role="menuitem"
|
||||
>
|
||||
<.icon name={@icon} class="size-5 shrink-0" aria-hidden="true" />
|
||||
<span class="relative shrink-0">
|
||||
<.icon name={@icon} class="size-5 shrink-0" aria-hidden="true" />
|
||||
<%= if @indicator_dot do %>
|
||||
<span
|
||||
class="absolute -top-0.5 -right-0.5 size-2 rounded-full bg-primary"
|
||||
aria-hidden="true"
|
||||
>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
<span class="menu-label">{@label}</span>
|
||||
</.link>
|
||||
</li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue