Skip to content

Commit 728c29a

Browse files
feat: show staging networks if we are on a staging network only (#1668)
Co-authored-by: Urix <[email protected]>
1 parent f74eb3a commit 728c29a

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

explorer/lib/explorer_web/components/nav.ex

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,33 @@ defmodule NavComponent do
44
def get_current_network(host) do
55
case host do
66
"explorer.alignedlayer.com" -> "Mainnet"
7-
"holesky.explorer.alignedlayer.com" -> "Testnet"
7+
"holesky.explorer.alignedlayer.com" -> "Holesky"
88
"stage.explorer.alignedlayer.com" -> "Stage"
99
_ -> "Devnet"
1010
end
1111
end
1212

13-
@impl true
14-
def mount(socket) do
15-
networks = ExplorerWeb.Helpers.get_aligned_networks()
16-
13+
def get_networks(current_network) do
1714
networks =
18-
Enum.map(networks, fn {name, link} ->
15+
Helpers.get_aligned_networks()
16+
|> Enum.filter(fn {name, _link} ->
17+
case current_network do
18+
# Filter dev networks if we are in mainnet or holesky
19+
"Mainnet" -> name in ["Mainnet", "Holesky"]
20+
"Holesky" -> name in ["Mainnet", "Holesky"]
21+
_ -> true
22+
end
23+
end)
24+
|> Enum.map(fn {name, link} ->
1925
{name, "window.location.href='#{link}'"}
2026
end)
27+
end
2128

29+
@impl true
30+
def mount(socket) do
2231
{:ok,
2332
assign(socket,
24-
latest_release: ReleasesHelper.get_latest_release(),
25-
networks: networks
33+
latest_release: ReleasesHelper.get_latest_release()
2634
)}
2735
end
2836

@@ -71,11 +79,11 @@ defmodule NavComponent do
7179
</.link>
7280
<.link
7381
class={
74-
active_view_class(assigns.socket.view, [
75-
ExplorerWeb.Restakes.Index,
76-
ExplorerWeb.Restake.Index
77-
])
78-
}
82+
active_view_class(assigns.socket.view, [
83+
ExplorerWeb.Restakes.Index,
84+
ExplorerWeb.Restake.Index
85+
])
86+
}
7987
navigate={~p"/restakes"}
8088
>
8189
Restakes
@@ -100,7 +108,7 @@ defmodule NavComponent do
100108
<.hover_dropdown_selector
101109
current_value={get_current_network(@host)}
102110
variant="accent"
103-
options={@networks}
111+
options={get_networks(get_current_network(@host))}
104112
icon="hero-cube-transparent-micro"
105113
/>
106114
<button

explorer/lib/explorer_web/live/utils.ex

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,15 @@ defmodule ExplorerWeb.Helpers do
108108
end
109109
end
110110

111-
@doc """
112-
Returns the current network based on the configured environment.
113-
"""
114-
def get_current_network() do
115-
prefix = System.get_env("ENVIRONMENT")
116-
String.capitalize(prefix)
117-
end
118-
119111
@doc """
120112
Returns a list of available AlignedLayer networks with their names and explorer URLs.
121113
"""
122114
def get_aligned_networks() do
123115
[
124116
{"Mainnet", "https://explorer.alignedlayer.com"},
125117
{"Holesky", "https://holesky.explorer.alignedlayer.com"},
126-
{"Stage", "https://stage.explorer.alignedlayer.com"}
118+
{"Stage", "https://stage.explorer.alignedlayer.com"},
119+
{"Devnet", "http://localhost:4000/"}
127120
]
128121
end
129122

0 commit comments

Comments
 (0)