-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fill textarea with response from backend #109
Changes from 10 commits
4b598db
4efb204
5464d12
c3e3663
2bcba47
b130936
52391ef
24c909a
9910bec
7c729be
18a3836
6c2b626
ccf1a7b
d8cf415
e1318f2
d8146e9
32297e9
b366eef
e5ba3f1
c4891d6
4ff5509
28e2f3f
17c0717
06a161f
b8f6963
41808b3
ceec4a8
11d9ece
57c6999
04f8f6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,103 +8,116 @@ export const InterceptTextBox = props => { | |
const responseTextValue = props.responseText[props.rowProps.checkbox.requestId] || defaultResponseText; | ||
const statusCodeValue = props.statusCodes[props.rowProps.checkbox.requestId] || defaultStatusCode; | ||
const contentTypeValue = props.contentType[props.rowProps.checkbox.requestId] || defaultContentType; | ||
let textAreaValue = JSON.stringify(props.responseData[props.rowProps.checkbox.requestId]) ||responseTextValue | ||
|
||
return ( | ||
<div className="grid-container form"> | ||
<div className="full-url"> | ||
<label htmlFor="">URL</label> | ||
<a href={props.rowProps.checkbox.url} className="urlText"> | ||
{props.rowProps.checkbox.url} | ||
</a> | ||
return ( | ||
<div className="grid-container form"> | ||
<div className="full-url"> | ||
<label htmlFor="">URL</label> | ||
<a href={props.rowProps.checkbox.url} className="urlText"> | ||
{props.rowProps.checkbox.url} | ||
</a> | ||
</div> | ||
<div className="response"> | ||
<span className="fetch-responsetext" onClick={() => { | ||
props.fetchResponse(props.rowProps.checkbox.url,props.rowProps.checkbox.method, props.rowProps.checkbox.requestId ) | ||
.then( () => { | ||
textAreaValue = JSON.stringify(props.responseData[props.rowProps.checkbox.requestId]) ||responseTextValue | ||
}) | ||
.catch( () => { | ||
textAreaValue = JSON.stringify(props.responseData[props.rowProps.checkbox.requestId]) ||responseTextValue | ||
}) | ||
} | ||
}>X</span> | ||
<label htmlFor="">Response Text</label> | ||
<textarea | ||
name="responseText" | ||
className="responseText" | ||
defaultValue={textAreaValue } | ||
key={textAreaValue} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added key attr to force re-render of |
||
//value={textAreaValue} | ||
onChange={event => props.handleRespTextChange(event.target.value, props.rowProps.checkbox.requestId)} | ||
/> | ||
</div> | ||
<div className="status"> | ||
<label htmlFor="">Select Status</label> | ||
<select | ||
value={statusCodeValue} | ||
className="select-status" | ||
onChange={event => { | ||
props.handleStatusCodeChange(event.target.value, props.rowProps.checkbox.requestId); | ||
}} | ||
> | ||
<option value="100">100 - Continue</option> | ||
<option value="101">101 - Switching Protocols</option> | ||
<option value="200">200 - OK</option> | ||
<option value="201">201 - Created</option> | ||
<option value="202">202 - Accepted</option> | ||
<option value="203">203 - Non-Authoritative Information</option> | ||
<option value="204">204 - No Content</option> | ||
<option value="205">205 - Reset Content</option> | ||
<option value="206">206 - Partial Content</option> | ||
<option value="207">207 - Multi-Status</option> | ||
<option value="300">300 - Multiple Choice</option> | ||
<option value="301">301 - Moved Permenantly</option> | ||
<option value="302">302 - Found</option> | ||
<option value="303">303 - See Other</option> | ||
<option value="304">304 - Not Modified</option> | ||
<option value="305">305 - Use Proxy</option> | ||
<option value="307">307 - Temporary Redirect</option> | ||
<option value="400">400 - Bad Request</option> | ||
<option value="401">401 - Unauthorized</option> | ||
<option value="402">402 - Payment Required</option> | ||
<option value="403">403 - Forbidden</option> | ||
<option value="404">404 - Not Found</option> | ||
<option value="405">405 - Method Not Allowed</option> | ||
<option value="406">406 - Not Acceptable</option> | ||
<option value="407">407 - Proxy Authentication Required</option> | ||
<option value="408">408 - Request Timeout</option> | ||
<option value="409">409 - Conflict</option> | ||
<option value="410">410 - Gone</option> | ||
<option value="411">411 - Length Required</option> | ||
<option value="412">412 - Precondition Failed</option> | ||
<option value="413">413 - Request Entity Too Large</option> | ||
<option value="414">414 - Request-URI Too Long</option> | ||
<option value="415">415 - Unsupported Media Type</option> | ||
<option value="416">416 - Requested Range Not Satisfiable</option> | ||
<option value="417">417 - Expectation Failed</option> | ||
<option value="422">422 - Unprocessable Entity</option> | ||
<option value="500">500 - Internal Server Error</option> | ||
<option value="501">501 - Not Implemented</option> | ||
<option value="502">502 - Bad Gateway</option> | ||
<option value="503">503 - Service Unavailable</option> | ||
<option value="504">504 - Gateway Timeout</option> | ||
<option value="505">505 - HTTP Version Not Supported</option> | ||
</select> | ||
</div> | ||
<div className="content"> | ||
<label htmlFor="">Content Type</label> | ||
<select | ||
value={contentTypeValue} | ||
className="content-type-select" | ||
onChange={event => { | ||
props.handleContentTypeChange(event.target.value, props.rowProps.checkbox.requestId); | ||
}} | ||
> | ||
<option value="application/json">application/json</option> | ||
<option value="text/html">text/html</option> | ||
<option value="text/csv">text/csv</option> | ||
<option value="application/javascript">application/javascript</option> | ||
<option value="text/css">text/css</option> | ||
<option value="text/plain">text/plain</option> | ||
<option value="application/pdf">application/pdf</option> | ||
</select> | ||
</div> | ||
<RequestHeaderList requestHeaders={props.rowProps.checkbox.requestHeaders} /> | ||
</div> | ||
<div className="response"> | ||
<label htmlFor="">Response Text</label> | ||
<textarea | ||
name="responseText" | ||
className="responseText" | ||
defaultValue={responseTextValue} | ||
//value={responseTextValue} | ||
onChange={event => props.handleRespTextChange(event.target.value, props.rowProps.checkbox.requestId)} | ||
/> | ||
</div> | ||
<div className="status"> | ||
<label htmlFor="">Select Status</label> | ||
<select | ||
value={statusCodeValue} | ||
className="select-status" | ||
onChange={event => { | ||
props.handleStatusCodeChange(event.target.value, props.rowProps.checkbox.requestId); | ||
}} | ||
> | ||
<option value="100">100 - Continue</option> | ||
<option value="101">101 - Switching Protocols</option> | ||
<option value="200">200 - OK</option> | ||
<option value="201">201 - Created</option> | ||
<option value="202">202 - Accepted</option> | ||
<option value="203">203 - Non-Authoritative Information</option> | ||
<option value="204">204 - No Content</option> | ||
<option value="205">205 - Reset Content</option> | ||
<option value="206">206 - Partial Content</option> | ||
<option value="207">207 - Multi-Status</option> | ||
<option value="300">300 - Multiple Choice</option> | ||
<option value="301">301 - Moved Permenantly</option> | ||
<option value="302">302 - Found</option> | ||
<option value="303">303 - See Other</option> | ||
<option value="304">304 - Not Modified</option> | ||
<option value="305">305 - Use Proxy</option> | ||
<option value="307">307 - Temporary Redirect</option> | ||
<option value="400">400 - Bad Request</option> | ||
<option value="401">401 - Unauthorized</option> | ||
<option value="402">402 - Payment Required</option> | ||
<option value="403">403 - Forbidden</option> | ||
<option value="404">404 - Not Found</option> | ||
<option value="405">405 - Method Not Allowed</option> | ||
<option value="406">406 - Not Acceptable</option> | ||
<option value="407">407 - Proxy Authentication Required</option> | ||
<option value="408">408 - Request Timeout</option> | ||
<option value="409">409 - Conflict</option> | ||
<option value="410">410 - Gone</option> | ||
<option value="411">411 - Length Required</option> | ||
<option value="412">412 - Precondition Failed</option> | ||
<option value="413">413 - Request Entity Too Large</option> | ||
<option value="414">414 - Request-URI Too Long</option> | ||
<option value="415">415 - Unsupported Media Type</option> | ||
<option value="416">416 - Requested Range Not Satisfiable</option> | ||
<option value="417">417 - Expectation Failed</option> | ||
<option value="422">422 - Unprocessable Entity</option> | ||
<option value="500">500 - Internal Server Error</option> | ||
<option value="501">501 - Not Implemented</option> | ||
<option value="502">502 - Bad Gateway</option> | ||
<option value="503">503 - Service Unavailable</option> | ||
<option value="504">504 - Gateway Timeout</option> | ||
<option value="505">505 - HTTP Version Not Supported</option> | ||
</select> | ||
</div> | ||
<div className="content"> | ||
<label htmlFor="">Content Type</label> | ||
<select | ||
value={contentTypeValue} | ||
className="content-type-select" | ||
onChange={event => { | ||
props.handleContentTypeChange(event.target.value, props.rowProps.checkbox.requestId); | ||
}} | ||
> | ||
<option value="application/json">application/json</option> | ||
<option value="text/html">text/html</option> | ||
<option value="text/csv">text/csv</option> | ||
<option value="application/javascript">application/javascript</option> | ||
<option value="text/css">text/css</option> | ||
<option value="text/plain">text/plain</option> | ||
<option value="application/pdf">application/pdf</option> | ||
</select> | ||
</div> | ||
<RequestHeaderList requestHeaders={props.rowProps.checkbox.requestHeaders} /> | ||
</div> | ||
); | ||
); | ||
}; | ||
|
||
InterceptTextBox.defaultProps = { | ||
responseText: [], | ||
statusCodes: [], | ||
contentType: [] | ||
contentType: [], | ||
responseData:{} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ export interface RequestObj { | |
disableInterceptor:React.ChangeEvent<HTMLButtonElement>; | ||
updateInterceptorStatus:React.ChangeEvent<HTMLButtonElement>; | ||
isInterceptorOn:object; | ||
fetchResponse:React.MouseEvent<HTMLButtonElement> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come this is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
responseData : object; | ||
} | ||
const RequestList = (props: RequestObj) => { | ||
const columns = [ | ||
|
@@ -126,6 +128,9 @@ const RequestList = (props: RequestObj) => { | |
statusCodes={props.statusCodes} | ||
handleContentTypeChange={props.handleContentTypeChange} | ||
contentType={props.contentType} | ||
tabId={props.tabId} | ||
fetchResponse={props.fetchResponse} | ||
responseData = {props.responseData} | ||
/> | ||
)} | ||
/> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as axios from 'axios' | ||
import { fetchResponse, fetchSuccess, fetchFailure } from './../actions' | ||
|
||
const fetchDataAlias = ({payload}) => { | ||
return (dispatch, getState) => { | ||
const {method, url, requestId} = payload | ||
console.log(method, url, requestId) | ||
//dispatch(fetchResponse(payload.url, payload.method, payload.tabId)) | ||
axios({ | ||
method, | ||
url | ||
}) | ||
.then( (data) => { | ||
dispatch(fetchSuccess(data, requestId)) | ||
}) | ||
.catch( (err) => { | ||
dispatch(fetchFailure(err, requestId)) | ||
}) | ||
} | ||
} | ||
|
||
export default { | ||
"FETCH_DATA": fetchDataAlias | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is suppose to be a async action right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is why we are using
aliases
- https://github.com/tshaddix/react-chrome-redux/wiki/Advanced-Usage#alias