Skip to content

Commit 1d2f7a7

Browse files
committed
Add config variable for skipping the graph
This is mostly useful if we want to restrict a deployment to display only a few layers.
1 parent dfc1264 commit 1d2f7a7

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ REACT_APP_STAGING_URLS=https://explorer.stg.oasis.io
2727
REACT_APP_SHOW_BUILD_BANNERS=true
2828
# REACT_APP_FIXED_NETWORK=testnet
2929
# REACT_APP_FIXED_LAYER=sapphire
30+
# REACT_APP_SKIP_GRAPH=true
3031
REACT_APP_SHOW_FIAT_VALUES=true

.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ REACT_APP_STAGING_URLS=https://explorer.stg.oasis.io
2222
REACT_APP_SHOW_BUILD_BANNERS=true
2323
# REACT_APP_FIXED_NETWORK=testnet
2424
# REACT_APP_FIXED_LAYER=sapphire
25+
# REACT_APP_SKIP_GRAPH=true
2526
REACT_APP_SHOW_FIAT_VALUES=true

src/app/utils/route-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { isLayerHidden } from '../../types/layers'
1111

1212
export const fixedNetwork = process.env.REACT_APP_FIXED_NETWORK as Network | undefined
1313
export const fixedLayer = process.env.REACT_APP_FIXED_LAYER as Layer | undefined
14+
export const skipGraph = !!fixedLayer || !!(process.env.REACT_APP_SKIP_GRAPH as boolean | undefined)
1415

1516
export type ScopeFreedom =
1617
| 'network' // We can select only the network

src/routes.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
fixedNetwork,
2424
fixedLayer,
2525
RouteUtils,
26+
skipGraph,
2627
} from './app/utils/route-utils'
2728
import { RoutingErrorPage } from './app/pages/RoutingErrorPage'
2829
import { ThemeByNetwork, withDefaultTheme } from './app/components/ThemeByNetwork'
@@ -65,7 +66,7 @@ const NetworkSpecificPart = () => (
6566
)
6667

6768
/**
68-
* In case of being restricted to a specific layer, jump to a dashboard
69+
* In case of being restricted to a specific layer or layers, jump to a dashboard
6970
*
7071
* This should be rendered on the landing page, since we don't want the opening graph.
7172
*/
@@ -75,8 +76,11 @@ const RedirectToDashboard: FC = () => {
7576
useEffect(() =>
7677
navigate(
7778
RouteUtils.getDashboardRoute({
78-
network: fixedNetwork ?? RouteUtils.getEnabledNetworksForLayer(fixedLayer!)[0]!,
79-
layer: fixedLayer!,
79+
network:
80+
fixedNetwork ?? fixedLayer
81+
? RouteUtils.getEnabledNetworksForLayer(fixedLayer)[0]!
82+
: RouteUtils.getEnabledScopes()[0].network,
83+
layer: fixedLayer ?? RouteUtils.getEnabledScopes()[0].layer,
8084
}),
8185
),
8286
)
@@ -99,7 +103,7 @@ export const routes: RouteObject[] = [
99103
children: [
100104
{
101105
path: '/',
102-
element: fixedLayer ? <RedirectToDashboard /> : withDefaultTheme(<HomePage />, true),
106+
element: skipGraph ? <RedirectToDashboard /> : withDefaultTheme(<HomePage />, true),
103107
},
104108
...(!!fixedNetwork && !!fixedLayer
105109
? []

src/types/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ declare global {
2828
REACT_APP_STAGING_URLS?: string
2929
REACT_APP_FIXED_NETWORK?: string
3030
REACT_APP_FIXED_LAYER?: string
31+
REACT_APP_SKIP_GRAPH?: string
3132
REACT_APP_SHOW_FIAT_VALUES: 'true' | 'false'
3233
}
3334
}

0 commit comments

Comments
 (0)