-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/bonfire-networks/bonfire-app/issues/1038
- Loading branch information
Showing
5 changed files
with
139 additions
and
8 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
lib/components/settings/instance/members/instances_live.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
defmodule Bonfire.UI.Me.SettingsViewsLive.InstancesLive do | ||
use Bonfire.UI.Common.Web, :stateful_component | ||
|
||
prop ghosted_instance_wide?, :boolean, default: nil | ||
prop silenced_instance_wide?, :boolean, default: nil | ||
|
||
def update(assigns, socket) do | ||
socket = assign(socket, assigns) | ||
|
||
{:ok, | ||
assign( | ||
socket, | ||
if(socket_connected?(socket), | ||
do: list_instances(), | ||
else: [instances: [], page_info: nil] | ||
) | ||
)} | ||
end | ||
|
||
def handle_event("load_more", attrs, socket) do | ||
%{page_info: page_info, instances: instances} = list_instances(attrs) | ||
|
||
{:noreply, | ||
socket | ||
|> assign( | ||
loaded: true, | ||
# instances: e(assigns(socket), :instances, []) ++ instances, | ||
instances: instances, | ||
page_info: page_info | ||
)} | ||
end | ||
|
||
def list_instances(attrs \\ nil) do | ||
%{edges: instances, page_info: page_info} = | ||
Bonfire.Federate.ActivityPub.Instances.list_paginated( | ||
skip_boundary_check: true, | ||
paginate: input_to_atoms(attrs) | ||
) | ||
|
||
# TODO: implement `Bonfire.Boundaries.Blocks.LiveHandler.update_many` so we don't do n+1 on these! | ||
instances = | ||
Enum.map(instances, fn user -> | ||
user | ||
|> Map.put( | ||
:ghosted_instance_wide?, | ||
Bonfire.Boundaries.Blocks.is_blocked?(id(user), :ghost, :instance_wide) | ||
) | ||
|> Map.put( | ||
:silenced_instance_wide?, | ||
Bonfire.Boundaries.Blocks.is_blocked?(id(user), :silence, :instance_wide) | ||
) | ||
end) | ||
|
||
%{ | ||
instances: instances, | ||
page_info: page_info | ||
} | ||
end | ||
end |
58 changes: 58 additions & 0 deletions
58
lib/components/settings/instance/members/instances_live.sface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<div> | ||
<div class="grid mb-2 px-4 md:px-0 md:grid-cols-2 gap-4 max-w-screen-md mx-auto w-full"> | ||
<div | ||
:for={%{id: id, ap_base_uri: ap_base_uri, display_hostname: display_hostname} = instance <- @instances} | ||
class="p-4 border rounded border-base-content/20 flex" | ||
> | ||
<!-- TODO: link to member directory in settings instead --> | ||
<div>{display_hostname}</div> | ||
|
||
<div class="dropdown dropdown-end"> | ||
<label | ||
class="relative btn btn-circle btn-outline border-base-content/30 btn-sm" | ||
tabindex="0" | ||
id="user-profile-menu" | ||
aria-haspopup="true" | ||
aria-expanded="true" | ||
> | ||
<#Icon iconify="material-symbols:more-horiz" class="w-5 h-5" /> | ||
</label> | ||
<ul | ||
tabindex="0" | ||
class="relative z-50 mt-3 p-0.5 menu shadow-xl bg-base-100 border rounded border-base-content/5 !block w-52 menu dropdown-content" | ||
role="menu" | ||
aria-orientation="vertical" | ||
aria-labelledby="user-profile-menu" | ||
> | ||
<li><LinkLive to={"/users/instance/#{display_hostname}/#{id}"} class="grow">{l("View known users from instance")}</LinkLive></li> | ||
<li><a href={ap_base_uri} target="_blank"><#Icon iconify="heroicons-solid:external-link" class="w-4 h-4" /> {l("Visit instance")}</a></li> | ||
<li> | ||
<StatelessComponent | ||
module={maybe_component(Bonfire.Boundaries.Web.BlockButtonLive, @__context__)} | ||
object={instance} | ||
parent_id="instances" | ||
type={:block} | ||
hide_icon | ||
is_local_user={false} | ||
open_btn_wrapper_class="w-full" | ||
label={display_hostname} | ||
open_btn_label={if @ghosted_instance_wide? && @silenced_instance_wide? do | ||
l("Unblock") | ||
else | ||
l("Block") | ||
end} | ||
class="text-error" | ||
/> | ||
</li></ul> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<Bonfire.UI.Common.LoadMoreLive | ||
:if={@page_info} | ||
live_handler={__MODULE__} | ||
target={@myself} | ||
page_info={@page_info} | ||
hide_guest_fallback | ||
/> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters