chore: added more @spec

This commit is contained in:
2026-05-01 17:49:50 +02:00
parent abcae1dad7
commit 881056eb61
157 changed files with 6223 additions and 1647 deletions

View File

@@ -75,11 +75,15 @@ defmodule BDS.UI.Dashboard do
end
defp post_stats(posts) do
Enum.reduce(posts, %{total_posts: 0, draft_count: 0, published_count: 0, archived_count: 0}, fn post, acc ->
acc
|> Map.update!(:total_posts, &(&1 + 1))
|> increment_status(post.status)
end)
Enum.reduce(
posts,
%{total_posts: 0, draft_count: 0, published_count: 0, archived_count: 0},
fn post, acc ->
acc
|> Map.update!(:total_posts, &(&1 + 1))
|> increment_status(post.status)
end
)
end
defp media_stats(media_items) do
@@ -116,7 +120,9 @@ defmodule BDS.UI.Dashboard do
|> Enum.flat_map(&normalize_terms(&1.categories))
|> Enum.frequencies()
|> Enum.map(fn {category, count} -> %{category: category, count: count} end)
|> Enum.sort_by(fn %{category: category, count: count} -> {-count, String.downcase(category)} end)
|> Enum.sort_by(fn %{category: category, count: count} ->
{-count, String.downcase(category)}
end)
end
defp recent_posts(posts) do
@@ -151,7 +157,9 @@ defmodule BDS.UI.Dashboard do
defp increment_status(counts, _status), do: counts
defp maybe_increment_image_count(counts, mime_type) when is_binary(mime_type) do
if String.starts_with?(mime_type, "image/"), do: Map.update!(counts, :image_count, &(&1 + 1)), else: counts
if String.starts_with?(mime_type, "image/"),
do: Map.update!(counts, :image_count, &(&1 + 1)),
else: counts
end
defp maybe_increment_image_count(counts, _mime_type), do: counts

View File

@@ -2,16 +2,86 @@ defmodule BDS.UI.Registry do
@moduledoc false
@sidebar_views [
%{id: :posts, label: "Posts", activity_group: :top, editor_route: :post, entity_tab: true, demo_kind: :entity},
%{id: :pages, label: "Pages", activity_group: :top, editor_route: :post, entity_tab: true, demo_kind: :entity},
%{id: :media, label: "Media", activity_group: :top, editor_route: :media, entity_tab: true, demo_kind: :entity},
%{id: :scripts, label: "Scripts", activity_group: :top, editor_route: :scripts, entity_tab: true, demo_kind: :entity},
%{id: :templates, label: "Templates", activity_group: :top, editor_route: :templates, entity_tab: true, demo_kind: :entity},
%{id: :tags, label: "Tags", activity_group: :top, editor_route: :tags, singleton: true, demo_kind: :singleton},
%{id: :chat, label: "AI Assistant", activity_group: :top, editor_route: :chat, entity_tab: true, demo_kind: :entity},
%{id: :import, label: "Import", activity_group: :top, editor_route: :import, entity_tab: true, demo_kind: :entity},
%{id: :git, label: "Source Control", activity_group: :bottom, editor_route: :git_diff, entity_tab: true, demo_kind: :entity},
%{id: :settings, label: "Settings", activity_group: :bottom, editor_route: :settings, singleton: true, demo_kind: :singleton}
%{
id: :posts,
label: "Posts",
activity_group: :top,
editor_route: :post,
entity_tab: true,
demo_kind: :entity
},
%{
id: :pages,
label: "Pages",
activity_group: :top,
editor_route: :post,
entity_tab: true,
demo_kind: :entity
},
%{
id: :media,
label: "Media",
activity_group: :top,
editor_route: :media,
entity_tab: true,
demo_kind: :entity
},
%{
id: :scripts,
label: "Scripts",
activity_group: :top,
editor_route: :scripts,
entity_tab: true,
demo_kind: :entity
},
%{
id: :templates,
label: "Templates",
activity_group: :top,
editor_route: :templates,
entity_tab: true,
demo_kind: :entity
},
%{
id: :tags,
label: "Tags",
activity_group: :top,
editor_route: :tags,
singleton: true,
demo_kind: :singleton
},
%{
id: :chat,
label: "AI Assistant",
activity_group: :top,
editor_route: :chat,
entity_tab: true,
demo_kind: :entity
},
%{
id: :import,
label: "Import",
activity_group: :top,
editor_route: :import,
entity_tab: true,
demo_kind: :entity
},
%{
id: :git,
label: "Source Control",
activity_group: :bottom,
editor_route: :git_diff,
entity_tab: true,
demo_kind: :entity
},
%{
id: :settings,
label: "Settings",
activity_group: :bottom,
editor_route: :settings,
singleton: true,
demo_kind: :singleton
}
]
@editor_routes [
@@ -41,4 +111,4 @@ defmodule BDS.UI.Registry do
def sidebar_view(id) when is_atom(id), do: Enum.find(@sidebar_views, &(&1.id == id))
def editor_route(id) when is_atom(id), do: Enum.find(@editor_routes, &(&1.id == id))
end
end

View File

@@ -225,6 +225,7 @@ defmodule BDS.UI.Workbench do
end
defp transient_tab?(type, _intent) when type in [:chat, :import], do: false
defp transient_tab?(type, intent) do
if MapSet.member?(@singleton_tabs, type), do: false, else: transient_from_intent(intent)
end