neiam /gitgud
Git Gud
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Packages
⭐
Log in to mark this repository.
Move Explore to the right of Orgs
bff9e3f · Gabriel Morell · 2026-09-09 21:37
Message
{commit_body(@commit)}
Files changed
modified
lib/git_gud_web/components/layouts.ex
+13
−7
@@ -49,6 +49,15 @@ defmodule GitGudWeb.Layouts do
| 49 | 49 | </.link> |
| 50 | 50 | </li> |
| 51 | 51 | |
| 52 | + <%!-- Orgs is signed-in only, but Explore is public, so it sits | |
| 53 | + on its own rather than inside the block below. --%> | |
| 54 | + <li :if={signed_in?(@current_scope)}> | |
| 55 | + <.link navigate={~p"/orgs"} class="btn btn-ghost btn-sm" id="nav-orgs"> | |
| 56 | + <.icon name="hero-building-office-2-micro" class="size-4" /> | |
| 57 | + <span class="hidden sm:inline">Orgs</span> | |
| 58 | + </.link> | |
| 59 | + </li> | |
| 60 | + | |
| 52 | 61 | <%!-- Facets: instance-wide ways to browse. Public, like the |
| 53 | 62 | pages behind it. Hidden entirely when nothing is on. --%> |
| 54 | 63 | <li :if={facets() != []}> |
@@ -78,13 +87,7 @@ defmodule GitGudWeb.Layouts do
| 78 | 87 | </div> |
| 79 | 88 | </li> |
| 80 | 89 | |
| 81 | − <%= if @current_scope && @current_scope.user do %> | |
| 82 | − <li> | |
| 83 | − <.link navigate={~p"/orgs"} class="btn btn-ghost btn-sm" id="nav-orgs"> | |
| 84 | − <.icon name="hero-building-office-2-micro" class="size-4" /> | |
| 85 | − <span class="hidden sm:inline">Orgs</span> | |
| 86 | − </.link> | |
| 87 | − </li> | |
| 90 | + <%= if signed_in?(@current_scope) do %> | |
| 88 | 91 | <li :if={admin?(@current_scope)}> |
| 89 | 92 | <.link |
| 90 | 93 | navigate={~p"/admin/federation"} |
@@ -233,6 +236,9 @@ defmodule GitGudWeb.Layouts do
| 233 | 236 | else: [] |
| 234 | 237 | end |
| 235 | 238 | |
| 239 | + defp signed_in?(%{user: %{}}), do: true | |
| 240 | + defp signed_in?(_), do: false | |
| 241 | + | |
| 236 | 242 | defp admin?(%{user: %{is_admin: true}}), do: true |
| 237 | 243 | defp admin?(_), do: false |
| 238 | 244 |
modified
test/git_gud_web/live/syms_live/top_test.exs
+14
−0
@@ -108,6 +108,20 @@ defmodule GitGudWeb.SymsLive.TopTest do
| 108 | 108 | assert lv |> element(~s{#nav-explore ~ ul a[href="/syms"]}) |> has_element?() |
| 109 | 109 | end |
| 110 | 110 | |
| 111 | + test "sits to the right of Orgs when signed in", %{} do | |
| 112 | + conn = log_in_user(build_conn(), user_fixture()) | |
| 113 | + {:ok, _lv, html} = live(conn, ~p"/repositories") | |
| 114 | + | |
| 115 | + assert :binary.match(html, "nav-orgs") < :binary.match(html, "nav-explore") | |
| 116 | + end | |
| 117 | + | |
| 118 | + test "still shows for anonymous visitors, who have no Orgs" do | |
| 119 | + {:ok, lv, html} = live(build_conn(), ~p"/repositories") | |
| 120 | + | |
| 121 | + refute html =~ "nav-orgs" | |
| 122 | + assert lv |> element("#nav-explore") |> has_element?() | |
| 123 | + end | |
| 124 | + | |
| 111 | 125 | test "hides entirely when no facet is enabled" do |
| 112 | 126 | Application.put_env(:git_gud, :syms, []) |
| 113 | 127 |
Parents: 1550621