@@ -31,7 +31,6 @@ interface Props {
3131 handleGetAutocompleteNameConstants ?: AutocompleteHandler ;
3232 handleGetAutocompleteValueConstants ?: AutocompleteHandler ;
3333 isDisabled ?: boolean ;
34- isWebSocketRequest ?: boolean ;
3534 namePlaceholder ?: string ;
3635 onChange : ( c : {
3736 name : string ;
@@ -42,6 +41,7 @@ interface Props {
4241 pairs : Pair [ ] ;
4342 valuePlaceholder ?: string ;
4443 onBlur ?: ( e : FocusEvent ) => void ;
44+ readOnlyPairs ?: Pair [ ] ;
4545}
4646
4747export const KeyValueEditor : FC < Props > = ( {
@@ -52,30 +52,17 @@ export const KeyValueEditor: FC<Props> = ({
5252 handleGetAutocompleteNameConstants,
5353 handleGetAutocompleteValueConstants,
5454 isDisabled,
55- isWebSocketRequest,
5655 namePlaceholder,
5756 onChange,
5857 pairs,
5958 valuePlaceholder,
6059 onBlur,
60+ readOnlyPairs,
6161} ) => {
6262 // We should make the pair.id property required and pass them in from the parent
6363 // smelly
6464 const pairsWithIds = pairs . map ( pair => ( { ...pair , id : pair . id || generateId ( 'pair' ) } ) ) ;
6565
66- const readOnlyWebsocketPairs = [
67- { name : 'Connection' , value : 'Upgrade' } ,
68- { name : 'Upgrade' , value : 'websocket' } ,
69- { name : 'Sec-WebSocket-Key' , value : '<calculated at runtime>' } ,
70- { name : 'Sec-WebSocket-Version' , value : '13' } ,
71- { name : 'Sec-WebSocket-Extensions' , value : 'permessage-deflate; client_max_window_bits' } ,
72- ] . map ( pair => ( { ...pair , id : generateId ( 'pair' ) } ) ) ;
73-
74- const readOnlyHttpPairs = [
75- { name : 'Accept' , value : '*/*' } ,
76- { name : 'Host' , value : '<calculated at runtime>' } ,
77- ] . map ( pair => ( { ...pair , id : generateId ( 'pair' ) } ) ) ;
78- const readOnlyPairs = isWebSocketRequest ? readOnlyWebsocketPairs : readOnlyHttpPairs ;
7966 const [ showDescription , setShowDescription ] = React . useState ( false ) ;
8067
8168 return (
@@ -129,7 +116,7 @@ export const KeyValueEditor: FC<Props> = ({
129116 addPair = { ( ) => { } }
130117 />
131118 ) }
132- { readOnlyPairs . map ( pair => (
119+ { ( readOnlyPairs || [ ] ) . map ( pair => (
133120 < li key = { pair . id } className = "key-value-editor__row-wrapper" >
134121 < div className = "key-value-editor__row" >
135122 < div className = "form-control form-control--underlined form-control--wide" >
0 commit comments