Conditionally show the link to an address.

pull/2/head
CJ Bryan and Matt Olenick 7 years ago
parent 82982ce0de
commit 6995427e2c
  1. 4
      lib/explorer/forms/transaction_form.ex
  2. 16
      lib/explorer_web/templates/transaction/show.html.eex
  3. 4
      test/explorer/forms/transaction_form_test.exs

@ -63,7 +63,7 @@ defmodule Explorer.TransactionForm do
case Repo.one(query) do
nil ->
gettext("Pending")
nil
to_address ->
to_address.hash
end
@ -79,7 +79,7 @@ defmodule Explorer.TransactionForm do
case Repo.one(query) do
nil ->
gettext("Pending")
nil
from_address ->
from_address.hash
end

@ -39,11 +39,23 @@
</div>
<div class="transaction__item">
<dt class="transaction__item-key"><%= gettext "From" %></dt>
<dd class="transaction__item-value"><%= link(@transaction.from_address, to: address_path(@conn, :show, @conn.assigns.locale, @transaction.from_address)) %></dd>
<dd class="transaction__item-value">
<%= if @transaction.from_address do %>
<%= link(@transaction.from_address, to: address_path(@conn, :show, @conn.assigns.locale, @transaction.from_address)) %>
<% else %>
<%= gettext "Pending" %>
<% end %>
</dd>
</div>
<div class="transaction__item">
<dt class="transaction__item-key"><%= gettext "To" %></dt>
<dd class="transaction__item-value"><%= link(@transaction.to_address, to: address_path(@conn, :show, @conn.assigns.locale, @transaction.to_address)) %></dd>
<dd class="transaction__item-value">
<%= if @transaction.to_address do %>
<%= link(@transaction.to_address, to: address_path(@conn, :show, @conn.assigns.locale, @transaction.to_address)) %>
<% else %>
<%= gettext "Pending" %>
<% end %>
</dd>
</div>
</dl>
</div>

@ -74,8 +74,8 @@ defmodule Explorer.TransactionFormTest do
formatted_age: "Pending",
formatted_timestamp: "Pending",
cumulative_gas_used: "Pending",
to_address: "Pending",
from_address: "Pending",
to_address: nil,
from_address: nil,
confirmations: 0,
status: "Pending",
first_seen: "48 years ago",

Loading…
Cancel
Save