feat: run request upon cmd+enter from response pane

This commit is contained in:
Anoop M D 2023-01-20 07:16:57 +05:30
parent 6b43159be2
commit 695f42df80
2 changed files with 14 additions and 3 deletions

View File

@ -1,17 +1,23 @@
import React from 'react';
import CodeEditor from 'components/CodeEditor';
import { useTheme } from 'providers/Theme';
import { useDispatch } from 'react-redux';
import { sendRequest } from 'providers/ReduxStore/slices/collections/actions';
import StyledWrapper from './StyledWrapper';
const QueryResult = ({ value, width }) => {
const QueryResult = ({ item, collection, value, width }) => {
const {
storedTheme
} = useTheme();
const dispatch = useDispatch();
const onRun = () => dispatch(sendRequest(item, collection.uid));
return (
<StyledWrapper className="px-3 w-full" style={{ maxWidth: width }}>
<div className="h-full">
<CodeEditor theme={storedTheme} value={value || ''} readOnly />
<CodeEditor theme={storedTheme} onRun={onRun} value={value || ''} readOnly />
</div>
</StyledWrapper>
);

View File

@ -33,7 +33,12 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => {
const getTabPanel = (tab) => {
switch (tab) {
case 'response': {
return <QueryResult width={rightPaneWidth} value={response.data ? JSON.stringify(response.data, null, 2) : ''} />;
return <QueryResult
item={item}
collection={collection}
width={rightPaneWidth}
value={response.data ? JSON.stringify(response.data, null, 2) : ''
} />;
}
case 'headers': {
return <ResponseHeaders headers={response.headers} />;