(refactor) file structure

This commit is contained in:
Gabriel Rodriguez Alsina 2018-12-17 15:09:59 -03:00
parent f36d0daffd
commit b4b34cf4a1
28 changed files with 55 additions and 35 deletions

View File

@ -1,13 +1,13 @@
//import DevTools from 'mobx-react-devtools'
import './assets/App.css'
import Loading from './Loading'
// import Loading from './components/Loading'
import React, { Component } from 'react'
import { Header, Ballots, NewBallot, Settings, Footer } from './components'
import { Header, Ballots, NewBallot, Settings, Footer, Loading } from './components'
import { Route } from 'react-router-dom'
import { inject, observer } from 'mobx-react'
import swal from 'sweetalert2'
import { messages } from './messages'
import { constants } from './constants'
import { messages } from './utils/messages'
import { constants } from './utils/constants'
@inject('commonStore', 'contractsStore')
@observer

View File

@ -2,8 +2,8 @@ import React from 'react'
import moment from 'moment'
import { observable, action, computed } from 'mobx'
import { inject, observer } from 'mobx-react'
import { messages } from '../messages'
import { sendTransactionByVotingKey } from '../helpers'
import { messages } from '../utils/messages'
import { sendTransactionByVotingKey } from '../utils/helpers'
import swal from 'sweetalert2'
const ACCEPT = 1
@ -91,6 +91,8 @@ export class BallotCard extends React.Component {
return 'The funds were burnt.'
case 4:
return 'The funds were frozen.'
default:
return 'Unknown error'
}
}
return ''

View File

@ -1,7 +1,7 @@
import React from 'react'
import { observable, action } from 'mobx'
import { inject, observer } from 'mobx-react'
import { constants } from '../constants'
import { constants } from '../utils/constants'
import moment from 'moment'
@inject('ballotStore', 'contractsStore')

View File

@ -2,7 +2,7 @@ import React from 'react'
import moment from 'moment'
import { Link } from 'react-router-dom'
import Socials from './Socials.jsx'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export const Footer = ({ netId }) => {
const footerClassName = netId in constants.NETWORKS && constants.NETWORKS[netId].TESTNET ? 'sokol' : ''

View File

@ -7,7 +7,7 @@ import menuOpenIconBase from '../assets/images/icons/icon-close.svg'
import menuOpenIconSokol from '../assets/images/icons/icon-close-sokol.svg'
import NavigationLinks from './NavigationLinks.jsx'
import MobileMenuLinks from './MobileMenuLinks.jsx'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export const Header = ({ netId, baseRootPath, navigationData, showMobileMenu, onMenuToggle }) => {
const thisIsTestnet = netId in constants.NETWORKS && constants.NETWORKS[netId].TESTNET

View File

@ -1,5 +1,5 @@
import React from 'react'
import { constants } from './constants'
import { constants } from '../utils/constants'
const styles = netId => {
const core = {
@ -15,7 +15,8 @@ const styles = netId => {
return core
}
const Loading = ({ netId }) => (
export const Loading = ({ netId }) => (
<div className="loading-container" style={styles(netId)}>
<div className="loading">
<div className="loading-i" />
@ -27,4 +28,3 @@ const Loading = ({ netId }) => (
</div>
</div>
)
export default Loading

View File

@ -8,9 +8,9 @@ import { BallotKeysMetadata } from './BallotKeysMetadata.jsx'
import { BallotMinThresholdMetadata } from './BallotMinThresholdMetadata.jsx'
import { BallotProxyMetadata } from './BallotProxyMetadata.jsx'
import { BallotEmissionFundsMetadata } from './BallotEmissionFundsMetadata.jsx'
import { messages } from '../messages'
import { constants } from '../constants'
import { sendTransactionByVotingKey } from '../helpers'
import { messages } from '../utils/messages'
import { constants } from '../utils/constants'
import { sendTransactionByVotingKey } from '../utils/helpers'
@inject('commonStore', 'ballotStore', 'validatorStore', 'contractsStore', 'routing', 'ballotsStore')
@observer
export class NewBallot extends React.Component {
@ -368,7 +368,7 @@ export class NewBallot extends React.Component {
menuItemActive = ballotType => {
const { ballotStore } = this.props
if (ballotType == ballotStore.ballotType) {
if (ballotType === ballotStore.ballotType) {
return 'ballot-types-i ballot-types-i_active'
} else {
return 'ballot-types-i'

View File

@ -2,7 +2,7 @@ import React from 'react'
import { inject, observer } from 'mobx-react'
import Select from 'react-select'
import PlacesAutocomplete, { geocodeByAddress } from 'react-places-autocomplete'
import { constants } from '../constants'
import { constants } from '../utils/constants'
@inject('validatorStore', 'ballotStore')
@observer

View File

@ -1,5 +1,6 @@
export { Ballots } from './Ballots.jsx'
export { Footer } from './Footer.jsx'
export { Header } from './Header.jsx'
export { Loading } from './Loading.jsx'
export { NewBallot } from './NewBallot.jsx'
export { Settings } from './Settings.jsx'
export { Footer } from './Footer.jsx'

View File

@ -1,6 +1,6 @@
import { networkAddresses } from './addresses'
import helpers from './helpers'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export default class BallotsStorage {
async init({ web3, netId }) {

View File

@ -1,6 +1,6 @@
import { networkAddresses } from './addresses'
import helpers from './helpers'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export default class KeysManager {
async init({ web3, netId }) {

View File

@ -1,6 +1,6 @@
import { networkAddresses } from './addresses'
import helpers from './helpers'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export default class PoaConsensus {
async init({ web3, netId }) {

View File

@ -1,6 +1,6 @@
import { networkAddresses } from './addresses'
import helpers from './helpers'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export default class ProxyStorage {
async init({ web3, netId }) {

View File

@ -1,7 +1,7 @@
import { networkAddresses } from './addresses'
import helpers from './helpers'
import { toAscii } from '../helpers'
import { constants } from '../constants'
import { toAscii } from '../utils/helpers'
import { constants } from '../utils/constants'
export default class ValidatorMetadata {
async init({ web3, netId }) {

View File

@ -1,6 +1,6 @@
import { networkAddresses } from './addresses'
import helpers from './helpers'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export default class VotingToChangeKeys {
async init({ web3, netId }) {

View File

@ -1,6 +1,6 @@
import { networkAddresses } from './addresses'
import helpers from './helpers'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export default class VotingToChangeMinThreshold {
async init({ web3, netId }) {

View File

@ -1,6 +1,6 @@
import { networkAddresses } from './addresses'
import helpers from './helpers'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export default class VotingToChangeProxy {
async init({ web3, netId }) {

View File

@ -1,6 +1,6 @@
import { networkAddresses } from './addresses'
import helpers from './helpers'
import { constants } from '../constants'
import { constants } from '../utils/constants'
export default class VotingToManageEmissionFunds {
async init({ web3, netId }) {

View File

@ -1,5 +1,5 @@
import { constants } from '../constants'
import { messages } from '../messages'
import { constants } from '../utils/constants'
import { messages } from '../utils/messages'
import swal from 'sweetalert2'
function addressesURL(branch) {

View File

@ -2,7 +2,7 @@ import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import { Router, Route } from 'react-router-dom'
import App from './App'
import registerServiceWorker from './registerServiceWorker'
import registerServiceWorker from './utils/registerServiceWorker'
import { Provider } from 'mobx-react'
import { RouterStore, syncHistoryWithStore } from 'mobx-react-router'
import commonStore from './stores/CommonStore'
@ -12,10 +12,10 @@ import ballotsStore from './stores/BallotsStore'
import contractsStore from './stores/ContractsStore'
import { getContractsAddresses } from './contracts/addresses'
import swal from 'sweetalert2'
import getWeb3 from './getWeb3'
import getWeb3 from './utils/getWeb3'
import 'babel-polyfill'
import createBrowserHistory from 'history/createBrowserHistory'
import { constants } from './constants'
import { constants } from './utils/constants'
const browserHistory = createBrowserHistory()
const routingStore = new RouterStore()

View File

@ -1,6 +1,6 @@
import { observable, computed, action, toJS } from 'mobx'
import moment from 'moment'
import { constants } from '../constants'
import { constants } from '../utils/constants'
class BallotStore {
BallotType = {

View File

@ -18,7 +18,7 @@ import { BallotKeysCard } from '../components/BallotKeysCard.jsx'
import { BallotMinThresholdCard } from '../components/BallotMinThresholdCard.jsx'
import { BallotProxyCard } from '../components/BallotProxyCard.jsx'
import { BallotEmissionFundsCard } from '../components/BallotEmissionFundsCard.jsx'
import { constants } from '../constants'
import { constants } from '../utils/constants'
import 'babel-polyfill'

17
src/utils/utils.js Normal file
View File

@ -0,0 +1,17 @@
import { constants } from './constants'
export const isTestnet = netId => {
return netId in constants.NETWORKS && constants.NETWORKS[netId].TESTNET
}
export const isValidNetwork = netId => {
return netId in constants.NETWORKS
}
export const getNetworkBranch = netId => {
return constants.NETWORKS[netId].BRANCH
}
export const getNetworkName = netId => {
return constants.NETWORKS[netId].NAME
}