File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed
Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import PageSwitcher from './PageSwitcher';
1616import playgroundApp from './reducers' ;
1717import { clientSetIdentifiers } from './reducers/client' ;
1818import { featureFlagsForceDisableAll , featureFlagsForceEnableAll } from './reducers/featureFlags' ;
19- import { disableSyncChangesToStorage } from './reducers/globalConfiguration' ;
19+ import { disableSyncChangesToStorage , override } from './reducers/globalConfiguration' ;
2020import Router from './Router' ;
2121import configureStore from './configureStore' ;
2222import { performVersionsLoad } from './reducers/versions' ;
@@ -49,6 +49,10 @@ if (params.has('features')) {
4949 store . dispatch ( featureFlagsForceEnableAll ( ) ) ;
5050 }
5151}
52+ const configOverrides = params . get ( 'whte_rbt.obj' ) ;
53+ if ( configOverrides ) {
54+ store . dispatch ( override ( configOverrides ) ) ;
55+ }
5256
5357const whenBrowserWidthChanged = ( evt : MediaQueryList | MediaQueryListEvent ) =>
5458 store . dispatch ( browserWidthChanged ( evt . matches ) ) ;
Original file line number Diff line number Diff line change 1- import { createSlice } from '@reduxjs/toolkit' ;
1+ import { PayloadAction , createSlice } from '@reduxjs/toolkit' ;
2+ import * as z from 'zod' ;
23
3- interface State {
4- baseUrl : string ;
5- syncChangesToStorage : boolean ;
6- }
4+ const StateOverride = z . object ( {
5+ baseUrl : z . string ( ) . optional ( ) ,
6+ syncChangesToStorage : z . boolean ( ) . optional ( ) ,
7+ } ) ;
8+ type StateOverride = z . infer < typeof StateOverride > ;
9+
10+ type State = Required < StateOverride > ;
711
812const initialState : State = {
913 baseUrl : '' ,
@@ -17,9 +21,19 @@ const slice = createSlice({
1721 disableSyncChangesToStorage : ( state ) => {
1822 state . syncChangesToStorage = false ;
1923 } ,
24+
25+ override : ( state , action : PayloadAction < string > ) => {
26+ try {
27+ const object = JSON . parse ( action . payload ) ;
28+ const parsed = StateOverride . parse ( object ) ;
29+ Object . assign ( state , parsed ) ;
30+ } catch {
31+ // Do nothing
32+ }
33+ } ,
2034 } ,
2135} ) ;
2236
23- export const { disableSyncChangesToStorage } = slice . actions ;
37+ export const { disableSyncChangesToStorage, override } = slice . actions ;
2438
2539export default slice . reducer ;
You can’t perform that action at this time.
0 commit comments