From c305290e81e1ebb38973c27d4cb0f9ab5325a2aa Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 3 Sep 2020 10:59:54 +0300 Subject: [PATCH] NFT instance: external link to the NFT in the app --- CHANGELOG.md | 1 + .../tokens/instance/overview/_details.html.eex | 7 +++++++ .../views/tokens/instance/overview_view.ex | 13 +++++++++++++ apps/block_scout_web/priv/gettext/default.pot | 14 +++++++------- .../priv/gettext/en/LC_MESSAGES/default.po | 14 +++++++------- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4648f5300c..1e9e3d0d28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#3279](https://github.com/poanetwork/blockscout/pull/3279) - NFT instance: link to the app - [#3273](https://github.com/poanetwork/blockscout/pull/3273) - Update token metadata at burn/mint events - [#3268](https://github.com/poanetwork/blockscout/pull/3268) - Token total supply on-demand fetcher - [#3261](https://github.com/poanetwork/blockscout/pull/3261) - Bridged tokens table diff --git a/apps/block_scout_web/lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex index 9785453dd6..a708ec3e3b 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex @@ -63,6 +63,13 @@
+ <%= if external_url(@token_instance.instance) do %> + + target="_blank"> + View In App <%= render BlockScoutWeb.IconsView, "_external_link.html" %> + + + <% end %> <%= @token.type %> <%= @total_token_transfers %> <%= gettext "Transfers" %> <%= if decimals?(@token) do %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex b/apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex index bf141a5bd2..c7581058ee 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex @@ -38,6 +38,19 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do if String.trim(result) == "", do: image_src(nil), else: result end + def external_url(nil), do: nil + + def external_url(instance) do + result = + if instance.metadata && instance.metadata["external_url"] do + instance.metadata["external_url"] + else + external_url(nil) + end + + if String.trim(result) == "", do: external_url(nil), else: result + end + def total_supply_usd(token) do tokens = CurrencyHelpers.divide_decimals(token.total_supply, token.decimals) price = token.usd_value diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 1c67b68654..9db39cb7f1 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -901,7 +901,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7 #: lib/block_scout_web/views/address_view.ex:346 -#: lib/block_scout_web/views/tokens/instance/overview_view.ex:98 +#: lib/block_scout_web/views/tokens/instance/overview_view.ex:113 #: lib/block_scout_web/views/tokens/overview_view.ex:37 #: lib/block_scout_web/views/transaction_view.ex:394 msgid "Token Transfers" @@ -1175,7 +1175,7 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:33 #: lib/block_scout_web/templates/address/overview.html.eex:133 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:51 -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:94 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:101 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:116 msgid "QR Code" @@ -1716,8 +1716,8 @@ msgstr "" #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:37 #: lib/block_scout_web/templates/address/overview.html.eex:134 #: lib/block_scout_web/templates/address/overview.html.eex:142 -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:95 -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:103 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:102 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:110 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:117 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:125 msgid "Close" @@ -1735,7 +1735,7 @@ msgid "Copy Token ID" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:69 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:76 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:74 msgid "Decimals" msgstr "" @@ -1768,7 +1768,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/instance/metadata/index.html.eex:18 #: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:10 -#: lib/block_scout_web/views/tokens/instance/overview_view.ex:99 +#: lib/block_scout_web/views/tokens/instance/overview_view.ex:114 msgid "Metadata" msgstr "" @@ -1783,7 +1783,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:67 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:74 msgid "Transfers" 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 1c67b68654..9db39cb7f1 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 @@ -901,7 +901,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7 #: lib/block_scout_web/views/address_view.ex:346 -#: lib/block_scout_web/views/tokens/instance/overview_view.ex:98 +#: lib/block_scout_web/views/tokens/instance/overview_view.ex:113 #: lib/block_scout_web/views/tokens/overview_view.ex:37 #: lib/block_scout_web/views/transaction_view.ex:394 msgid "Token Transfers" @@ -1175,7 +1175,7 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:33 #: lib/block_scout_web/templates/address/overview.html.eex:133 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:51 -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:94 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:101 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:116 msgid "QR Code" @@ -1716,8 +1716,8 @@ msgstr "" #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:37 #: lib/block_scout_web/templates/address/overview.html.eex:134 #: lib/block_scout_web/templates/address/overview.html.eex:142 -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:95 -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:103 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:102 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:110 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:117 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:125 msgid "Close" @@ -1735,7 +1735,7 @@ msgid "Copy Token ID" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:69 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:76 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:74 msgid "Decimals" msgstr "" @@ -1768,7 +1768,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/instance/metadata/index.html.eex:18 #: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:10 -#: lib/block_scout_web/views/tokens/instance/overview_view.ex:99 +#: lib/block_scout_web/views/tokens/instance/overview_view.ex:114 msgid "Metadata" msgstr "" @@ -1783,7 +1783,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:67 +#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:74 msgid "Transfers" msgstr ""