@@ -26,14 +26,20 @@ import {Button, Input, Switch} from '@wireapp/react-ui-kit';
2626
2727import { ConversationState } from 'Repositories/conversation/ConversationState' ;
2828import { Config , Configuration } from 'src/script/Config' ;
29+ import { StartupFeatureToggleName , startupFeatureToggleNames } from 'src/script/featureToggles/startupFeatureToggleNames' ;
30+ import { updateLocationSearchForStartupFeatureToggle } from 'src/script/featureToggles/startupFeatureToggleQueryParameters' ;
2931import { useClickOutside } from 'src/script/hooks/useClickOutside' ;
3032import { useApplicationContext } from 'src/script/page/RootProvider' ;
3133import { CoreCryptoLogLevel } from 'Util/debugUtil' ;
3234
3335import { wrapperStyles } from './ConfigToolbar.styles' ;
3436
37+ export function createLocationUrl ( pathname : string , search : string , hash : string ) : string {
38+ return `${ pathname } ${ search } ${ hash } ` ;
39+ }
40+
3541export function ConfigToolbar ( ) {
36- const { fireAndForgetInvoker} = useApplicationContext ( ) ;
42+ const { fireAndForgetInvoker, applicationNavigation , isFeatureToggleEnabled } = useApplicationContext ( ) ;
3743 const [ showConfig , setShowConfig ] = useState ( false ) ;
3844 const [ isResettingMLSConversation , setIsResettingMLSConversation ] = useState ( false ) ;
3945 const [ isGzipEnabled , setIsGzipEnabled ] = useState ( window . wire ?. app . debug ?. isGzippingEnabled ( ) ?? false ) ;
@@ -303,6 +309,52 @@ export function ConfigToolbar() {
303309 ) ;
304310 } ;
305311
312+ function reloadApplicationForStartupFeatureToggle (
313+ featureToggleName : StartupFeatureToggleName ,
314+ shouldEnableFeatureToggle : boolean ,
315+ ) : void {
316+ const locationSearch = applicationNavigation . currentSearch ;
317+ const nextLocationSearch = updateLocationSearchForStartupFeatureToggle ( {
318+ locationSearch,
319+ featureToggleName,
320+ shouldEnableFeatureToggle,
321+ } ) ;
322+ const locationPathname = applicationNavigation . currentPathname ;
323+ const locationHash = applicationNavigation . currentHash ;
324+ const nextLocationUrl = createLocationUrl ( locationPathname , nextLocationSearch , locationHash ) ;
325+
326+ applicationNavigation . navigateTo ( nextLocationUrl ) ;
327+ }
328+
329+ function renderStartupFeatureToggleCheckboxList ( ) {
330+ return (
331+ < fieldset style = { { margin : 0 , border : 0 , padding : 0 } } >
332+ < legend style = { { fontWeight : 'bold' , marginBottom : '8px' } } > Startup Feature Toggles</ legend >
333+ < ul style = { { listStyle : 'none' , margin : 0 , padding : 0 } } >
334+ { startupFeatureToggleNames . map ( featureToggleName => {
335+ const featureToggleCheckboxIdentifier = `startup-feature-toggle-checkbox-${ featureToggleName } ` ;
336+
337+ return (
338+ < li key = { featureToggleName } style = { { marginBottom : '10px' } } >
339+ < label htmlFor = { featureToggleCheckboxIdentifier } style = { { display : 'block' } } >
340+ < input
341+ id = { featureToggleCheckboxIdentifier }
342+ type = "checkbox"
343+ checked = { isFeatureToggleEnabled ( featureToggleName ) }
344+ onChange = { event => {
345+ reloadApplicationForStartupFeatureToggle ( featureToggleName , event . currentTarget . checked ) ;
346+ } }
347+ />
348+ { ` ${ featureToggleName } ` }
349+ </ label >
350+ </ li >
351+ ) ;
352+ } ) }
353+ </ ul >
354+ </ fieldset >
355+ ) ;
356+ }
357+
306358 const resetMLSConversation = async ( ) => {
307359 setIsResettingMLSConversation ( true ) ;
308360 try {
@@ -359,6 +411,10 @@ export function ConfigToolbar() {
359411
360412 < hr />
361413
414+ < div > { renderStartupFeatureToggleCheckboxList ( ) } </ div >
415+
416+ < hr />
417+
362418 < h3 > Message Automation</ h3 >
363419 < Input
364420 type = "text"
0 commit comments