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

About Popup #907

Merged
merged 10 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Configs for the gaia-6002 testnet @faboweb
* Introduced addressbook to store found peers and to select nodes round robin @faboweb
* Tutorial how to start a local node @faboweb
* Added versions to Preference Page @okwme

### Changes

Expand Down
43 changes: 40 additions & 3 deletions app/src/renderer/components/common/PagePreferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
tm-page(title="Preferences")
div(slot="menu"): tool-bar

tm-modal(:close="setAbout", v-if="showAbout")
div(slot="title") About Cosmos Voyager
.about-popup
img( src="~@/assets/images/onboarding/step-0.png")
div Voyager v{{versionVoyager}}
div Cosmos SDK v{{versionSDK}}

tm-part(title='Settings')
tm-list-item(type="field" title="Select network to connect to")
tm-field#select-network(
Expand Down Expand Up @@ -41,12 +48,20 @@ tm-page(title="Preferences")
type='button'
@click.native="signOut"
value='Sign Out')
tm-part(title="About")
tm-list-item(type="field"
title="Version Information")
tm-btn#toggle-onboarding(
@click.native="setAbout"
value="Show Versions"
icon="info")
</template>

<script>
import { mapGetters } from "vuex"
import { mapGetters, mapMutations } from "vuex"
import { TmListItem, TmBtn, TmPage, TmPart, TmField } from "@tendermint/ui"
import ToolBar from "common/TmToolBar"
import TmModal from "common/TmModal"

export default {
name: "page-preferences",
Expand All @@ -56,12 +71,25 @@ export default {
TmListItem,
TmPage,
TmPart,
ToolBar
ToolBar,
TmModal
},
computed: {
...mapGetters(["user", "themes", "onboarding", "mockedConnector"])
...mapGetters([
"user",
"themes",
"onboarding",
"mockedConnector",
"config"
]),
showAbout() {
return this.config.showAbout
}
},

data: () => ({
versionVoyager: null,
versionSDK: null,
themeSelectActive: null,
themeSelectOptions: [
{
Expand All @@ -88,8 +116,11 @@ export default {
mounted() {
this.networkSelectActive = this.mockedConnector ? "mock" : "live"
this.themeSelectActive = this.themes.active
this.versionSDK = process.env.GAIA_VERSION.split("-").shift()
this.versionVoyager = process.env.VOYAGER_VERSION
},
methods: {
...mapMutations(["setAbout"]),
signOut() {
this.$store.dispatch("signOut")
this.$store.commit("notifySignOut")
Expand Down Expand Up @@ -121,3 +152,9 @@ export default {
}
}
</script>
<style lang="stylus">
.about-popup
text-align center
img
max-width 150px
</style>
2 changes: 1 addition & 1 deletion app/src/renderer/components/common/TmModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="pug">
div(:class='cssClass' @click="close()")
div(:class='cssClass' @click.self="close()")
.tm-modal-container
header.tm-modal-header
.tm-modal-icon(v-if='icon')
Expand Down
9 changes: 9 additions & 0 deletions app/src/renderer/vuex/modules/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default ({ commit }) => {
maxValidators: 100,
activeMenu: "",
desktop: false,
showAbout: false,
devMode:
process.env.PREVIEW !== undefined
? JSON.parse(process.env.PREVIEW)
Expand All @@ -24,6 +25,14 @@ export default ({ commit }) => {
}
}
const mutations = {
setAbout(state, value) {
// when triggered from a button the click event is value, when triggered from the modal the value is undefined
// value is present so it can also be explicit as a replacement from the electron menu
state.showAbout =
typeof value === "object" || typeof value === "undefined"
? !state.showAbout
: value
},
setDevMode(state, value) {
state.devMode = value
},
Expand Down
11 changes: 9 additions & 2 deletions tasks/runner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict"

const fs = require("fs")
const config = require("../app/src/config")
const spawn = require("child_process").spawn
const path = require("path")
Expand Down Expand Up @@ -66,11 +66,18 @@ module.exports = async function(networkPath) {
console.log(
`${BLUE}Starting electron...\n (network path: ${networkPath})\n${END}`
)
const packageJSON = require("../package.json")
const voyagerVersion = packageJSON.version
const gaiaVersion = fs
.readFileSync(networkPath + "basecoindversion.txt")
.toString()
let env = Object.assign(
{},
{
NODE_ENV: "development",
COSMOS_NETWORK: networkPath
COSMOS_NETWORK: networkPath,
GAIA_VERSION: gaiaVersion,
VOYAGER_VERSION: voyagerVersion
},
process.env
)
Expand Down
3 changes: 3 additions & 0 deletions test/unit/helpers/genesis_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import fs from "fs-extra"
let testRoot = "./test/unit/tmp/test_root/"

function mockGenesis() {
process.env.COSMOS_NETWORK = "./networks/gaiaiaiaiaiaia/"
Copy link
Collaborator

Choose a reason for hiding this comment

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

XD

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😜

process.env.GAIA_VERSION = "1.2.3-asdf"
process.env.VOYAGER_VERSION = "3.6.9"
process.env.COSMOS_HOME = testRoot
fs.ensureFileSync(testRoot + "genesis.json")
fs.writeFileSync(
Expand Down
43 changes: 43 additions & 0 deletions test/unit/specs/components/common/PagePreferences.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,49 @@ describe("PagePreferences", () => {
it("switches mocked mode", () => {
wrapper.vm.networkSelectActive = "mock"
wrapper.vm.setMockedConnector()
expect(wrapper.vm.mockedConnector).toBe(true)
expect(store.dispatch).toHaveBeenCalledWith("setMockedConnector", true)

wrapper.vm.networkSelectActive = "live"
wrapper.vm.setMockedConnector()
expect(wrapper.vm.mockedConnector).toBe(false)
expect(store.dispatch).toHaveBeenCalledWith("setMockedConnector", true)

// dont update without switch
wrapper.vm.setMockedConnector()
expect(wrapper.vm.mockedConnector).toBe(false)
})

it("switches mocked mode again", async () => {
let test = instance.mount(PagePreferences, {
getters: {
mockedConnector: () => true
}
})
wrapper = test.wrapper
store = test.store
await store.dispatch("signIn", {
account: "default",
password: "1234567890"
})
wrapper.vm.networkSelectActive = "live"
wrapper.vm.setMockedConnector()
expect(store.dispatch).toHaveBeenCalledWith("setMockedConnector", false)
})

it("shows versions", () => {
expect(wrapper.vm.$el).toMatchSnapshot()
wrapper.vm.setAbout()
wrapper.update()
expect(store.state.config.showAbout).toBe(true)
expect(wrapper.vm.$el.outerHTML).toContain(
"Voyager v" + wrapper.vm.versionVoyager
)
expect(wrapper.vm.$el.outerHTML).toContain(
"Cosmos SDK v" + wrapper.vm.versionSDK.split("-").shift()
)
expect(wrapper.vm.$el).toMatchSnapshot()
wrapper.vm.setAbout(false)
expect(store.state.config.showAbout).toBe(false)
})
})
Loading