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

Jordan/2183 fix page network block loading #2187

Merged
merged 8 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added

- [\#1306](https://github.com/cosmos/voyager/issues/1306) Withdraw fee distribution rewards @fedekunze
- [\#2183](https://github.com/cosmos/voyager/issues/2183) Loading block to network block loader @jbibla

### Changed

Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/assets/images/loader.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/renderer/components/common/ActionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<img
class="icon action-modal-atom"
src="~assets/images/cosmos-logo.png"
/>
>
<span class="action-modal-title">
{{ session.signedIn ? title : `Sign in required` }}
</span>
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/components/common/TmHardwareState.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="tm-hardware-state">
<img v-if="loading" src="~assets/images/loader.svg" >
<img v-if="loading" src="~assets/images/loader.svg">
<i class="tm-hardware-state__icon material-icons">{{ icon }}</i>
<div class="tm-hardware-state__label">
<slot />
Expand Down
24 changes: 18 additions & 6 deletions app/src/renderer/components/network/PageNetwork.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,23 @@
<dl class="info_dl">
<dt>Total Liquid {{ bondDenom }}</dt>
<dd id="loose_tokens">
{{ pool.pool && pool.pool.not_bonded_tokens ? num.pretty(
num.atoms(pool.pool.not_bonded_tokens)
) : `n/a` }}
{{
pool.pool && pool.pool.not_bonded_tokens
? num.pretty(num.atoms(pool.pool.not_bonded_tokens))
jbibla marked this conversation as resolved.
Show resolved Hide resolved
: `n/a`
}}
</dd>
</dl>
</div>
<div class="column">
<dl class="info_dl">
<dt>Total Delegated {{ bondDenom }}</dt>
<dd id="bonded_tokens">
{{ pool.pool && pool.pool.bonded_tokens ? num.pretty(
num.atoms(pool.pool.bonded_tokens)
) : `n/a` }}
{{
pool.pool && pool.pool.bonded_tokens
? num.pretty(num.atoms(pool.pool.bonded_tokens))
jbibla marked this conversation as resolved.
Show resolved Hide resolved
: `n/a`
}}
</dd>
</dl>
</div>
Expand All @@ -63,6 +67,14 @@
<panel-sort :properties="properties" />
</thead>
<tbody>
<tr v-if="blocks.length === 0" class="block data-table__row">
<td>
<img class="loading-icon" src="~assets/images/loader.svg">
</td>
<td>
<img class="loading-icon" src="~assets/images/loader.svg">
</td>
</tr>
<tr
v-for="block in blocks"
:key="block.header.height"
Expand Down
16 changes: 15 additions & 1 deletion test/unit/specs/components/network/PageNetwork.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,21 @@ describe(`PageNetwork`, () => {
})
})

it(`has the expected html structure`, () => {
it(`should display the network page with data and the blocks table`, () => {
expect(wrapper.vm.$el).toMatchSnapshot()
})

it(`should display the network page with the blocks table in a loading state`, () => {
$store.getters.blocks = []

wrapper = shallowMount(PageNetwork, {
localVue,
mocks: {
$store
},
stubs: [`router-link`]
})

expect(wrapper.vm.$el).toMatchSnapshot()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PageNetwork has the expected html structure 1`] = `
exports[`PageNetwork should display the network page with data and the blocks table 1`] = `
<tm-page-stub
data-title="Network"
subtitle=""
Expand Down Expand Up @@ -140,6 +140,8 @@ exports[`PageNetwork has the expected html structure 1`] = `
</thead>

<tbody>
<!---->

<tr
class="block data-table__row"
>
Expand Down Expand Up @@ -178,3 +180,166 @@ exports[`PageNetwork has the expected html structure 1`] = `
</table>
</tm-page-stub>
`;

exports[`PageNetwork should display the network page with the blocks table in a loading state 1`] = `
<tm-page-stub
data-title="Network"
subtitle=""
title=""
>
<div
class="page-profile__header page-profile__section network"
>
<div
class="row"
>
<div
class="page-profile__header__info"
>
<div
class="page-profile__status-and-title"
>
<span
class="page-profile__status green"
/>

<h2
class="page-profile__title"
>

gaia-20k

</h2>
</div>
</div>
</div>

<div
class="row"
>
<dl
class="info_dl colored_dl"
>
<dt>
Block Height
</dt>

<dd>
#6,001
</dd>
</dl>

<dl
class="info_dl colored_dl"
>
<dt>
Last Block
</dt>

<dd>
a few seconds ago
</dd>
</dl>

<dl
class="info_dl colored_dl"
>
<dt>
Transactions
</dt>

<dd>
108
</dd>
</dl>

<dl
class="info_dl colored_dl"
>
<dt>
Number of Validators
</dt>

<dd>
1
</dd>
</dl>
</div>

<div
class="row"
>
<div
class="column"
>
<dl
class="info_dl"
>
<dt>
Total Liquid stake
</dt>

<dd
id="loose_tokens"
>

0.00

</dd>
</dl>
</div>

<div
class="column"
>
<dl
class="info_dl"
>
<dt>
Total Delegated stake
</dt>

<dd
id="bonded_tokens"
>

0.00

</dd>
</dl>
</div>
</div>
</div>

<table
class="blocks data-table"
>
<thead>
<panel-sort-stub
properties="[object Object],[object Object]"
/>
</thead>

<tbody>
<tr
class="block data-table__row"
>
<td>
<img
class="loading-icon"
src="~assets/images/loader.svg"
/>
</td>

<td>
<img
class="loading-icon"
src="~assets/images/loader.svg"
/>
</td>
</tr>

</tbody>
</table>
</tm-page-stub>
`;