Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed code proposals and code proposal details pages #902

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// We need to import the CSS so that webpack will load it.
// The MiniCssExtractPlugin is used to separate it out into
// its own CSS file.
import {} from "./ui";
import { } from "./ui";
import {
initializeNbTransactionGraph,
updateNbTransactionGraph,
Expand Down Expand Up @@ -71,10 +71,11 @@ Hooks.Diff = {
const diffHtml = diff2html(diff, {
drawFileList: true,
matching: "lines",
outputFormat: "side-by-side",
outputFormat: "line-by-line",
highlight: true,
});
document.querySelector("#diff").innerHTML = diffHtml;
this.el.innerHTML = diffHtml;
this.el.style.display = "block";
},
};

Expand All @@ -89,7 +90,7 @@ Hooks.network_charts = {
mounted() {
const nbTransactionEl = this.el.querySelector("#nb_transactions")
const validationDurationEl = this.el.querySelector("#validation_duration")

const txGraph = initializeNbTransactionGraph(nbTransactionEl);
const validationDurationGraph = initializeValidationDurationGraph(validationDurationEl);

Expand Down
13 changes: 11 additions & 2 deletions lib/archethic_web/live/code_proposal_details_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@ defmodule ArchethicWeb.CodeProposalDetailsLive do

with {:ok, addr} <- Base.decode16(address, case: :mixed),
true <- Crypto.valid_address?(addr),
{:ok, prop} <- Governance.get_code_proposal(addr) do
{:ok,
%Proposal{
description: description,
version: version,
changes: changes,
approvals: approvals
}} <- Governance.get_code_proposal(addr) do
new_socket =
socket
|> assign(:proposal, prop)
|> assign(:description, description)
|> assign(:version, version)
|> assign(:changes, changes)
|> assign(:approvals, approvals)
|> assign(:exists?, true)
|> assign(:address, addr)
|> assign(:deployed?, false)
Expand Down
11 changes: 6 additions & 5 deletions lib/archethic_web/templates/code/proposal_details.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<div class="columns">
<div class="column">
<p class="heading">Code proposal</p>
<h1 class="subtitle text_wrap">
<%= link to: Routes.live_path(@socket, ArchethicWeb.TransactionDetailsLive, Base.encode16(@address)) do%>
<%= Base.encode16(@address) %>
</h1>
<% end %>
</div>
</div>

Expand All @@ -46,14 +46,15 @@
<div class="columns">
<div class="column">
<p class="heading">Changes</p>
<div id="diff_src" style="display: none" phx-hook="Diff"></div>
<div id="diff"></div>
<div id="diff_src" style="display: none" phx-hook="Diff">
<%= @changes %>
</div>
</div>
</div>

<div class="columns">
<div class="column">
<p class="heading">Approvals (2)</p>
<p class="heading"><%= "Approvals (#{Enum.count(@approvals)})" %></p>
<%= for approval <- @approvals do %>
<div class="columns">
<div class="column">
Expand Down
6 changes: 1 addition & 5 deletions lib/archethic_web/templates/code/proposal_list.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<p class="heading">Transaction date</p>
<span><%= format_date(proposal.timestamp) %></span>
</div>
<div class="column">
<p class="heading">Sender</p>
<span><%= Base.encode16(:binary.part(proposal.sender, 0, 13)) %>...</span>
</div>
<div class="column">
<p class="heading">Changes criticality</p>
<span>
Expand All @@ -36,7 +32,7 @@
</div>
<div class="column">
<p class="heading">Approvals</p>
<span><%= proposal.nb_approvals %></span>
<span><%= Enum.count(proposal.approvals) %></span>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions lib/archethic_web/templates/layout/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<title><%= assigns[:page_title] || "ARCHETHIC" %></title>
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
<link rel="stylesheet" href={Routes.static_path(@conn, "/css/app.css")} />
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/diff2html/bundles/css/diff2html.min.css" />
<%= csrf_meta_tag() %>
</head>
<body>
Expand Down