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>
</ul>
</div>
<% main_nets = main_nets() %>
<% main_nets = main_nets(other_networks()) %>
<%= unless Enum.empty?(main_nets) do %>
<div class="col-md-<%= col_size %> footer-list">
@ -50,7 +50,7 @@
</div>
<% end %>
<% test_nets = test_nets() %>
<% test_nets = test_nets(other_networks()) %>
<%= unless Enum.empty?(test_nets) do %>
<div class="col-md-<%= col_size %> footer-list">

@ -85,15 +85,15 @@
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<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>
<% end %>
<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>
<% end %>
<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>
<% end %>
</div>

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

Loading…
Cancel
Save