11import { useState } from "react" ;
2- import { Checkbox } from ' ../components/Checkbox.js' ;
3- import { Input } from ' ../components/Input.js' ;
4- import { SelectWithOptions } from ' ../components/Select.js' ;
5- import { Stack } from ' ../components/Stack.js' ;
6- import { useSettingsContext } from ' ../context/useRDTContext.js' ;
7- import { RouteBoundaryOptions } from ' ../context/rdtReducer.js' ;
8- import { uppercaseFirstLetter } from ' ../utils/string.js' ;
2+ import { Checkbox } from " ../components/Checkbox.js" ;
3+ import { Input } from " ../components/Input.js" ;
4+ import { SelectWithOptions } from " ../components/Select.js" ;
5+ import { Stack } from " ../components/Stack.js" ;
6+ import { useSettingsContext } from " ../context/useRDTContext.js" ;
7+ import { RouteBoundaryOptions } from " ../context/rdtReducer.js" ;
8+ import { uppercaseFirstLetter } from " ../utils/string.js" ;
99
1010export const SettingsTab = ( ) => {
1111 const { settings, setSettings } = useSettingsContext ( ) ;
1212 const [ minHeight , setMinHeight ] = useState ( settings . minHeight . toString ( ) ) ;
1313 const [ maxHeight , setMaxHeight ] = useState ( settings . maxHeight . toString ( ) ) ;
1414 const [ expansionLevel , setExpansionLevel ] = useState ( settings . expansionLevel . toString ( ) ) ;
15+ const [ wsPort , setWsPort ] = useState ( settings . wsPort . toString ( ) ) ;
1516 return (
1617 < Stack className = "rdt-mb-4" >
1718 < h1 >
@@ -26,6 +27,14 @@ export const SettingsTab = () => {
2627 >
2728 Open dev tools by default
2829 </ Checkbox >
30+ < Checkbox
31+ id = "requireUrlFlag"
32+ hint = "Allows you to only show rdt when there is a flag in the URL search params set."
33+ onChange = { ( ) => setSettings ( { requireUrlFlag : ! settings . requireUrlFlag } ) }
34+ value = { settings . requireUrlFlag }
35+ >
36+ Show dev tools only when URL flag is set
37+ </ Checkbox >
2938 < Checkbox
3039 id = "hideUntilHover"
3140 hint = "The dev tools trigger will be hidden on the page until you hover over it."
@@ -34,8 +43,45 @@ export const SettingsTab = () => {
3443 >
3544 Hide the trigger until hovered
3645 </ Checkbox >
46+ < Checkbox
47+ id = "withServerDevTools"
48+ hint = "Tell the dev tools if they should try to connect to their server counterpart, if you don't have that set up you can just disable this."
49+ onChange = { ( ) => setSettings ( { withServerDevTools : ! settings . withServerDevTools } ) }
50+ value = { settings . withServerDevTools }
51+ >
52+ Connect to server dev tools
53+ </ Checkbox >
3754 < hr className = "rdt-mt-2 rdt-border-gray-700" />
3855 < Stack gap = "lg" >
56+ { settings . requireUrlFlag && (
57+ < Input
58+ name = "urlFlag"
59+ id = "urlFlag"
60+ label = "URL flag to use"
61+ hint = { `This allows you to change the URL search param flag that will be used to show the dev tools when "Show dev tools only when URL flag is set" is set to true` }
62+ value = { settings . urlFlag }
63+ onChange = { ( e ) => setSettings ( { urlFlag : e . target . value ?? "" } ) }
64+ onBlur = { ( e ) => {
65+ setSettings ( { urlFlag : e . target . value . trim ( ) } ) ;
66+ } }
67+ />
68+ ) }
69+ { settings . withServerDevTools && (
70+ < Input
71+ name = "wsPort"
72+ id = "wsPort"
73+ label = "Server dev tools WS port (default: 8080)"
74+ hint = "This allows you to change the port the client dev tools will try to connect to."
75+ value = { wsPort }
76+ onChange = { ( e ) => setWsPort ( e . target . value ?? "" ) }
77+ onBlur = { ( e ) => {
78+ const value = parseInt ( e . target . value ) ;
79+ if ( value && ! isNaN ( value ) && value >= 0 ) {
80+ setSettings ( { wsPort : value } ) ;
81+ }
82+ } }
83+ />
84+ ) }
3985 < Input
4086 name = "expansionLevel"
4187 id = "expansionLevel"
0 commit comments