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

new flag: devMode, production tweaks #186

Merged
merged 11 commits into from
Dec 7, 2017
5 changes: 2 additions & 3 deletions app/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,14 @@ function createWindow () {
mainWindow = new BrowserWindow({
minWidth: 320,
minHeight: 480,
width: 1200,
height: 800,
width: 1024,
height: 768,
center: true,
title: 'Cosmos',
darkTheme: true,
titleBarStyle: 'hidden',
webPreferences: { webSecurity: false }
})
// mainWindow.maximize()

mainWindow.loadURL(winURL + '?node=' + nodeIP)
if (DEV || process.env.COSMOS_DEVTOOLS) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/components/common/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export default {
let w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
if (w >= 1024) {
this.close()
this.$store.commit('SET_CONFIG_DESKTOP', true)
this.$store.commit('setConfigDesktop', true)
return
}
this.$store.commit('SET_CONFIG_DESKTOP', false)
this.$store.commit('setConfigDesktop', false)
}
},
mounted () {
Expand Down
10 changes: 5 additions & 5 deletions app/src/renderer/components/common/AppMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ menu.app-menu
part(title='Wallet')
list-item(to="/" exact @click.native="close" title="Balance")
list-item(to="/wallet/send" exact @click.native="close" title="Send")
list-item(to="/wallet/transactions" exact @click.native="close" title="Transactions")
part(title='Governance')
list-item(to="/wallet/transactions" exact @click.native="close" title="Transactions" v-if="config.devMode")
part(title='Governance' v-if="config.devMode")
list-item(to="/proposals" exact @click.native="close" title="Proposals")
part(title='Stake')
part(title='Stake' v-if="config.devMode")
list-item(to="/staking" exact @click.native="close" title="Delegates")
part(title='Monitor')
part(title='Monitor' v-if="config.devMode")
list-item(to="/blockchain" exact @click.native="close" title="Blockchain")
list-item(to="/validators" exact @click.native="close" title="Validators"
v-bind:class="{ 'active': isValidatorPage }")
Expand All @@ -32,7 +32,7 @@ export default {
UserPane
},
computed: {
...mapGetters(['proposals', 'validators']),
...mapGetters(['proposals', 'validators', 'config']),
proposalAlerts () {
return this.proposals
.filter(p => p.flags.read === false).length
Expand Down
13 changes: 6 additions & 7 deletions app/src/renderer/components/common/NiListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,19 @@ export default {
&:last-child
border-bottom: none

&:hover
.ni-li-title
color bright

&:first-child
height 3rem + px

&.ni-li-link
&:hover
background: app-bg-hover

.ni-li-label
cursor pointer

.ni-li-title
color bright

&:before
content ''
display block
Expand Down Expand Up @@ -167,9 +169,6 @@ export default {
padding 0 1rem
flex-flow column nowrap

&:hover
cursor: pointer

.ni-li-title
color txt
line-height 1.25
Expand Down
11 changes: 10 additions & 1 deletion app/src/renderer/components/common/NiSession.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,24 @@ export default {
SessionHardware
},
computed: {
...mapGetters(['config']),
...mapGetters(['config', 'config']),
active () { return this.config.modals.session.active }
},
mounted () {
if (!this.config.devMode) {
this.$store.commit('setModalSession', true)
}
}
}
</script>

<style lang="stylus">
@import '~variables'

.ni-session-wrapper
position relative
z-index 1000

.ni-field-checkbox
display flex
flex-flow row nowrap
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/components/common/NiSessionHardware.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
setStatus (value) { this.status = value },
onSubmit () {
this.$store.commit('setModalSession', false)
this.$store.commit('notify', { title: 'Signed In (Hardware)', body: 'TODO: REPLACE ME' })
this.$store.commit('notify', { title: 'Welcome back!', body: 'You are now signed in to your Cosmos account.' })
this.$store.commit('setSignedIn', true)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/components/common/NiSessionSignIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default {
this.$v.$touch()
if (this.$v.$error) return
this.$store.commit('setModalSession', false)
this.$store.commit('notify', { title: 'Signed In (Seed)', body: 'TODO: REPLACE ME' })
this.$store.commit('notify', { title: 'Welcome back!', body: 'You are now signed in to your Cosmos account.' })
this.$store.commit('setSignedIn', true)
}
},
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/components/common/NiSessionSignUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default {
this.$v.$touch()
if (this.$v.$error) return
this.$store.commit('setModalSession', false)
this.$store.commit('notify', { title: 'Signed Up', body: 'TODO: REPLACE ME' })
this.$store.commit('notify', { title: 'Welcome!', body: 'Your account has been created.' })
this.$store.commit('setSignedIn', true)
}
},
Expand Down
5 changes: 5 additions & 0 deletions app/src/renderer/components/common/NiSessionWelcome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@
icon="short_text"
title="Sign in with seed")
list-item(
v-if="config.devMode"
@click.native="setState('hardware')"
icon="usb"
title="Sign in with hardware")
.ni-session-footer
</template>

<script>
import {mapGetters} from 'vuex'
import ListItem from 'common/NiListItem'
export default {
name: 'ni-session-welcome',
components: {
ListItem
},
computed: {
...mapGetters(['config'])
},
methods: {
setState (value) { this.$store.commit('setModalSessionState', value) }
}
Expand Down
8 changes: 6 additions & 2 deletions app/src/renderer/components/common/NiUserPane.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<template lang="pug">
list-item.ni-li-user(
v-if="user.signedIn"
v-if="user.signedIn && config.devMode"
type="link"
to="/profile"
@click.native="close"
icon="face"
title="CosmosUser01")
list-item.ni-li-user(
v-else-if="user.signedIn"
icon="mood"
title="Signed In")
list-item.ni-li-user(
v-else
@click.native="openSession"
Expand All @@ -23,7 +27,7 @@ export default {
ListItem
},
computed: {
...mapGetters(['user'])
...mapGetters(['user', 'config'])
},
methods: {
close () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang='pug'>
.modal-blockchain(v-if='config.blockchainSelect' @click='close($event)')
.modal-blockchain(v-if='config.modals.blockchain.active' @click='close($event)')
.modal-blockchain-container: blockchain-select
</template>

Expand All @@ -17,7 +17,7 @@ export default {
methods: {
close (event) {
if (!event.target.classList.contains('ni-field-select')) {
this.$store.commit('SET_CONFIG_BLOCKCHAIN_SELECT', false)
this.$store.commit('setModalBlockchain', false)
// console.log('closing it bc', event.target)
} else {
// console.log('clicked on select, not doing anything')
Expand All @@ -27,7 +27,7 @@ export default {
watch: {
'blockchain.blockchainName' (val, oldVal) {
// console.log('blockchain name changed, closing modal')
this.$store.commit('SET_CONFIG_BLOCKCHAIN_SELECT', false)
this.$store.commit('setModalBlockchain', false)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/components/monitor/PageBlockchain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ page(title='Blockchain')
i.material-icons search
.label Search
a(@click='toggleBlockchainSelect')
i.material-icons(v-if='!config.blockchainSelect') filter_list
i.material-icons(v-if='!config.modals.blockchain.active') filter_list
i.material-icons(v-else='') close
.label Switch Blockchain

Expand Down Expand Up @@ -93,7 +93,7 @@ export default {
return moment(ms / 1000000).format('HH:mm:ss.SSS')
},
toggleBlockchainSelect () {
this.$store.commit('SET_CONFIG_BLOCKCHAIN_SELECT', !this.config.blockchainSelect)
this.$store.commit('setModalBlockchain', !this.config.modals.blockchain.active)
}
}
}
Expand Down
22 changes: 7 additions & 15 deletions app/src/renderer/vuex/modules/config.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
export default ({ commit, basecoin }) => {
const state = {
INVITE_TOKENS_MAX: 10,
CANDIDATE: {
KEYBASE_MIN: 2,
KEYBASE_MAX: 16,
DESCRIPTION_MIN: 20,
DESCRIPTION_MAX: 40000,
COMMISSION_MIN: 0,
COMMISSION_MAX: 99,
SELF_BOND_MIN: 100,
SELF_BOND_MAX: 1e10
},
activeMenu: '',
blockchainSelect: false,
desktop: false,
devMode: true,
modals: {
help: {
active: false
},
session: {
active: false,
state: 'welcome'
},
blockchain: {
active: false
}
}
}
Expand All @@ -36,13 +28,13 @@ export default ({ commit, basecoin }) => {
setModalSessionState (state, value) {
state.modals.session.state = value
},
SET_CONFIG_BLOCKCHAIN_SELECT (state, value) {
state.blockchainSelect = value
setModalBlockchain (state, value) {
state.modals.blockchain.active = value
},
setActiveMenu (state, value) {
state.activeMenu = value
},
SET_CONFIG_DESKTOP (state, value) {
setConfigDesktop (state, value) {
state.desktop = value
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/NISessionSignIn.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('NISessionSignIn', () => {
}})
wrapper.vm.onSubmit()
expect(store.commit.mock.calls[1][0]).toEqual('notify')
expect(store.commit.mock.calls[1][1].title.toLowerCase()).toContain('signed in')
expect(store.commit.mock.calls[1][1].title.toLowerCase()).toContain('welcome back!')
expect(store.commit.mock.calls[2]).toEqual(['setSignedIn', true])
})

Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/NISessionSignUp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('NISessionSignUp', () => {
}})
wrapper.vm.onSubmit()
expect(store.commit.mock.calls[1][0]).toEqual('notify')
expect(store.commit.mock.calls[1][1].title.toLowerCase()).toContain('signed up')
expect(store.commit.mock.calls[1][1].title.toLowerCase()).toContain('welcome!')
expect(store.commit.mock.calls[2]).toEqual(['setSignedIn', true])
})

Expand Down
7 changes: 5 additions & 2 deletions test/unit/specs/NISessionWelcome.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ const localVue = createLocalVue()
localVue.use(Vuex)

describe('NISessionWelcome', () => {
let wrapper, store
let wrapper, store, getters

beforeEach(() => {
store = new Vuex.Store()
getters = {
config: () => ({ devMode: true })
}
store = new Vuex.Store({ getters })
wrapper = mount(NISessionWelcome, {
localVue,
store
Expand Down