hide_in_dropdown flag for networks

pull/1900/head
Victor Baranov 6 years ago
parent fdcd6b31dd
commit 2164c286e2
  1. 4
      apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex
  2. 6
      apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex
  3. 37
      apps/block_scout_web/lib/block_scout_web/views/layout_view.ex

@ -37,7 +37,7 @@
<li><a href="https://forum.poa.network/c/blockscout" rel="noreferrer" class="footer-link"><%= gettext("Support") %></a></li> <li><a href="https://forum.poa.network/c/blockscout" rel="noreferrer" class="footer-link"><%= gettext("Support") %></a></li>
</ul> </ul>
</div> </div>
<% main_nets = main_nets() %> <% main_nets = main_nets(other_networks()) %>
<%= unless Enum.empty?(main_nets) do %> <%= unless Enum.empty?(main_nets) do %>
<div class="col-md-<%= col_size %> footer-list"> <div class="col-md-<%= col_size %> footer-list">
@ -50,7 +50,7 @@
</div> </div>
<% end %> <% end %>
<% test_nets = test_nets() %> <% test_nets = test_nets(other_networks()) %>
<%= unless Enum.empty?(test_nets) do %> <%= unless Enum.empty?(test_nets) do %>
<div class="col-md-<%= col_size %> footer-list"> <div class="col-md-<%= col_size %> footer-list">

@ -85,15 +85,15 @@
</a> </a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown"> <div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item header division">Mainnets</a> <a class="dropdown-item header division">Mainnets</a>
<%= for %{url: url, title: title} <- head_main_nets() do %> <%= for %{url: url, title: title} <- dropdown_head_main_nets() do %>
<a class="dropdown-item" href="<%= url%>"><%= title %></a> <a class="dropdown-item" href="<%= url%>"><%= title %></a>
<% end %> <% end %>
<a class="dropdown-item header division">Testnets</a> <a class="dropdown-item header division">Testnets</a>
<%= for %{url: url, title: title} <- test_nets() do %> <%= for %{url: url, title: title} <- test_nets(dropdown_nets()) do %>
<a class="dropdown-item" href="<%= url%>"><%= title %></a> <a class="dropdown-item" href="<%= url%>"><%= title %></a>
<% end %> <% end %>
<a class="dropdown-item header division">Other networks</a> <a class="dropdown-item header division">Other networks</a>
<%= for %{url: url, title: title} <- other_nets() do %> <%= for %{url: url, title: title} <- dropdown_other_nets() do %>
<a class="dropdown-item" href="<%= url%>"><%= title %></a> <a class="dropdown-item" href="<%= url%>"><%= title %></a>
<% end %> <% end %>
</div> </div>

@ -154,38 +154,47 @@ defmodule BlockScoutWeb.LayoutView do
def ignore_version?(_), do: false def ignore_version?(_), do: false
def other_networks do def other_networks do
get_other_networks =
if Application.get_env(:block_scout_web, :other_networks) do if Application.get_env(:block_scout_web, :other_networks) do
:block_scout_web :block_scout_web
|> Application.get_env(:other_networks) |> Application.get_env(:other_networks)
|> Poison.decode!() |> Poison.Parser.parse!(%{keys: :atoms!})
|> Kernel.||(@default_other_networks)
|> Enum.map(fn chain ->
for {key, val} <- chain, into: %{}, do: {String.to_atom(key), val}
end)
else else
@default_other_networks @default_other_networks
end end
get_other_networks
|> Enum.reject(fn %{title: title} -> |> Enum.reject(fn %{title: title} ->
title == subnetwork_title() title == subnetwork_title()
end) end)
|> Enum.sort() |> Enum.sort()
end end
def main_nets do def main_nets(nets) do
Enum.reject(other_networks(), &Map.get(&1, :test_net?)) nets
|> Enum.reject(&Map.get(&1, :test_net?))
end end
def head_main_nets do def test_nets(nets) do
main_nets() nets
|> Enum.reject(&Map.get(&1, :other?)) |> Enum.filter(&Map.get(&1, :test_net?))
end end
def test_nets do def dropdown_nets do
Enum.filter(other_networks(), &Map.get(&1, :test_net?)) other_networks()
|> Enum.reject(&Map.get(&1, :hide_in_dropdown?))
end
def dropdown_head_main_nets do
dropdown_nets()
|> main_nets()
|> Enum.reject(&Map.get(&1, :other?))
end end
def other_nets do def dropdown_other_nets do
Enum.filter(other_networks(), &Map.get(&1, :other?)) dropdown_nets()
|> main_nets()
|> Enum.filter(&Map.get(&1, :other?))
end end
def other_explorers do def other_explorers do

Loading…
Cancel
Save