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

fedekunze/1718 remove session pt 1 #1916

Merged
merged 25 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -117,6 +117,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [\#1846](https://github.com/cosmos/voyager/issues/1846) Allow node endpoints to be set from the URL @faboweb
- [\#1221](https://github.com/cosmos/voyager/issues/1221) individual linter check on GitHub @faboweb
- [\#1922](https://github.com/cosmos/voyager/issues/1922) removed font awesome @jbibla
- [\#1916](https://github.com/cosmos/voyager/pull/1916) redirect to session modal when user hasn't logged in @fedekunze

### Fixed

Expand Down
3 changes: 2 additions & 1 deletion app/src/renderer/components/common/AppMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<router-link
id="app-menu__staking"
class="app-menu-item"
to="/staking"
to="/staking/validators/"
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
exact="exact"
title="Staking"
@click.native="close"
>
Expand Down
9 changes: 6 additions & 3 deletions app/src/renderer/components/common/TmBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
<div class="icon-container">
<img class="icon" src="~assets/images/cosmos-logo.png" />
</div>
<div class="total-atoms top-section">
<div v-if="user.signedIn" class="total-atoms top-section">
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
<h3>Total {{ bondDenom }}</h3>
<h2 class="total-atoms__value">{{ num.shortNumber(totalAtoms) }}</h2>
</div>
<div v-if="unbondedAtoms" class="unbonded-atoms top-section">
<div
v-if="unbondedAtoms && user.signedIn"
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
class="unbonded-atoms top-section"
>
<h3>Available {{ bondDenom }}</h3>
<h2>{{ unbondedAtoms }}</h2>
</div>
</div>
<short-bech32 :address="user.address || ''" />
<short-bech32 v-if="user.signedIn" :address="user.address || ''" />
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
<div class="tabs">
<div
v-for="tab in tabs"
Expand Down
23 changes: 3 additions & 20 deletions app/src/renderer/components/common/ToolBar.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<template>
<div class="tool-bar">
<a
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
v-tooltip.bottom="'Back'"
:disabled="user.history.length === 0"
class="back"
@click="back"
>
<i class="material-icons">arrow_back</i>
</a>
<a
v-tooltip.bottom="'Refresh'"
v-if="!!refresh"
Expand All @@ -32,7 +24,7 @@
</a>
<router-link
v-tooltip.bottom="'Preferences'"
v-if="config.devMode"
v-if="config.devMode && user.signedIn"
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
id="settings"
to="/preferences"
>
Expand All @@ -45,7 +37,7 @@
</template>

<script>
import { mapGetters, mapMutations } from "vuex"
import { mapGetters } from "vuex"
export default {
name: `tool-bar`,
props: {
Expand All @@ -59,7 +51,7 @@ export default {
}
},
computed: {
...mapGetters([`user`, `lastPage`, `config`]),
...mapGetters([`user`, `config`]),
searchEnabled() {
return !!this.searching
},
Expand All @@ -71,15 +63,6 @@ export default {
}
},
methods: {
...mapMutations([`pauseHistory`, `popHistory`]),
back() {
if (!this.lastPage) return
this.pauseHistory(true)
this.$router.push(this.lastPage, () => {
this.popHistory()
this.pauseHistory(false)
})
},
enableModalHelp() {
this.$store.commit(`setModalHelp`, true)
},
Expand Down
14 changes: 12 additions & 2 deletions app/src/renderer/components/governance/PageGovernance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ export default {
]
}),
computed: {
...mapGetters([`proposals`, `filters`, `depositDenom`, `connected`]),
...mapGetters([
`proposals`,
`filters`,
`depositDenom`,
`connected`,
`user`
]),
proposalList() {
return Object.values(this.proposals.proposals)
}
Expand All @@ -61,7 +67,11 @@ export default {
},
methods: {
onPropose() {
this.$refs.modalPropose.open()
if (this.user.signedIn) {
this.$refs.modalPropose.open()
} else {
this.$store.commit(`setModalSession`, true)
}
}
}
}
Expand Down
25 changes: 17 additions & 8 deletions app/src/renderer/components/governance/PageProposal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ export default {
`connected`,
`wallet`,
`votes`,
`config`
`config`,
`user`
]),
proposal() {
return this.proposals.proposals[this.proposalId]
Expand Down Expand Up @@ -250,15 +251,23 @@ export default {
},
methods: {
async onVote() {
this.$refs.modalVote.open()
// The error is already handled with notifyError in votes.js
await this.$store.dispatch(`getProposalVotes`, this.proposalId)
this.lastVote =
this.votes[this.proposalId] &&
this.votes[this.proposalId].find(e => e.voter === this.wallet.address)
if (this.user.signedIn) {
this.$refs.modalVote.open()
// The error is already handled with notifyError in votes.js
await this.$store.dispatch(`getProposalVotes`, this.proposalId)
this.lastVote =
this.votes[this.proposalId] &&
this.votes[this.proposalId].find(e => e.voter === this.wallet.address)
} else {
this.$store.commit(`setModalSession`, true)
}
},
onDeposit() {
this.$refs.modalDeposit.open()
if (this.user.signedIn) {
this.$refs.modalDeposit.open()
} else {
this.$store.commit(`setModalSession`, true)
}
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions app/src/renderer/components/staking/PageStaking.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ export default {
data: () => ({
query: ``,
tabs: [
{
displayName: `My Delegations`,
pathName: `My Delegations`
},
{
displayName: `Validators`,
pathName: `Validators`
Expand All @@ -34,7 +30,15 @@ export default {
]
}),
computed: {
...mapGetters([`connected`, `delegates`, `filters`])
...mapGetters([`connected`, `delegates`, `filters`, `user`])
},
mounted() {
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
if (this.user.signedIn) {
this.tabs.unshift({
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
displayName: `My Delegations`,
pathName: `My Delegations`
})
}
},
methods: {
...mapActions([`updateDelegates`])
Expand Down
25 changes: 17 additions & 8 deletions app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export default {
`config`,
`keybase`,
`liquidAtoms`,
`user`,
`wallet`,
`connected`
]),
Expand Down Expand Up @@ -315,19 +316,27 @@ export default {
this.showCannotModal = false
},
onDelegation() {
this.action = `delegate`
if (this.liquidAtoms > 0) {
this.$refs.delegationModal.open()
if (this.user.signedIn) {
this.action = `delegate`
if (this.liquidAtoms > 0) {
this.$refs.delegationModal.open()
} else {
this.showCannotModal = true
}
} else {
this.showCannotModal = true
this.$store.commit(`setModalSession`, true)
}
},
onUndelegation() {
this.action = `undelegate`
if (this.myBond.isGreaterThan(0)) {
this.$refs.undelegationModal.open()
if (this.user.signedIn) {
this.action = `undelegate`
if (this.myBond.isGreaterThan(0)) {
this.$refs.undelegationModal.open()
} else {
this.showCannotModal = true
}
} else {
this.showCannotModal = true
this.$store.commit(`setModalSession`, true)
}
},
delegationTargetOptions() {
Expand Down
3 changes: 0 additions & 3 deletions app/src/renderer/components/staking/TableValidators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ export default {
async mounted() {
Mousetrap.bind([`command+f`, `ctrl+f`], () => this.setSearch(true))
Mousetrap.bind(`esc`, () => this.setSearch(false))

// XXX temporary because querying the shares shows old shares after bonding
// this.updateDelegates()
},
methods: {
updateDelegates() {
Expand Down
15 changes: 14 additions & 1 deletion app/src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,21 @@ async function _startApp(
})

router.beforeEach((to, from, next) => {
if (from.fullPath !== to.fullPath && !store.getters.user.pauseHistory)
if (from.fullPath !== to.fullPath && !store.getters.user.pauseHistory) {
store.commit(`addHistory`, from.fullPath)
}
// redirect to session page if auth required
if (
[
`/staking/my-delegationg`,
`/wallet`,
`/wallet/send/:denom?`,
`/transactions`
].includes(to.path) &&
!store.state.user.signedIn
) {
store.commit(`setModalSession`, true)
}
next()
})

Expand Down
12 changes: 8 additions & 4 deletions app/src/renderer/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default [
{
path: `my-delegations`,
name: `My Delegations`,
component: require(`./components/staking/TabMyDelegations`).default
component: require(`./components/staking/TabMyDelegations`).default,
meta: { requiresAuth: true }
},
{
path: `validators`,
Expand All @@ -67,18 +68,21 @@ export default [
{
path: `/`,
name: `wallet`,
component: require(`./components/wallet/PageWallet`).default
component: require(`./components/wallet/PageWallet`).default,
meta: { requiresAuth: true }
},
{
path: `/wallet/send/:denom?`,
name: `send`,
props: true,
component: require(`./components/wallet/SendModal`).default
component: require(`./components/wallet/SendModal`).default,
meta: { requiresAuth: true }
},
{
path: `/transactions`,
name: `transactions`,
component: require(`./components/wallet/PageTransactions`).default
component: require(`./components/wallet/PageTransactions`).default,
meta: { requiresAuth: true }
},
{
path: `/network`,
Expand Down
7 changes: 4 additions & 3 deletions app/src/renderer/vuex/modules/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function({ node }) {
}, 1000)
}
},
async rpcSubscribe({ commit, dispatch }) {
async rpcSubscribe({ commit, dispatch, rootState }) {
const { node } = state.externals
if (state.stopConnecting) return

Expand Down Expand Up @@ -103,8 +103,9 @@ export default function({ node }) {
dispatch(`setLastHeader`, header)
}
)

dispatch(`walletSubscribe`)
if (rootState.user.signedIn) {
dispatch(`walletSubscribe`)
}
dispatch(`checkNodeHalted`)
dispatch(`pollRPCConnection`)
},
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/delegation.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export default ({ node }) => {
}
}
const actions = {
reconnected({ state, dispatch }) {
if (state.loading) {
reconnected({ state, dispatch, rootState }) {
if (state.loading && rootState.user.signedIn) {
dispatch(`getBondedDelegates`)
}
},
Expand Down
5 changes: 3 additions & 2 deletions app/src/renderer/vuex/modules/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ export default ({ node }) => {
// clear previous account state
rootState.transactions = JSON.parse(JSON.stringify(emptyState))
},
async reconnected({ state, dispatch }) {
if (state.loading) {
async reconnected({ state, dispatch, rootState }) {
// TODO: remove signedIn check when we support the option for setting a custom address for txs page
if (state.loading && rootState.user.signedIn) {
await dispatch(`getAllTxs`)
}
},
Expand Down
6 changes: 1 addition & 5 deletions app/src/renderer/vuex/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,9 @@ export default ({}) => {
},
async showInitialScreen({ state, dispatch, commit }) {
dispatch(`resetSessionData`)

await dispatch(`loadAccounts`)
commit(`setModalSessionState`, `welcome`)

state.externals.track(`pageview`, {
dl: `/session/welcome`
})
state.externals.track(`pageview`, { dl: `/` })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the thinking here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main page is not longer /session/welcome

},
async loadAccounts({ commit, state }) {
state.loading = true
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default ({ node }) => {
}

const actions = {
async reconnected({ state, dispatch }) {
if (state.loading && state.address) {
async reconnected({ rootState, state, dispatch }) {
if (state.loading && state.address && rootState.user.signedIn) {
await dispatch(`queryWalletBalances`)
}
},
Expand Down
Loading