File tree Expand file tree Collapse file tree 3 files changed +12
-14
lines changed
Expand file tree Collapse file tree 3 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import InfoIconWrapper from "../base/InfoIconWrapper";
1515import TextField from "../base/TextField" ;
1616import { isValidUrl } from "../../utils/strings" ;
1717import EdiTDorContext from "../../context/ediTDorContext" ;
18+ import Dropdown from "../base/Dropdown" ;
1819
1920export interface SettingsData {
2021 northboundUrl : string ;
@@ -149,21 +150,14 @@ const Settings: React.FC<SettingsProps> = ({
149150 < div className = "my-4 rounded-md bg-black bg-opacity-80 p-2" >
150151 { ! hideTitle && < h1 className = "font-bold" > JSON Editor</ h1 > }
151152 < div className = "px-4" >
152- < label
153- htmlFor = "json-indentation-select"
154- className = "mb-1 block text-sm text-gray-300"
155- >
156- Space indentation
157- </ label >
158- < select
153+ < Dropdown
159154 id = "json-indentation-select"
160- value = { data . jsonIndentation }
155+ label = "Space indentation"
156+ value = { String ( data . jsonIndentation ) }
161157 onChange = { handleJsonIndentationChange }
162- className = "w-full rounded-md border-2 border-gray-600 bg-gray-600 p-2 text-white focus:border-blue-500 focus:outline-none sm:text-sm"
163- >
164- < option value = { 2 } > 2 spaces</ option >
165- < option value = { 4 } > 4 spaces</ option >
166- </ select >
158+ options = { [ "2" , "4" ] }
159+ className = "w-full"
160+ />
167161 </ div >
168162 </ div >
169163
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ interface JsonSchemaEntry {
4747const JsonEditor : React . FC < JsonEditorProps > = ( { editorRef } ) => {
4848 const context = useContext ( ediTDorContext ) ;
4949
50- const jsonIndentation = context . settings ?. jsonIndentation ?? 2 ;
50+ const jsonIndentation = context . jsonIndentation ?? 2 ;
5151 const [ schemas ] = useState < JsonSchemaEntry [ ] > ( [ ] ) ;
5252 const [ proxy , setProxy ] = useState < any > ( undefined ) ;
5353 const editorInstance = useRef < editor . IStandaloneCodeEditor | null > ( null ) ;
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ interface IDropdownProps {
1717 id : string ;
1818 label : string ;
1919 options : string [ ] ;
20+ value ?: string ;
21+ onChange ?: ( event : React . ChangeEvent < HTMLSelectElement > ) => void ;
2022 className ?: string ;
2123}
2224
@@ -33,6 +35,8 @@ const Dropdown: React.FC<IDropdownProps> = (props) => {
3335 < select
3436 className = "block w-full appearance-none rounded border-2 border-gray-600 bg-gray-600 px-4 py-3 pr-8 leading-tight text-white focus:border-blue-500 focus:outline-none"
3537 id = { props . id }
38+ value = { props . value }
39+ onChange = { props . onChange }
3640 >
3741 { props . options . map ( ( e ) => {
3842 return < option key = { e } > { e } </ option > ;
You can’t perform that action at this time.
0 commit comments