forked from extern/bruno
pr #1184: addressed review comments
This commit is contained in:
parent
2d16e07747
commit
ee2295aec1
@ -2,15 +2,14 @@ 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';
|
||||
import { responseCleared } from 'providers/ReduxStore/slices/collections/index';
|
||||
|
||||
const ResponseClear = ({ collection, item }) => {
|
||||
const dispatch = useDispatch();
|
||||
const response = item.response || {};
|
||||
|
||||
const clearResponse = () =>
|
||||
dispatch(
|
||||
responseReceived({
|
||||
responseCleared({
|
||||
itemUid: item.uid,
|
||||
collectionUid: collection.uid,
|
||||
response: null
|
||||
@ -19,7 +18,7 @@ const ResponseClear = ({ collection, item }) => {
|
||||
|
||||
return (
|
||||
<StyledWrapper className="ml-2 flex items-center">
|
||||
<button onClick={clearResponse} disabled={!response.dataBuffer} title="Clear response">
|
||||
<button onClick={clearResponse} title="Clear response">
|
||||
<IconEraser size={16} strokeWidth={1.5} />
|
||||
</button>
|
||||
</StyledWrapper>
|
||||
|
@ -269,6 +269,16 @@ export const collectionsSlice = createSlice({
|
||||
}
|
||||
}
|
||||
},
|
||||
responseCleared: (state, action) => {
|
||||
const collection = findCollectionByUid(state.collections, action.payload.collectionUid);
|
||||
|
||||
if (collection) {
|
||||
const item = findItemInCollection(collection, action.payload.itemUid);
|
||||
if (item) {
|
||||
item.response = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
saveRequest: (state, action) => {
|
||||
const collection = findCollectionByUid(state.collections, action.payload.collectionUid);
|
||||
|
||||
@ -1397,6 +1407,7 @@ export const {
|
||||
processEnvUpdateEvent,
|
||||
requestCancelled,
|
||||
responseReceived,
|
||||
responseCleared,
|
||||
saveRequest,
|
||||
deleteRequestDraft,
|
||||
newEphemeralHttpRequest,
|
||||
|
Loading…
Reference in New Issue
Block a user