Merge pull request #1184 from smebberson/feature/clear-response

You can now clear a response.
This commit is contained in:
Anoop M D 2023-12-15 00:47:02 +05:30 committed by GitHub
commit 2d16e07747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,8 @@
import styled from 'styled-components';
const StyledWrapper = styled.div`
font-size: 0.8125rem;
color: ${(props) => props.theme.requestTabPanel.responseStatus};
`;
export default StyledWrapper;

View File

@ -0,0 +1,28 @@
import React from 'react';
import { IconEraser } from '@tabler/icons';
import { useDispatch } from 'react-redux';
import StyledWrapper from './StyledWrapper';
import { responseReceived } from 'providers/ReduxStore/slices/collections/index';
const ResponseClear = ({ collection, item }) => {
const dispatch = useDispatch();
const response = item.response || {};
const clearResponse = () =>
dispatch(
responseReceived({
itemUid: item.uid,
collectionUid: collection.uid,
response: null
})
);
return (
<StyledWrapper className="ml-2 flex items-center">
<button onClick={clearResponse} disabled={!response.dataBuffer} title="Clear response">
<IconEraser size={16} strokeWidth={1.5} />
</button>
</StyledWrapper>
);
};
export default ResponseClear;

View File

@ -21,7 +21,7 @@ const ResponseSave = ({ item }) => {
};
return (
<StyledWrapper className="ml-4 flex items-center">
<StyledWrapper className="ml-2 flex items-center">
<button onClick={saveResponseToFile} disabled={!response.dataBuffer} title="Save response to file">
<IconDownload size={16} strokeWidth={1.5} />
</button>

View File

@ -15,6 +15,7 @@ import TestResults from './TestResults';
import TestResultsLabel from './TestResultsLabel';
import StyledWrapper from './StyledWrapper';
import ResponseSave from 'src/components/ResponsePane/ResponseSave';
import ResponseClear from 'src/components/ResponsePane/ResponseClear';
const ResponsePane = ({ rightPaneWidth, item, collection }) => {
const dispatch = useDispatch();
@ -114,6 +115,7 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => {
</div>
{!isLoading ? (
<div className="flex flex-grow justify-end items-center">
<ResponseClear item={item} collection={collection} />
<ResponseSave item={item} />
<StatusCode status={response.status} />
<ResponseTime duration={response.duration} />