feat: enable setting devMode from queryParams (#254)

* feat: enable setting devMode from queryParams

* docs: update dev mode docs

* docs: move dev mode comment

* docs: move dev mode comment
This commit is contained in:
Cafe137
2021-11-23 13:39:47 +01:00
committed by GitHub
parent 49350b0570
commit 844383bea7
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ npm start
The Bee Dashboard runs in development mode on [http://localhost:3031/](http://localhost:3031/) The Bee Dashboard runs in development mode on [http://localhost:3031/](http://localhost:3031/)
> Setting `REACT_APP_DEV_MODE=1` environment variable loosens some checks. This makes it possible to develop Bee Dashboard without having connected peers and chequebook properly set up, effectively supporting the dev mode of Bee itself. > Setting the `REACT_APP_DEV_MODE=1` environment variable, or opening Bee Dashboard with the query string `?devMode=1` loosens some checks. This makes it possible to develop Bee Dashboard without having connected peers and chequebook properly set up, effectively supporting the dev mode of Bee itself.
## Contribute ## Contribute
+6 -3
View File
@@ -51,6 +51,8 @@ interface ContextInterface {
refresh: () => Promise<void> refresh: () => Promise<void>
} }
const startedInDevMode = window.location.search.includes('devMode=1')
const initialValues: ContextInterface = { const initialValues: ContextInterface = {
status: { status: {
all: false, all: false,
@@ -102,6 +104,8 @@ function getStatus(
chequebookBalance: ChequebookBalance | null, chequebookBalance: ChequebookBalance | null,
error: Error | null, error: Error | null,
): Status { ): Status {
// FIXME: `devMode` is a temporary workaround to be able to develop with only one node
const devMode = startedInDevMode || Boolean(process.env.REACT_APP_DEV_MODE)
const status = { const status = {
version: Boolean( version: Boolean(
debugApiHealth && debugApiHealth &&
@@ -112,13 +116,12 @@ function getStatus(
blockchainConnection: Boolean(nodeAddresses?.ethereum), blockchainConnection: Boolean(nodeAddresses?.ethereum),
debugApiConnection: Boolean(debugApiHealth?.status === 'ok'), debugApiConnection: Boolean(debugApiHealth?.status === 'ok'),
apiConnection: apiHealth, apiConnection: apiHealth,
// FIXME: `REACT_APP_DEV_MODE` is a temporary workaround to be able to develop with only one node topology: Boolean(topology?.connected && topology?.connected > 0) || devMode,
topology: Boolean(topology?.connected && topology?.connected > 0) || Boolean(process.env.REACT_APP_DEV_MODE),
chequebook: chequebook:
(Boolean(chequebookAddress?.chequebookAddress) && (Boolean(chequebookAddress?.chequebookAddress) &&
chequebookBalance !== null && chequebookBalance !== null &&
chequebookBalance?.totalBalance.toBigNumber.isGreaterThan(0)) || chequebookBalance?.totalBalance.toBigNumber.isGreaterThan(0)) ||
Boolean(process.env.REACT_APP_DEV_MODE), devMode,
} }
return { ...status, all: !error && Object.values(status).every(v => v) } return { ...status, all: !error && Object.values(status).every(v => v) }