Skip to content

Commit 52acb71

Browse files
committed
https://github.com/bonfire-networks/bonfire-app/issues/1734
1 parent 13e8bb4 commit 52acb71

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

priv/templates/lib/bonfire/web/views/dashboard_live.ex

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ defmodule Bonfire.Web.Views.DashboardLive do
1616
is_guest? = is_nil(current_user)
1717

1818
sidebar_widgets = [
19-
2019
users: [
2120
secondary:
2221
Enum.filter(
@@ -26,8 +25,7 @@ defmodule Bonfire.Web.Views.DashboardLive do
2625
true,
2726
current_user: current_user
2827
) && {Bonfire.Tag.Web.WidgetTagsLive, []},
29-
{Bonfire.UI.Social.WidgetTrendingLinksLive, []},
30-
28+
{Bonfire.UI.Social.WidgetTrendingLinksLive, []},
3129
Settings.get([Bonfire.Web.Views.DashboardLive, :include, :admins], true,
3230
current_user: current_user
3331
) &&
@@ -43,6 +41,17 @@ defmodule Bonfire.Web.Views.DashboardLive do
4341
]
4442
]
4543

44+
# Main content widgets for dashboard (when no specific feed is selected)
45+
main_widgets =
46+
Enum.filter(
47+
[
48+
{Bonfire.UI.Social.WidgetTrendingLinksLive,
49+
[limit: 5, widget_title: l("Trending Links")]}
50+
# Future widgets can be added here
51+
],
52+
& &1
53+
)
54+
4655
default_feed =
4756
Settings.get([Bonfire.Web.Views.DashboardLive, :default_feed], :my,
4857
current_user: current_user
@@ -69,6 +78,7 @@ defmodule Bonfire.Web.Views.DashboardLive do
6978
no_header: is_guest?,
7079
page_title: page_title,
7180
sidebar_widgets: sidebar_widgets,
81+
main_widgets: main_widgets,
7282
loading: true,
7383
feed: nil,
7484
feed_id: nil,

priv/templates/lib/bonfire/web/views/dashboard_live.sface

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<section data-id="user_dashboard" class="">
22
<div class={
3-
"flex flex-col bg-base-100 gap-2",
3+
"flex flex-col bg-base-100 gap-2 p-3",
44
"border border-base-content/10": !current_user_id(@__context__)
55
}>
66
{!-- <div
@@ -41,13 +41,41 @@
4141
hide_filters
4242
/>
4343
{#match _}
44-
<div class="border border-primary/30 border-dashed rounded-xl p-4 flex flex-col gap-4 m-4 text-center text-base-content/80 flex items-center place-content-center flex-col">
45-
<div>{l "You can customise your dashboard by adding widgets here."}</div>
46-
<LinkLive class="link link-primary flex items-center gap-2" to={~p"/settings/user/dashboard"}>
47-
<#Icon iconify="ph:gear-fill" class="w-5 h-5" />
48-
{l "Configure"}</LinkLive>
49-
</div>
50-
<!-- <StatelessComponent module={maybe_component(Bonfire.UI.Social.WidgetDiscussionsLive, @__context__)} /> -->
44+
{#case @main_widgets
45+
|> Enum.map(fn
46+
{component, component_assigns} ->
47+
%{
48+
module: component,
49+
data: component_assigns,
50+
type: Surface.Component
51+
}
52+
53+
%{} = widget ->
54+
widget
55+
56+
_ ->
57+
nil
58+
end)
59+
|> Enum.reject(&is_nil/1)}
60+
{#match widgets when is_list(widgets) and widgets != []}
61+
<Bonfire.UI.Common.WidgetsLive
62+
widgets={widgets}
63+
page={@page}
64+
selected_tab={@selected_tab}
65+
showing_within={:main}
66+
container_class="flex flex-col gap-4"
67+
id="dashboard_main_widgets"
68+
with_title
69+
/>
70+
{#match _}
71+
<div class="border border-primary/30 border-dashed rounded-xl p-4 flex flex-col gap-4 m-4 text-center text-base-content/80 flex items-center place-content-center flex-col">
72+
<div>{l "You can customise your dashboard by adding widgets here."}</div>
73+
<LinkLive class="link link-primary flex items-center gap-2" to={~p"/settings/user/dashboard"}>
74+
<#Icon iconify="ph:gear-fill" class="w-5 h-5" />
75+
{l "Configure"}
76+
</LinkLive>
77+
</div>
78+
{/case}
5179
{/case}
5280
</div>
5381
</section>

0 commit comments

Comments
 (0)