Skip to content

Commit

Permalink
Add config variable for skipping the graph
Browse files Browse the repository at this point in the history
This is mostly useful if we want to restrict a deployment
to display only a few layers.
  • Loading branch information
csillag committed Jun 3, 2024
1 parent d1dc7e9 commit b372e50
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ REACT_APP_STAGING_URLS=https://explorer.stg.oasis.io
REACT_APP_SHOW_BUILD_BANNERS=true
# REACT_APP_FIXED_NETWORK=testnet
# REACT_APP_FIXED_LAYER=sapphire
# REACT_APP_SKIP_GRAPH=true
REACT_APP_SHOW_FIAT_VALUES=true
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ REACT_APP_STAGING_URLS=https://explorer.stg.oasis.io
REACT_APP_SHOW_BUILD_BANNERS=true
# REACT_APP_FIXED_NETWORK=testnet
# REACT_APP_FIXED_LAYER=sapphire
# REACT_APP_SKIP_GRAPH=true
REACT_APP_SHOW_FIAT_VALUES=true
1 change: 1 addition & 0 deletions src/app/utils/route-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { isLayerHidden } from '../../types/layers'

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

export type ScopeFreedom =
| 'network' // We can select only the network
Expand Down
12 changes: 8 additions & 4 deletions src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
fixedNetwork,
fixedLayer,
RouteUtils,
skipGraph,
} from './app/utils/route-utils'
import { RoutingErrorPage } from './app/pages/RoutingErrorPage'
import { ThemeByNetwork, withDefaultTheme } from './app/components/ThemeByNetwork'
Expand Down Expand Up @@ -65,7 +66,7 @@ const NetworkSpecificPart = () => (
)

/**
* In case of being restricted to a specific layer, jump to a dashboard
* In case of being restricted to a specific layer or layers, jump to a dashboard
*
* This should be rendered on the landing page, since we don't want the opening graph.
*/
Expand All @@ -75,8 +76,11 @@ const RedirectToDashboard: FC = () => {
useEffect(() =>
navigate(
RouteUtils.getDashboardRoute({
network: fixedNetwork ?? RouteUtils.getEnabledNetworksForLayer(fixedLayer!)[0]!,
layer: fixedLayer!,
network:
fixedNetwork ?? fixedLayer
? RouteUtils.getEnabledNetworksForLayer(fixedLayer)[0]!
: RouteUtils.getEnabledScopes()[0].network,
layer: fixedLayer ?? RouteUtils.getEnabledScopes()[0].layer,
}),
),
)
Expand All @@ -99,7 +103,7 @@ export const routes: RouteObject[] = [
children: [
{
path: '/',
element: fixedLayer ? <RedirectToDashboard /> : withDefaultTheme(<HomePage />, true),
element: skipGraph ? <RedirectToDashboard /> : withDefaultTheme(<HomePage />, true),
},
...(!!fixedNetwork && !!fixedLayer
? []
Expand Down
1 change: 1 addition & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ declare global {
REACT_APP_STAGING_URLS?: string
REACT_APP_FIXED_NETWORK?: string
REACT_APP_FIXED_LAYER?: string
REACT_APP_SKIP_GRAPH?: string
REACT_APP_SHOW_FIAT_VALUES: 'true' | 'false'
}
}
Expand Down

0 comments on commit b372e50

Please sign in to comment.