Show "Remove my Poll" modal window (#2461)

It's just a question and a simple contract call, actually.

Co-Authored-By: Anatoly Nikiforov <anatolyniky@gmail.com>
staking
goodsoft 5 years ago committed by Victor Baranov
parent af61d02b6d
commit 21d88a2beb
  1. 2
      apps/block_scout_web/assets/js/pages/stakes.js
  2. 11
      apps/block_scout_web/assets/js/pages/stakes/remove_pool.js
  3. 6
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_btn_remove_pool.html.eex
  4. 4
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_top.html.eex

@ -8,6 +8,7 @@ import { createAsyncLoadStore, refreshPage } from '../lib/async_listing_load'
import Web3 from 'web3'
import { openValidatorInfoModal } from './stakes/validator_info'
import { openBecomeCandidateModal } from './stakes/become_candidate'
import { openRemovePoolModal } from './stakes/remove_pool'
export const initialState = {
channel: null,
@ -82,6 +83,7 @@ if ($stakesPage.length) {
$(document.body)
.on('click', '.js-validator-info', event => openValidatorInfoModal(event, store))
.on('click', '.js-become-candidate', () => openBecomeCandidateModal(store))
.on('click', '.js-remove-pool', () => openRemovePoolModal(store))
initializeWeb3(store)
}

@ -0,0 +1,11 @@
import { openQuestionModal } from '../../lib/modals'
import { makeContractCall } from './utils'
export function openRemovePoolModal (store) {
openQuestionModal('Remove my Pool', 'Do you really want to remove your pool?', () => removePool(store))
}
async function removePool (store) {
const contract = store.getState().stakingContract
makeContractCall(contract.methods.removeMyPool(), store)
}

@ -0,0 +1,6 @@
<span class="stakes-btn-remove-pool js-remove-pool <%= if assigns[:extra_class] do @extra_class end %>">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14">
<path fill-rule="evenodd" d="M13 5h-1v8a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5H1a1 1 0 0 1 0-2h3V1a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2h3a1 1 0 0 1 0 2zM8 2H6v1h2V2zm2 3H4v7h6V5z"/>
</svg>
<span class="stakes-btn-remove-pool-text"><%= @text %></span>
</span>

@ -7,7 +7,9 @@
<%= render BlockScoutWeb.StakesView, "_stakes_stats_item_account.html", account: @account, token: @token %>
<!-- Buttons -->
<div class="stakes-top-buttons">
<%= unless @account[:pool] && @account.pool.is_active do %>
<%= if @account[:pool] && @account.pool.is_active do %>
<%= render BlockScoutWeb.StakesView, "_stakes_btn_remove_pool.html", text: gettext("Remove My Pool"), extra_class: "js-remove-pool" %>
<% else %>
<%= render BlockScoutWeb.CommonComponentsView, "_btn_add_full.html", text: gettext("Become a Candidate"), extra_class: "js-become-candidate" %>
<% end %>
</div>

Loading…
Cancel
Save