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. 49
      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
if Application.get_env(:block_scout_web, :other_networks) do get_other_networks =
:block_scout_web if Application.get_env(:block_scout_web, :other_networks) do
|> Application.get_env(:other_networks) :block_scout_web
|> Poison.decode!() |> Application.get_env(:other_networks)
|> Kernel.||(@default_other_networks) |> Poison.Parser.parse!(%{keys: :atoms!})
|> Enum.map(fn chain -> else
for {key, val} <- chain, into: %{}, do: {String.to_atom(key), val} @default_other_networks
end) end
else
@default_other_networks get_other_networks
end
|> 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
def dropdown_nets do
other_networks()
|> Enum.reject(&Map.get(&1, :hide_in_dropdown?))
end end
def test_nets do def dropdown_head_main_nets do
Enum.filter(other_networks(), &Map.get(&1, :test_net?)) 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