fix: more alignments still

This commit is contained in:
2026-04-26 09:40:33 +02:00
parent b377951054
commit 50d8e88ce8
8 changed files with 144 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
defmodule BDS.Desktop.ShellData do
@moduledoc false
alias BDS.Git
alias BDS.I18n
alias BDS.Projects
alias BDS.UI.Dashboard
@@ -100,6 +101,30 @@ defmodule BDS.Desktop.ShellData do
)
end
def git_badge_count(project_id, opts \\ [])
def git_badge_count(nil, _opts), do: 0
def git_badge_count("default", _opts), do: 0
def git_badge_count(project_id, opts) when is_binary(project_id) do
provider = Keyword.get(opts, :provider, git_remote_state_provider())
try do
case provider.(project_id, []) do
{:ok, %{behind: behind}} when is_integer(behind) and behind > 0 -> behind
{:ok, %{behind: behind}} when is_binary(behind) -> parse_positive_count(behind)
_other -> 0
end
rescue
error in [DBConnection.OwnershipError, Exqlite.Error] ->
if match?(%Exqlite.Error{}, error) and not String.contains?(Exception.message(error), "no such table") do
reraise error, __STACKTRACE__
end
0
end
end
def panel_tabs(workbench) do
[:tasks, :output]
|> maybe_add_panel_tab(workbench.editor_route, :post_links)
@@ -108,6 +133,17 @@ defmodule BDS.Desktop.ShellData do
|> Enum.uniq()
end
defp git_remote_state_provider do
Application.get_env(:bds, :git_remote_state_provider, &Git.remote_state/2)
end
defp parse_positive_count(value) do
case Integer.parse(value) do
{count, _rest} when count > 0 -> count
_other -> 0
end
end
def activity_icon(id) do
case to_string(id) do
"posts" -> ~s(<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zM6 20V4h7v5h5v11H6z"></path><path d="M8 12h8v2H8zm0 4h8v2H8z"></path></svg>)

View File

@@ -394,11 +394,12 @@ defmodule BDS.Desktop.ShellLive do
defp reload_shell(socket, workbench) do
projects = ShellData.project_snapshot()
dashboard = ShellData.dashboard(projects.active_project_id)
git_badge_count = ShellData.git_badge_count(projects.active_project_id)
active_view_id = Atom.to_string(workbench.active_view)
sidebar_data = ShellData.sidebar_view(projects.active_project_id, active_view_id, current_sidebar_filters(socket, active_view_id))
sidebar_data = merge_sidebar_ui_state(socket, active_view_id, sidebar_data)
task_status = BDS.Tasks.status_snapshot()
activity_buttons = Workbench.activity_buttons(workbench, 0)
activity_buttons = Workbench.activity_buttons(workbench, git_badge_count)
page_language = socket.assigns[:page_language] || ShellData.ui_language()
offline_mode = Map.get(socket.assigns, :offline_mode, true)

View File

@@ -112,6 +112,9 @@
aria-label={activity_label(button.label)}
>
<%= raw(ShellData.activity_icon(button.id)) %>
<%= if button.badge do %>
<span class="activity-bar-badge"><%= button.badge.display %></span>
<% end %>
</button>
<% end %>
</div>
@@ -129,6 +132,9 @@
aria-label={activity_label(button.label)}
>
<%= raw(ShellData.activity_icon(button.id)) %>
<%= if button.badge do %>
<span class="activity-bar-badge"><%= button.badge.display %></span>
<% end %>
</button>
<% end %>
</div>