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

Mario/2965 set max button pending changes #2974

Merged
merged 38 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
89177d9
Debug
mariopino Sep 9, 2019
2691cfd
Fix
mariopino Sep 9, 2019
087c3ec
Fix
mariopino Sep 9, 2019
7c08f2b
Replace operator === by == in isMaxAmount() func
mariopino Sep 10, 2019
9374a36
Better use parseFloat and === operator
mariopino Sep 10, 2019
9ddaa32
Change set max btn style to secondary
mariopino Sep 10, 2019
fa8e5ad
Fix btn class and type
mariopino Sep 10, 2019
01059df
TmBtn code cleanup, change btn style in dele/undel
mariopino Sep 10, 2019
3a8a954
Fix addon-max css padding
mariopino Sep 10, 2019
fe6cfa5
Unify denom input suffix in send, deleg and undel
mariopino Sep 10, 2019
87b2b50
Fix input-suffix css
mariopino Sep 10, 2019
08998ab
Fix input-suffix css and
mariopino Sep 10, 2019
f7f31dd
Cleanup
mariopino Sep 10, 2019
b0717c3
Fix input suffix css
mariopino Sep 10, 2019
47bfdbd
Fix css
mariopino Sep 10, 2019
7247e8c
Fix delegation modal isMaxAmount()
mariopino Sep 10, 2019
ebe281f
Update snapshots
mariopino Sep 10, 2019
f2e5cea
changelog
mariopino Sep 10, 2019
e7fdd8e
Fix delegation message
mariopino Sep 10, 2019
fb870f5
Reserve space for warning message
mariopino Sep 10, 2019
ef39e6a
Fix class
mariopino Sep 10, 2019
e72e265
Change .form-message.empty padding
mariopino Sep 10, 2019
d7d5347
Fix css padding
mariopino Sep 10, 2019
aa8e4cd
Update SendModal snapshot
mariopino Sep 10, 2019
8fc576c
Css fix, reserve space for warning in del. modal
mariopino Sep 10, 2019
45ff188
Update snap
mariopino Sep 10, 2019
5f1ed40
Css cleanup
mariopino Sep 10, 2019
fca4eba
Fix padding
mariopino Sep 10, 2019
f7f319a
Fix css padding
mariopino Sep 10, 2019
c8b2565
Merge branch 'develop' into mario/2965-set-max-button
mariopino Sep 16, 2019
f59631a
Show warn about using all tokens as validation msg
mariopino Sep 16, 2019
917fd98
Cleanup
mariopino Sep 16, 2019
53cc00a
Increase margin for edit memo btn
mariopino Sep 16, 2019
8ef6332
Update tests and snaps
mariopino Sep 16, 2019
5f3f731
Fix SendModal test
mariopino Sep 16, 2019
6880659
Mod. isMaxAmount() to return false if balance = 0
mariopino Sep 16, 2019
872f902
Update tests
mariopino Sep 16, 2019
9e6d837
Increase code coverage
mariopino Sep 16, 2019
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 changes/mario_2965-set-max-button
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Fixed] [#2965](https://github.com/cosmos/lunie/issues/2965) Change Set Max button style to secondary, fixed bug in warning message. @mariopino
12 changes: 0 additions & 12 deletions src/ActionModal/components/ActionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -773,18 +773,6 @@ export default {
display: inline-block;
}

.form-message.notice {
border-radius: 0.25rem;
border: 1px solid var(--bc-dim);
background-color: #1c223e;
font-weight: 300;
margin: 2rem 0;
padding: 1rem 1rem;
font-size: 14px;
font-style: normal;
width: 100%;
}

.slide-fade-enter-active {
transition: all 0.1s ease;
}
Expand Down
17 changes: 10 additions & 7 deletions src/ActionModal/components/DelegationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
field-id="amount"
field-label="Amount"
>
<!-- <span class="input-suffix">{{ denom | viewDenom }}</span> -->
<span class="input-suffix-denom">{{ viewDenom(denom) }}</span>
<TmFieldGroup>
<TmField
id="amount"
Expand All @@ -61,7 +61,8 @@
@keyup.enter.native="enterPressed"
/>
<TmBtn
type="addon-max"
type="button"
class="secondary addon-max"
value="Set Max"
@click.native="setMaxAmount()"
/>
Expand Down Expand Up @@ -99,10 +100,12 @@
name="Amount"
type="between"
/>
<p v-if="isMaxAmount() && !isRedelegation()" class="form-message notice">
You are about to use all your tokens for this transaction. Consider
leaving a little bit left over to cover the network fees.
</p>
<TmFormMsg
v-else-if="isMaxAmount() && !isRedelegation()"
msg="You are about to use all your tokens for this transaction. Consider leaving a little bit left over to cover the network fees."
type="custom"
class="tm-form-msg--desc"
/>
</TmFormGroup>
</ActionModal>
</template>
Expand Down Expand Up @@ -229,7 +232,7 @@ export default {
this.amount = atoms(this.balance)
},
isMaxAmount() {
return this.amount === atoms(this.balance)
return parseFloat(this.amount) === parseFloat(atoms(this.balance))
},
enterPressed() {
this.$refs.actionModal.validateChangeStep()
Expand Down
25 changes: 15 additions & 10 deletions src/ActionModal/components/SendModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
field-id="amount"
field-label="Amount"
>
<span class="input-suffix-denom">{{ viewDenom(denom) }}</span>
<TmFieldGroup>
<TmField
id="amount"
Expand All @@ -70,7 +71,8 @@
@keyup.enter.native="enterPressed"
/>
<TmBtn
type="addon-max"
type="button"
class="secondary addon-max"
value="Set Max"
@click.native="setMaxAmount()"
/>
Expand Down Expand Up @@ -98,10 +100,12 @@
name="Amount"
type="between"
/>
<p v-if="isMaxAmount()" class="form-message notice max-notice">
You are about to use all your tokens for this transaction. Consider
leaving a little bit left over to cover the network fees.
</p>
<TmFormMsg
v-else-if="isMaxAmount()"
msg="You are about to use all your tokens for this transaction. Consider leaving a little bit left over to cover the network fees."
type="custom"
class="tm-form-msg--desc max-message"
/>
</TmFormGroup>
<TmBtn
v-if="editMemo === false"
Expand Down Expand Up @@ -220,7 +224,11 @@ export default {
this.amount = atoms(this.balance)
},
isMaxAmount() {
return this.amount === atoms(this.balance)
if (this.balance === 0) {
return false
} else {
return parseFloat(this.amount) === parseFloat(atoms(this.balance))
}
},
bech32Validate(param) {
try {
Expand Down Expand Up @@ -262,10 +270,7 @@ export default {
</script>
<style scoped>
#edit-memo-btn {
margin-top: 1.5rem;
margin-top: 2.4rem;
}

.form-message.notice {
margin: 1rem 0 0 0;
}
</style>
5 changes: 3 additions & 2 deletions src/ActionModal/components/UndelegationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
field-id="amount"
field-label="Amount"
>
<span class="input-suffix">{{ num.viewDenom(denom) }}</span>
<span class="input-suffix-denom">{{ num.viewDenom(denom) }}</span>
<TmFieldGroup>
<TmField
id="amount"
Expand All @@ -47,7 +47,8 @@
@keyup.enter.native="enterPressed"
/>
<TmBtn
type="addon-max"
type="button"
class="secondary addon-max"
value="Set Max"
@click.native="setMaxAmount()"
/>
Expand Down
8 changes: 3 additions & 5 deletions src/components/common/TmBtn.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<template>
<button v-if="type === `addon-max`" class="addon-max" :disabled="disabled">
{{ value }}
</button>
<button
v-else
class="button"
:class="{
secondary: type === `secondary`,
Expand Down Expand Up @@ -110,10 +106,12 @@ export default {
font-family: var(--sans);
font-size: 14px;
font-weight: 400;
padding: 5px 16px;
padding: 4px 16px;
min-width: 100px;
color: var(--bright);
margin: 0;
border-top-left-radius: 0 !important;
border-bottom-left-radius: 0 !important;
border-top-right-radius: 0.25rem !important;
border-bottom-right-radius: 0.25rem !important;
cursor: pointer;
Expand Down
13 changes: 13 additions & 0 deletions src/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ input.tm-field {
border-radius: 2px;
}

.input-suffix-denom {
display: inline-block;
position: absolute;
padding: 7px 8px;
font-size: var(--sm);
text-transform: uppercase;
right: 124px;
letter-spacing: 1px;
text-align: right;
font-weight: 500;
border-radius: 2px;
}

.field-checkbox-label {
display: block;
padding-left: 1.5rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe(`DelegationModal`, () => {
const state = {
session: {
signedIn: true,
address: `cosmosvaladdr15ky9du8a2wlstz6fpx3p4mqpjyrm5ctqzh8yqw`
address: `cosmosvaladdr15ky9du8a2wlstz6fpx3p4mqpjyrm5ctqzh8yqw`,
}
}

Expand Down Expand Up @@ -192,4 +192,27 @@ describe(`DelegationModal`, () => {
})
})
})

describe(`if amount field max button clicked`, () => {
it(`amount has to be 1000 atom`, async () => {
wrapper.setData({
amount: 1,
selectedIndex: 0,
validator: mockValues.state.candidates[1]
})
wrapper.vm.setMaxAmount()
expect(wrapper.vm.amount).toBe(1000)
})
it(`should show warning message`, async () => {
wrapper.setData({
amount: 1000,
selectedIndex: 0,
validator: mockValues.state.candidates[1]
})
//await wrapper.vm.$nextTick()
expect(wrapper.html()).toContain(
"You are about to use all your tokens for this transaction. Consider leaving a little bit left over to cover the network fees."
)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ describe(`SendModal`, () => {
{
denom: `fermion`,
amount: 2300
},
{
denom: `EMPTY_BALANCE`,
amount: 0
}
]
const getters = {
Expand All @@ -27,7 +31,7 @@ describe(`SendModal`, () => {
const state = {
wallet: {
loading: false,
denoms: [`fermion`, `gregcoin`, `mycoin`, `STAKE`],
denoms: [`fermion`, `gregcoin`, `mycoin`, `STAKE`, `EMPTY_BALANCE`],
balances
}
}
Expand Down Expand Up @@ -189,11 +193,30 @@ describe(`SendModal`, () => {
address: `cosmos12345`
})
wrapper.vm.setMaxAmount()
expect(wrapper.vm.amount).toBe(10000)
await wrapper.vm.$nextTick()
expect(wrapper.find(".max-notice").text()).toContain(
"You are about to use all your tokens for this transaction."
expect(wrapper.html()).toContain(
"You are about to use all your tokens for this transaction. Consider leaving a little bit left over to cover the network fees."
)
})
it(`should not show warning message if balance = 0`, async () => {
wrapper.setData({
denom: `EMPTY_BALANCE`,
address: `cosmos12345`
})
wrapper.vm.setMaxAmount()
await wrapper.vm.$nextTick()
expect(wrapper.html()).not.toContain(
"You are about to use all your tokens for this transaction. Consider leaving a little bit left over to cover the network fees."
)
})
it(`isMaxAmount() should return false if balance = 0`, async () => {
wrapper.setData({
denom: `EMPTY_BALANCE`,
address: `cosmos12345`
})
wrapper.vm.setMaxAmount()
await wrapper.vm.$nextTick()
expect(wrapper.vm.isMaxAmount()).toBe(false)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ exports[`DelegationModal should display the delegation modal form 1`] = `
fieldid="amount"
fieldlabel="Amount"
>
<span
class="input-suffix-denom"
>
STAKE
</span>

<tmfieldgroup-stub>
<tmfield-stub
class="tm-field-addon"
Expand All @@ -67,7 +73,8 @@ exports[`DelegationModal should display the delegation modal form 1`] = `
/>

<tmbtn-stub
type="addon-max"
class="secondary addon-max"
type="button"
value="Set Max"
/>
</tmfieldgroup-stub>
Expand All @@ -83,8 +90,6 @@ exports[`DelegationModal should display the delegation modal form 1`] = `
</span>

<!---->

<!---->
</tmformgroup-stub>
</actionmodal-stub>
`;
Loading