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

refactor: rename constants as naming convention #267

Merged
merged 1 commit into from
Apr 25, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next'

import { MainActions, actionCreators } from 'containers/MainContent/reducer'
import { Network } from 'contexts/NeuronWallet'
import { UnremovableNetwork } from 'utils/const'
import { UNREMOVABLE_NETWORK } from 'utils/const'

const RemoveNetworkDialog = ({
isChecked,
Expand All @@ -29,7 +29,7 @@ const RemoveNetworkDialog = ({
<Card.Body>
{`Network of name: ${network.name}, address: ${network.remote} will be removed.`}
{isChecked ? (
<p>{`It's the active network, removing it will make reconnect to ${UnremovableNetwork}`}</p>
<p>{`It's the active network, removing it will make reconnect to ${UNREMOVABLE_NETWORK}`}</p>
) : null}
</Card.Body>
<Card.Footer className="text-muted">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Network } from 'contexts/NeuronWallet'
import { networksCall } from 'services/UILayer'

import { Message, MAX_NETWORK_NAME_LENGTH, UnremovableNetworkId, UnremovableNetwork } from 'utils/const'
import { Message, MAX_NETWORK_NAME_LENGTH, UNREMOVABLE_NETWORK_ID, UNREMOVABLE_NETWORK } from 'utils/const'
import i18n from 'utils/i18n'
import { MainActions } from '../reducer'

Expand Down Expand Up @@ -71,10 +71,10 @@ export default {
},
deleteNetwork: (id?: string) => {
if (id === undefined) throw new Error('No network id found')
if (id === UnremovableNetworkId) {
if (id === UNREMOVABLE_NETWORK_ID) {
return {
type: MainActions.ErrorMessage,
payload: { networks: i18n.t(`messages.is-unremovable`, { target: UnremovableNetwork }) },
payload: { networks: i18n.t(`messages.is-unremovable`, { target: UNREMOVABLE_NETWORK }) },
}
}
networksCall.delete(id)
Expand Down
15 changes: 2 additions & 13 deletions packages/neuron-ui/src/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,8 @@ export const MAX_NETWORK_NAME_LENGTH = 28
export const ADDRESS_LENGTH = 40
export const PAGE_SIZE = 15
export const EXPLORER = 'http://localhost:3000'
export const UnremovableNetwork = 'Testnet'
export const UnremovableNetworkId = '0'

export const DEFAULT_NETWORKS = [
{
name: 'Testnet',
remote: 'http://localhost:8114',
},
{
name: 'Localhost',
remote: 'http://localhost:8114',
},
]
export const UNREMOVABLE_NETWORK = 'Testnet'
export const UNREMOVABLE_NETWORK_ID = '0'

export enum ConnectStatus {
Online = 'online',
Expand Down