diff --git a/packages/grafnode-components/src/components/RequestHeaders/StyledWrapper.js b/packages/grafnode-components/src/components/RequestHeaders/StyledWrapper.js new file mode 100644 index 000000000..16551c4c5 --- /dev/null +++ b/packages/grafnode-components/src/components/RequestHeaders/StyledWrapper.js @@ -0,0 +1,39 @@ +import styled from 'styled-components'; + +const Wrapper = styled.div` + table { + width: 100%; + border-collapse: collapse; + font-weight: 600; + + thead, td { + border: 1px solid #efefef; + } + + thead { + color: #777777; + font-size: 0.75rem; + } + td { + padding: 6px 10px; + } + } + + .btn-add-header { + margin-block: 10px; + padding: 5px; + } + + input[type="text"] { + width: 100%; + border: solid 1px transparent; + outline: none !important; + + &:focus{ + outline: none !important; + border: solid 1px transparent; + } + } +`; + +export default Wrapper; diff --git a/packages/grafnode-components/src/components/RequestHeaders/index.js b/packages/grafnode-components/src/components/RequestHeaders/index.js new file mode 100644 index 000000000..60acad2ea --- /dev/null +++ b/packages/grafnode-components/src/components/RequestHeaders/index.js @@ -0,0 +1,90 @@ +import React, { useState } from 'react'; +import StyledWrapper from './StyledWrapper'; + +const RequestHeaders = () => { + const [headers, setHeaders] = useState([{enabled: true}]); + + const addHeader = () => { + let newHeader = { + key: '', + value: '', + description: '', + enabled: true, + }; + + let newHeaders = [...headers, newHeader]; + setHeaders(newHeaders); + }; + + const handleHeaderValueChange = (e, index, menu) => { + // todo: yet to implement + }; + + const handleRemoveHeader = (index) => { + headers.splice(index, 1); + setHeaders(...headers); + }; + + return ( + + + + + + + + + + + + + {headers && headers.length && headers.map((header, index) => { + return ( + + + + + + + + ) + })} + +
KEYVALUEDESCRIPTION
+ handleHeaderValueChange(e, index, 'enabled')} + /> + + handleHeaderValueChange(e, index, 'key')} + /> + + handleHeaderValueChange(e, index, 'value')} + /> + + handleHeaderValueChange(e, index, 'description')} + /> + + +
+ +
+ ) +}; +export default RequestHeaders; \ No newline at end of file diff --git a/packages/grafnode-components/src/components/RequestPane/index.js b/packages/grafnode-components/src/components/RequestPane/index.js index ea7f96911..b3f86e9fc 100644 --- a/packages/grafnode-components/src/components/RequestPane/index.js +++ b/packages/grafnode-components/src/components/RequestPane/index.js @@ -2,6 +2,7 @@ import React from 'react'; import { Tab, TabList, TabPanel, Tabs } from 'react-tabs'; import StyledWrapper from './StyledWrapper'; import QueryEditor from '../QueryEditor'; +import RequestHeaders from '../RequestHeaders'; const RequestPane = ({onRunQuery, schema, leftPaneWidth, value, onQueryChange}) => { return ( @@ -21,7 +22,7 @@ const RequestPane = ({onRunQuery, schema, leftPaneWidth, value, onQueryChange}) /> - Headers +