diff --git a/apps/block_scout_web/config/config.exs b/apps/block_scout_web/config/config.exs index 60cc509a83..2379cc02c9 100644 --- a/apps/block_scout_web/config/config.exs +++ b/apps/block_scout_web/config/config.exs @@ -9,7 +9,8 @@ use Mix.Config config :block_scout_web, namespace: BlockScoutWeb, ecto_repos: [Explorer.Repo], - version: System.get_env("BLOCKSCOUT_VERSION") + version: System.get_env("BLOCKSCOUT_VERSION"), + release_link: System.get_env("RELEASE_LINK") config :block_scout_web, BlockScoutWeb.Chain, network: System.get_env("NETWORK"), diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex index 1e68fda54e..4a15dc8f1e 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex @@ -90,8 +90,9 @@ <% version = version() %> <%= unless ignore_version?(version) do %> + <% release_link = release_link(version) %>
- <%= gettext("Version") %>: <%= version %> + <%= gettext("Version") %>: <%= release_link %>
<% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex index b93be0ba51..94b2e4fd55 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex @@ -76,6 +76,16 @@ defmodule BlockScoutWeb.LayoutView do BlockScoutWeb.version() end + def release_link(version) do + release_link = Application.get_env(:block_scout_web, :release_link) + + if release_link == "" || release_link == nil do + version + else + html_escape({:safe, "#{version}"}) + end + end + def ignore_version?("unknown"), do: true def ignore_version?(_), do: false diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index d790de78d0..25284e5f7b 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -1557,7 +1557,7 @@ msgid "Test Networks" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_footer.html.eex:94 +#: lib/block_scout_web/templates/layout/_footer.html.eex:95 msgid "Version" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 93fc660959..33cbe21b8a 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -1557,7 +1557,7 @@ msgid "Test Networks" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_footer.html.eex:94 +#: lib/block_scout_web/templates/layout/_footer.html.eex:95 msgid "Version" msgstr "" @@ -1682,7 +1682,7 @@ msgstr "" msgid "Run" msgstr "" -#, elixir-format, fuzzy +#, elixir-format #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:31 msgid "EVM Vesion" msgstr "" diff --git a/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs index 21580945a6..96925b2b62 100644 --- a/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs +++ b/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs @@ -60,4 +60,30 @@ defmodule BlockScoutWeb.LayoutViewTest do assert LayoutView.network_title() == "POA" end end + + describe "release_link/1" do + test "use the version when there is no release_link env configured for it" do + Application.put_env(:block_scout_web, :release_link, nil) + + assert LayoutView.release_link("1.3.4") == "1.3.4" + end + + test "use the version when empty release_link env configured for it" do + Application.put_env(:block_scout_web, :release_link, "") + + assert LayoutView.release_link("1.3.4") == "1.3.4" + end + + test "use the enviroment release link when it's configured" do + Application.put_env( + :block_scout_web, + :release_link, + "https://github.com/poanetwork/blockscout/releases/tag/v1.3.4-beta" + ) + + assert LayoutView.release_link("1.3.4") == + {:safe, + ~s(1.3.4)} + end + end end