Hide address tabs if no items

pull/3239/head
Victor Baranov 4 years ago
parent 41ceae90cb
commit dad7c030bb
  1. 1
      CHANGELOG.md
  2. 56
      apps/block_scout_web/lib/block_scout_web/templates/address/_tabs.html.eex
  3. 24
      apps/block_scout_web/priv/gettext/default.pot
  4. 24
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  5. 37
      apps/explorer/lib/explorer/chain.ex

@ -1,6 +1,7 @@
## Current ## Current
### Features ### Features
- [#3239](https://github.com/poanetwork/blockscout/pull/3239) - Hide address page tabs if no items
- [#3236](https://github.com/poanetwork/blockscout/pull/3236) - Easy verification of contracts which hash verified twins (the same bytecode) - [#3236](https://github.com/poanetwork/blockscout/pull/3236) - Easy verification of contracts which hash verified twins (the same bytecode)
- [#3227](https://github.com/poanetwork/blockscout/pull/3227) - Distinguishing of bridged tokens - [#3227](https://github.com/poanetwork/blockscout/pull/3227) - Distinguishing of bridged tokens
- [#3224](https://github.com/poanetwork/blockscout/pull/3224) - Top tokens page - [#3224](https://github.com/poanetwork/blockscout/pull/3224) - Top tokens page

@ -4,41 +4,51 @@
class: "card-tab #{tab_status("transactions", @conn.request_path)}", class: "card-tab #{tab_status("transactions", @conn.request_path)}",
to: address_transaction_path(@conn, :index, @address.hash) to: address_transaction_path(@conn, :index, @address.hash)
) %> ) %>
<%= link( <%= if Chain.check_if_token_transfers_at_address(@address.hash) do %>
gettext("Token Transfers"), <%= link(
class: "card-tab #{tab_status("token_transfers", @conn.request_path)}", gettext("Token Transfers"),
"data-test": "token_transfers_tab_link", class: "card-tab #{tab_status("token_transfers", @conn.request_path)}",
to: address_token_transfers_path(@conn, :index, @address.hash) "data-test": "token_transfers_tab_link",
) %> to: address_token_transfers_path(@conn, :index, @address.hash)
) %>
<% end %>
<%= if Chain.check_if_tokens_at_address(@address.hash) do %>
<%= link( <%= link(
gettext("Tokens"), gettext("Tokens"),
class: "card-tab #{tab_status("tokens", @conn.request_path)}", class: "card-tab #{tab_status("tokens", @conn.request_path)}",
to: address_token_path(@conn, :index, @address.hash), to: address_token_path(@conn, :index, @address.hash),
"data-test": "tokens_tab_link" "data-test": "tokens_tab_link"
) %> ) %>
<%= link( <% end %>
gettext("Internal Transactions"), <%= if Chain.check_if_internal_transactions_at_address(@address.hash) do %>
class: "card-tab #{tab_status("internal_transactions", @conn.request_path)}", <%= link(
"data-test": "internal_transactions_tab_link", gettext("Internal Transactions"),
to: address_internal_transaction_path(@conn, :index, @address.hash) class: "card-tab #{tab_status("internal_transactions", @conn.request_path)}",
) %> "data-test": "internal_transactions_tab_link",
to: address_internal_transaction_path(@conn, :index, @address.hash)
) %>
<% end %>
<%= link( <%= link(
gettext("Coin Balance History"), gettext("Coin Balance History"),
class: "card-tab #{tab_status("coin_balances", @conn.request_path)}", class: "card-tab #{tab_status("coin_balances", @conn.request_path)}",
"data-test": "coin_balance_tab_link", "data-test": "coin_balance_tab_link",
to: address_coin_balance_path(@conn, :index, @address.hash) to: address_coin_balance_path(@conn, :index, @address.hash)
) %> ) %>
<%= link( <%= if Chain.check_if_logs_at_address(@address.hash) do %>
gettext("Logs"), <%= link(
class: "card-tab #{tab_status("logs", @conn.request_path)}", gettext("Logs"),
to: address_logs_path(@conn, :index, @address.hash) class: "card-tab #{tab_status("logs", @conn.request_path)}",
) %> to: address_logs_path(@conn, :index, @address.hash)
<%= link( ) %>
gettext("Blocks Validated"), <% end %>
class: "card-tab #{tab_status("validations", @conn.request_path)}", <%= if Chain.check_if_validated_blocks_at_address(@address.hash) do %>
"data-test": "validations_tab_link", <%= link(
to: address_validation_path(@conn, :index, @address.hash) gettext("Blocks Validated"),
) %> class: "card-tab #{tab_status("validations", @conn.request_path)}",
"data-test": "validations_tab_link",
to: address_validation_path(@conn, :index, @address.hash)
) %>
<% end %>
<%= if contract?(@address) do %> <%= if contract?(@address) do %>
<%= link( <%= link(
to: address_contract_path(@conn, :index, @address.hash), to: address_contract_path(@conn, :index, @address.hash),

@ -493,7 +493,7 @@ msgid "Decoded"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:56 #: lib/block_scout_web/templates/address/_tabs.html.eex:66
msgid "Decompiled code" msgid "Decompiled code"
msgstr "" msgstr ""
@ -891,7 +891,7 @@ msgid "Token Transfer"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:8 #: lib/block_scout_web/templates/address/_tabs.html.eex:9
#: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:3 #: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:3
#: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:16 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:16
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:3 #: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:3
@ -1792,14 +1792,14 @@ msgid "Copy Txn Input"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:37 #: lib/block_scout_web/templates/address/_tabs.html.eex:46
#: lib/block_scout_web/templates/address_validation/index.html.eex:13 #: lib/block_scout_web/templates/address_validation/index.html.eex:13
#: lib/block_scout_web/views/address_view.ex:354 #: lib/block_scout_web/views/address_view.ex:354
msgid "Blocks Validated" msgid "Blocks Validated"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:46 #: lib/block_scout_web/templates/address/_tabs.html.eex:56
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187
#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:126 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:126
@ -1809,7 +1809,7 @@ msgid "Code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:26 #: lib/block_scout_web/templates/address/_tabs.html.eex:32
#: lib/block_scout_web/views/address_view.ex:353 #: lib/block_scout_web/views/address_view.ex:353
msgid "Coin Balance History" msgid "Coin Balance History"
msgstr "" msgstr ""
@ -1820,7 +1820,7 @@ msgid "Decompiled Code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:20 #: lib/block_scout_web/templates/address/_tabs.html.eex:25
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:19 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:19
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:11 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:11
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6
@ -1830,7 +1830,7 @@ msgid "Internal Transactions"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:32 #: lib/block_scout_web/templates/address/_tabs.html.eex:39
#: lib/block_scout_web/templates/address_logs/index.html.eex:8 #: lib/block_scout_web/templates/address_logs/index.html.eex:8
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:17 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:17
#: lib/block_scout_web/templates/transaction_log/index.html.eex:8 #: lib/block_scout_web/templates/transaction_log/index.html.eex:8
@ -1840,7 +1840,7 @@ msgid "Logs"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:62 #: lib/block_scout_web/templates/address/_tabs.html.eex:72
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:25 #: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:25
#: lib/block_scout_web/views/address_view.ex:349 #: lib/block_scout_web/views/address_view.ex:349
#: lib/block_scout_web/views/tokens/overview_view.ex:39 #: lib/block_scout_web/views/tokens/overview_view.ex:39
@ -1848,7 +1848,7 @@ msgid "Read Contract"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:14 #: lib/block_scout_web/templates/address/_tabs.html.eex:17
#: lib/block_scout_web/templates/address_token/index.html.eex:8 #: lib/block_scout_web/templates/address_token/index.html.eex:8
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:11 #: lib/block_scout_web/templates/address_token_transfer/index.html.eex:11
#: lib/block_scout_web/templates/layout/_topnav.html.eex:83 #: lib/block_scout_web/templates/layout/_topnav.html.eex:83
@ -1904,13 +1904,13 @@ msgid "Revert reason"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:69 #: lib/block_scout_web/templates/address/_tabs.html.eex:79
#: lib/block_scout_web/views/address_view.ex:350 #: lib/block_scout_web/views/address_view.ex:350
msgid "Read Proxy" msgid "Read Proxy"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:76 #: lib/block_scout_web/templates/address/_tabs.html.eex:86
#: lib/block_scout_web/views/address_view.ex:351 #: lib/block_scout_web/views/address_view.ex:351
msgid "Write Contract" msgid "Write Contract"
msgstr "" msgstr ""
@ -1927,7 +1927,7 @@ msgid "Write"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:83 #: lib/block_scout_web/templates/address/_tabs.html.eex:93
#: lib/block_scout_web/views/address_view.ex:352 #: lib/block_scout_web/views/address_view.ex:352
msgid "Write Proxy" msgid "Write Proxy"
msgstr "" msgstr ""

@ -493,7 +493,7 @@ msgid "Decoded"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:56 #: lib/block_scout_web/templates/address/_tabs.html.eex:66
msgid "Decompiled code" msgid "Decompiled code"
msgstr "" msgstr ""
@ -891,7 +891,7 @@ msgid "Token Transfer"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:8 #: lib/block_scout_web/templates/address/_tabs.html.eex:9
#: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:3 #: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:3
#: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:16 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:16
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:3 #: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:3
@ -1792,14 +1792,14 @@ msgid "Copy Txn Input"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:37 #: lib/block_scout_web/templates/address/_tabs.html.eex:46
#: lib/block_scout_web/templates/address_validation/index.html.eex:13 #: lib/block_scout_web/templates/address_validation/index.html.eex:13
#: lib/block_scout_web/views/address_view.ex:354 #: lib/block_scout_web/views/address_view.ex:354
msgid "Blocks Validated" msgid "Blocks Validated"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:46 #: lib/block_scout_web/templates/address/_tabs.html.eex:56
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187
#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:126 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:126
@ -1809,7 +1809,7 @@ msgid "Code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:26 #: lib/block_scout_web/templates/address/_tabs.html.eex:32
#: lib/block_scout_web/views/address_view.ex:353 #: lib/block_scout_web/views/address_view.ex:353
msgid "Coin Balance History" msgid "Coin Balance History"
msgstr "" msgstr ""
@ -1820,7 +1820,7 @@ msgid "Decompiled Code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:20 #: lib/block_scout_web/templates/address/_tabs.html.eex:25
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:19 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:19
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:11 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:11
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6
@ -1830,7 +1830,7 @@ msgid "Internal Transactions"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:32 #: lib/block_scout_web/templates/address/_tabs.html.eex:39
#: lib/block_scout_web/templates/address_logs/index.html.eex:8 #: lib/block_scout_web/templates/address_logs/index.html.eex:8
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:17 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:17
#: lib/block_scout_web/templates/transaction_log/index.html.eex:8 #: lib/block_scout_web/templates/transaction_log/index.html.eex:8
@ -1840,7 +1840,7 @@ msgid "Logs"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:62 #: lib/block_scout_web/templates/address/_tabs.html.eex:72
#: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:25 #: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:25
#: lib/block_scout_web/views/address_view.ex:349 #: lib/block_scout_web/views/address_view.ex:349
#: lib/block_scout_web/views/tokens/overview_view.ex:39 #: lib/block_scout_web/views/tokens/overview_view.ex:39
@ -1848,7 +1848,7 @@ msgid "Read Contract"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:14 #: lib/block_scout_web/templates/address/_tabs.html.eex:17
#: lib/block_scout_web/templates/address_token/index.html.eex:8 #: lib/block_scout_web/templates/address_token/index.html.eex:8
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:11 #: lib/block_scout_web/templates/address_token_transfer/index.html.eex:11
#: lib/block_scout_web/templates/layout/_topnav.html.eex:83 #: lib/block_scout_web/templates/layout/_topnav.html.eex:83
@ -1904,13 +1904,13 @@ msgid "Revert reason"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:69 #: lib/block_scout_web/templates/address/_tabs.html.eex:79
#: lib/block_scout_web/views/address_view.ex:350 #: lib/block_scout_web/views/address_view.ex:350
msgid "Read Proxy" msgid "Read Proxy"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:76 #: lib/block_scout_web/templates/address/_tabs.html.eex:86
#: lib/block_scout_web/views/address_view.ex:351 #: lib/block_scout_web/views/address_view.ex:351
msgid "Write Contract" msgid "Write Contract"
msgstr "" msgstr ""
@ -1927,7 +1927,7 @@ msgid "Write"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/_tabs.html.eex:83 #: lib/block_scout_web/templates/address/_tabs.html.eex:93
#: lib/block_scout_web/views/address_view.ex:352 #: lib/block_scout_web/views/address_view.ex:352
msgid "Write Proxy" msgid "Write Proxy"
msgstr "" msgstr ""

@ -1859,6 +1859,43 @@ defmodule Explorer.Chain do
|> Repo.all() |> Repo.all()
end end
def check_if_validated_blocks_at_address(address_hash) do
Repo.exists?(from(b in Block, where: b.miner_hash == ^address_hash))
end
def check_if_logs_at_address(address_hash) do
Repo.exists?(from(l in Log, where: l.address_hash == ^address_hash))
end
def check_if_internal_transactions_at_address(address_hash) do
internal_transactions_exists_by_created_contract_address_hash =
Repo.exists?(from(it in InternalTransaction, where: it.created_contract_address_hash == ^address_hash))
internal_transactions_exists_by_from_address_hash =
Repo.exists?(from(it in InternalTransaction, where: it.from_address_hash == ^address_hash))
internal_transactions_exists_by_to_address_hash =
Repo.exists?(from(it in InternalTransaction, where: it.to_address_hash == ^address_hash))
internal_transactions_exists_by_created_contract_address_hash || internal_transactions_exists_by_from_address_hash ||
internal_transactions_exists_by_to_address_hash
end
def check_if_token_transfers_at_address(address_hash) do
token_transfers_exists_by_from_address_hash =
Repo.exists?(from(tt in TokenTransfer, where: tt.from_address_hash == ^address_hash))
token_transfers_exists_by_to_address_hash =
Repo.exists?(from(tt in TokenTransfer, where: tt.to_address_hash == ^address_hash))
token_transfers_exists_by_from_address_hash ||
token_transfers_exists_by_to_address_hash
end
def check_if_tokens_at_address(address_hash) do
Repo.exists?(from(tb in CurrentTokenBalance, where: tb.address_hash == ^address_hash))
end
@doc """ @doc """
Counts all of the block validations and groups by the `miner_hash`. Counts all of the block validations and groups by the `miner_hash`.
""" """

Loading…
Cancel
Save