Skip to content

Commit

Permalink
Merge branch 'develop' into peng/fix-ni-session
Browse files Browse the repository at this point in the history
  • Loading branch information
faboweb authored Jan 30, 2018
2 parents 093d49b + 3a3e080 commit a1ea674
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [3.0.0] - 2018-01-15
## [0.3.0] - 2018-01-15
### Added
- Added a changelog @jolesbi.

## [0.3.1] - 2018-01-30
### Changed
* Resolved notifications error on NiSessionLoading.vue @nylira.
* Resolved old saved prevAccountKey being used in NiSessionSignIn.vue @nylira.
* Improved performance of amountBonded in LiDelegate.vue @nylira.
* Prevented user from going to PageBond if they don't have any atoms/fermions @nylira.
* Hid the bonding interface on PageDelegates if the user doesn't have any atoms @nylira.
26 changes: 15 additions & 11 deletions app/src/renderer/components/staking/LiDelegate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
span {{ num.prettyInt(delegate.voting_power) }}
.bar(:style='vpStyles')
.li-delegate__value.bonded_by_you
span {{ num.prettyInt(amountBonded(delegate.id)) }}
.li-delegate__value.checkbox#remove-from-cart(v-if="inCart" @click='rm(delegate)')
i.material-icons check_box
.li-delegate__value.checkbox#add-to-cart(v-else @click='add(delegate)')
i.material-icons check_box_outline_blank
span {{ amountBonded }}
template(v-if="userCanDelegate")
.li-delegate__value.checkbox#remove-from-cart(v-if="inCart" @click='rm(delegate)')
i.material-icons check_box
.li-delegate__value.checkbox#add-to-cart(v-else @click='add(delegate)')
i.material-icons check_box_outline_blank
template(v-else)
.li-delegate__value
</template>

<script>
Expand All @@ -29,7 +32,10 @@ export default {
Btn
},
computed: {
...mapGetters(['shoppingCart', 'delegates', 'config', 'committedDelegations']),
...mapGetters(['shoppingCart', 'delegates', 'config', 'committedDelegations', 'user']),
amountBonded () {
return this.num.prettyInt(this.committedDelegations[this.delegate.id])
},
styles () {
let value = ''
if (this.inCart) value += 'li-delegate-active '
Expand Down Expand Up @@ -57,17 +63,15 @@ export default {
},
inCart () {
return this.shoppingCart.find(c => c.id === this.delegate.id)
}
},
userCanDelegate () { return this.user.atoms > 0 }
},
data: () => ({
num: num
}),
methods: {
add (delegate) { this.$store.commit('addToCart', delegate) },
rm (delegate) { this.$store.commit('removeFromCart', delegate.id) },
amountBonded (delegateId) {
return this.committedDelegations[delegateId]
}
rm (delegate) { this.$store.commit('removeFromCart', delegate.id) }
}
}
</script>
Expand Down
10 changes: 10 additions & 0 deletions app/src/renderer/components/staking/PageBond.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ export default {
return d
})
},
leaveIfBroke (count) {
if (count === 0) {
this.$store.commit('notifyError', {
title: 'Cannot Bond Without Atoms',
body: 'You do not have any atoms to bond to delegates.'
})
this.$router.push('/staking')
}
},
leaveIfEmpty (count) {
if (count === 0) {
this.$store.commit('notifyError', {
Expand Down Expand Up @@ -323,6 +332,7 @@ export default {
}
},
async mounted () {
this.leaveIfBroke(this.user.atoms)
this.leaveIfEmpty(this.shoppingCart.length)
this.resetFields()
this.bondBarsInput()
Expand Down
11 changes: 8 additions & 3 deletions app/src/renderer/components/staking/PageDelegates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ page#page-delegates(title='Delegates')
li-delegate(v-for='i in filteredDelegates' :key='i.id' :delegate='i')

.fixed-button-bar
.label #[strong {{ shoppingCart.length }}] delegates selected
btn.btn__primary(type="link" to="/staking/bond" :disabled="shoppingCart.length < 1" icon="chevron_right" icon-pos="right" value="Next")
template(v-if="userCanDelegate")
.label #[strong {{ shoppingCart.length }}] delegates selected
btn.btn__primary(type="link" to="/staking/bond" :disabled="shoppingCart.length < 1" icon="chevron_right" icon-pos="right" value="Next")
template(v-else)
.label You do not have any ATOMs to delegate.
btn.btn__primary(disabled icon="chevron_right" icon-pos="right" value="Next")
</template>

<script>
Expand Down Expand Up @@ -61,7 +65,8 @@ export default {
} else {
return list
}
}
},
userCanDelegate () { return this.user.atoms > 0 }
},
data: () => ({
query: '',
Expand Down
4 changes: 3 additions & 1 deletion test/unit/specs/components/staking/LiDelegate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('LiDelegate', () => {
wrapper = test.wrapper
store = test.store

store.commit('setAtoms', 1337)
store.commit('addDelegate', {
pub_key: {
type: 'ed25519',
Expand Down Expand Up @@ -62,7 +63,8 @@ describe('LiDelegate', () => {
})

it('should show the relative voting power as a bar', () => {
expect(wrapper.vm.$el.querySelector('.number_of_votes .bar').style.width).toBe('33%')
expect(wrapper.vm.$el.querySelector('.number_of_votes .bar')
.style.width).toBe('33%')
})

it('should add to cart', () => {
Expand Down
1 change: 1 addition & 0 deletions test/unit/specs/components/staking/PageDelegates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('PageDelegates', () => {
store = instance.store

store.state.user.address = 'abc'
store.commit('setAtoms', 1337)
store.commit('addDelegate', {
pub_key: {
type: 'ed25519',
Expand Down

0 comments on commit a1ea674

Please sign in to comment.