You can now clear a response.

This commit is contained in:
Scott Mebberson 2023-12-08 08:35:35 +10:30
parent da3bd95add
commit 08935c64bb
No known key found for this signature in database
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} />