diff --git a/packages/grafnode-components/src/components/RequestPane/StyledWrapper.js b/packages/grafnode-components/src/components/GraphQLRequestPane/StyledWrapper.js similarity index 100% rename from packages/grafnode-components/src/components/RequestPane/StyledWrapper.js rename to packages/grafnode-components/src/components/GraphQLRequestPane/StyledWrapper.js diff --git a/packages/grafnode-components/src/components/RequestPane/index.js b/packages/grafnode-components/src/components/GraphQLRequestPane/index.js similarity index 86% rename from packages/grafnode-components/src/components/RequestPane/index.js rename to packages/grafnode-components/src/components/GraphQLRequestPane/index.js index 42b486ef..3a6138ce 100644 --- a/packages/grafnode-components/src/components/RequestPane/index.js +++ b/packages/grafnode-components/src/components/GraphQLRequestPane/index.js @@ -4,7 +4,7 @@ import StyledWrapper from './StyledWrapper'; import QueryEditor from '../QueryEditor'; import RequestHeaders from '../RequestHeaders'; -const RequestPane = ({onRunQuery, schema, leftPaneWidth, value, onQueryChange}) => { +const GraphQLRequestPane = ({onRunQuery, schema, leftPaneWidth, value, onQueryChange}) => { return ( @@ -29,4 +29,4 @@ const RequestPane = ({onRunQuery, schema, leftPaneWidth, value, onQueryChange}) ) }; -export default RequestPane; +export default GraphQLRequestPane; diff --git a/packages/grafnode-components/src/components/HttpRequestPane/StyledWrapper.js b/packages/grafnode-components/src/components/HttpRequestPane/StyledWrapper.js new file mode 100644 index 00000000..b98f13b8 --- /dev/null +++ b/packages/grafnode-components/src/components/HttpRequestPane/StyledWrapper.js @@ -0,0 +1,59 @@ +import styled from 'styled-components'; + +const StyledWrapper = styled.div` + .react-tabs__tab-list { + border-bottom: none !important; + padding-top: 0; + padding-left: 0 !important; + display: flex; + align-items: center; + margin: 0; + + .react-tabs__tab { + font-size: 14px; + padding: 6px 0px; + border: none; + user-select: none; + border-bottom: solid 2px transparent; + margin-right: 20px; + color: rgb(117 117 117); + outline: none !important; + + &:focus, &:active, &:focus-within, &:focus-visible, &:target { + outline: none !important; + box-shadow: none !important; + } + + &:after { + display: none !important; + } + } + } + + .react-tabs__tab--selected { + border: none; + color: #322e2c !important; + border-bottom: solid 2px #8e44ad !important; + border-color: #8e44ad !important; + background: inherit; + outline: none !important; + box-shadow: none !important; + + &:focus, &:active, &:focus-within, &:focus-visible, &:target { + border: none; + outline: none !important; + box-shadow: none !important; + border-bottom: solid 2px #8e44ad !important; + border-color: #8e44ad !important; + background: inherit; + outline: none !important; + box-shadow: none !important; + } + } + + .react-tabs__tab-panel--selected { + height: 90%; + } +`; + +export default StyledWrapper; \ No newline at end of file diff --git a/packages/grafnode-components/src/components/HttpRequestPane/index.js b/packages/grafnode-components/src/components/HttpRequestPane/index.js new file mode 100644 index 00000000..921cd826 --- /dev/null +++ b/packages/grafnode-components/src/components/HttpRequestPane/index.js @@ -0,0 +1,26 @@ +import React from 'react'; +import { Tab, TabList, TabPanel, Tabs } from 'react-tabs'; +import StyledWrapper from './StyledWrapper'; +import QueryParams from '../QueryParams'; +import RequestHeaders from '../RequestHeaders'; + +const HttpRequestPane = ({leftPaneWidth}) => { + return ( + + + + Params + Headers + + + + + + + + + + ) +}; + +export default HttpRequestPane; diff --git a/packages/grafnode-components/src/components/QueryParams/StyledWrapper.js b/packages/grafnode-components/src/components/QueryParams/StyledWrapper.js new file mode 100644 index 00000000..15e2a186 --- /dev/null +++ b/packages/grafnode-components/src/components/QueryParams/StyledWrapper.js @@ -0,0 +1,43 @@ +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: #616161; + font-size: 0.75rem; + } + td { + padding: 6px 10px; + } + } + + .btn-add-param { + 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; + } + } + + input[type="checkbox"] { + cursor: pointer; + } +`; + +export default Wrapper; diff --git a/packages/grafnode-components/src/components/QueryParams/index.js b/packages/grafnode-components/src/components/QueryParams/index.js new file mode 100644 index 00000000..9bafc3fe --- /dev/null +++ b/packages/grafnode-components/src/components/QueryParams/index.js @@ -0,0 +1,101 @@ +import React, { useState } from 'react'; +import { nanoid } from 'nanoid'; +import { IconTrash } from '@tabler/icons'; +import StyledWrapper from './StyledWrapper'; + +const initialState = [{ + uid: nanoid(), + enabled: true +}]; + +const QueryParams = () => { + const [params, setParams] = useState(initialState); + + const addParam = () => { + let newParam = { + uid: nanoid(), + key: '', + value: '', + description: '', + enabled: true + }; + + let newParams = [...params, newParam]; + setParams(newParams); + }; + + const handleParamValueChange = (e, index, menu) => { + // todo: yet to implement + }; + + const handleRemoveHeader = (index) => { + params.splice(index, 1); + setParams([...params]); + }; + + return ( + + + + + + + + + + + + {params && params.length ? params.map((header, index) => { + return ( + + + + + + + ); + }) : null} + +
KeyValueDescription
+ handleParamValueChange(e, index, 'key')} + /> + + handleParamValueChange(e, index, 'value')} + /> + + handleParamValueChange(e, index, 'description')} + /> + +
+ handleParamValueChange(e, index, 'enabled')} + /> + +
+
+ +
+ ) +}; +export default QueryParams; \ No newline at end of file diff --git a/packages/grafnode-components/src/components/RequestTabPanel/index.js b/packages/grafnode-components/src/components/RequestTabPanel/index.js index 3d5cd6a8..0b6f2394 100644 --- a/packages/grafnode-components/src/components/RequestTabPanel/index.js +++ b/packages/grafnode-components/src/components/RequestTabPanel/index.js @@ -1,7 +1,8 @@ import React, { useState, useEffect } from 'react'; import find from 'lodash/find'; import QueryUrl from '../QueryUrl'; -import RequestPane from '../RequestPane'; +import GraphQLRequestPane from '../GraphQLRequestPane'; +import HttpRequestPane from '../HttpRequestPane'; import ResponsePane from '../ResponsePane'; import Welcome from '../Welcome'; import { @@ -120,13 +121,21 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re
- + {item.request.type === 'graphql' ? ( + + ) : null} + + {item.request.type === 'http' ? ( + + ) : null}