Skip to content
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

Add title attribute to all buttons #126

Merged
merged 3 commits into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions app/components/InterceptAllButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import * as React from "react";
export const InterceptAllButton = props => {
return (
<button
id="intercept-all-btn"
className="btn btn-sm btn-primary btn-clear"
disabled={props.disabled}
onClick={props.handleCheckedRequests}
>
Intercept
</button>
id="intercept-all-btn"
title="Intercept Selected Requests"
className="btn btn-sm btn-primary btn-clear"
disabled={props.disabled}
onClick={props.handleCheckedRequests}
>
Intercept
</button>
);
};

InterceptAllButton.displayName = "InterceptAllButton";

InterceptAllButton.defaultProps = {
disabled: false
};
};
7 changes: 4 additions & 3 deletions app/components/Intercept_Components/InterceptTextBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import {RequestHeaderList} from "./RequestHeaderList";
import { RequestHeaderList } from "./RequestHeaderList";

export const InterceptTextBox = props => {
const requestId = props.rowProps.checkbox.requestId;
Expand All @@ -25,9 +25,9 @@ export const InterceptTextBox = props => {
</a>
</div>
<div className="response">
<label className="responseTextlabel">Response Text</label>
<label className="responseTextlabel">Mocked Response Text</label>
<button
title="Fetch Response"
title="Fetch Response Text"
className="fetch-responsetext btn-sm btn-primary"
onClick={() => {
props.fetchResponse(props.rowProps.checkbox);
Expand All @@ -38,6 +38,7 @@ export const InterceptTextBox = props => {
className="responseText"
defaultValue={responseTextValue}
key={props.responseData[requestId]}
title="Mocked Response Text"
//value={textAreaValue}
onChange={event => {
props.handleRespTextChange(event.target.value, requestId);
Expand Down
135 changes: 73 additions & 62 deletions app/components/request_list.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from "react";
import ReactTable from "react-table";
import matchSorter from "match-sorter";
import {InterceptForm} from "./../components/Intercept_Components/index";
import {InterceptAllButton} from './../components/InterceptAllButton'
import {Switch} from './Switch'
import { InterceptForm } from "./../components/Intercept_Components/index";
import { InterceptAllButton } from "./../components/InterceptAllButton";
import { Switch } from "./Switch";
export interface RequestObj {
requests: Array<chrome.webRequest.WebRequestDetails>;
requestId?: number;
Expand All @@ -20,20 +20,24 @@ export interface RequestObj {
PageDetails: object;
handlePaginationChange: React.MouseEvent<HTMLButtonElement>;
tabId: number;
clearRequests:React.ChangeEvent<HTMLButtonElement>;
disableInterceptor:React.ChangeEvent<HTMLButtonElement>;
updateInterceptorStatus:React.ChangeEvent<HTMLButtonElement>;
isInterceptorOn:object;
fetchResponse:React.MouseEvent<HTMLSpanElement>
responseData : object;
clearRequests: React.ChangeEvent<HTMLButtonElement>;
disableInterceptor: React.ChangeEvent<HTMLButtonElement>;
updateInterceptorStatus: React.ChangeEvent<HTMLButtonElement>;
isInterceptorOn: object;
fetchResponse: React.MouseEvent<HTMLSpanElement>;
responseData: object;
responseError: object;
}
const RequestList = (props: RequestObj) => {
const columns = [
{
Header: "Request URL",
accessor: "url",
Cell: ({original}) => <div className="url" title={original.url}>{original.url}</div>,
Cell: ({ original }) => (
<div className="url" title={original.url}>
{original.url}
</div>
),
filterable: true,
filterMethod: (filter, rows) => {
return matchSorter(rows, filter.value, {
Expand All @@ -45,15 +49,15 @@ const RequestList = (props: RequestObj) => {
},
{
Header: "Method",
className:"method",
className: "method",
accessor: "method",
width: 100,
filterable: true,
filterMethod: (filter, row) => row[filter.id] === filter.value,
Filter: ({filter, onChange}) => (
Filter: ({ filter, onChange }) => (
<select
onChange={event => onChange(event.target.value)}
style={{width: "100%"}}
style={{ width: "100%" }}
value={filter ? filter.value : ""}
>
<option value="">ALL</option>
Expand All @@ -66,7 +70,7 @@ const RequestList = (props: RequestObj) => {
{
id: "checkbox",
accessor: "",
Cell: ({original}) => {
Cell: ({ original }) => {
return (
<input
type="checkbox"
Expand All @@ -81,63 +85,70 @@ const RequestList = (props: RequestObj) => {
Header: "Intercept",
sortable: false,
width: 75,
className: 'text-center'
className: "text-center"
}
];

const enabledRequests = props.requests.filter(request => {
return props.checkedReqs[request.requestId];
})
return props.checkedReqs[request.requestId];
});

return (
<div>
<div className="grid-container response-action">
<Switch isOn={props.isInterceptorOn[props.tabId]} handleSwitch={props.handleSwitch}/>
<div className="text-right">
<InterceptAllButton
disabled={!enabledRequests.length}
handleCheckedRequests={() => {
return props.handleCheckedRequests(enabledRequests);
}}
/>
<button
type="button"
className="btn btn-sm btn-primary btn-clear"
onClick={props.clearRequests}
>
CLEAR
</button>
<div className="grid-container response-action">
<Switch isOn={props.isInterceptorOn[props.tabId]} handleSwitch={props.handleSwitch} />
<div className="text-right">
<InterceptAllButton
disabled={!enabledRequests.length}
handleCheckedRequests={() => {
return props.handleCheckedRequests(enabledRequests);
}}
/>
<button
type="button"
title="Clear All Requests"
className="btn btn-sm btn-primary btn-clear"
onClick={props.clearRequests}
>
CLEAR
</button>
</div>
</div>
</div>

<ReactTable
data={props.requests}
columns={columns}
showPagination={true}
showPaginationTop={false}
showPaginationBottom={true}
defaultPageSize={10}
page={props.PageDetails[props.tabId] ? props.PageDetails[props.tabId].currentPageNumber : 0}
pageSize={props.PageDetails[props.tabId] ? props.PageDetails[props.tabId].currentRowSize : 10}
onPageChange={changedPageNo => props.handlePaginationChange(changedPageNo, props.tabId, "currentPageNumber")}
onPageSizeChange={changedRowSize => props.handlePaginationChange(changedRowSize, props.tabId, "currentRowSize")}
collapseOnDataChange={false}
SubComponent={row => (
<InterceptForm
rowProps={row}
handleStatusCodeChange={props.handleStatusCodeChange}
handleRespTextChange={props.handleRespTextChange}
responseText={props.responseText}
statusCodes={props.statusCodes}
handleContentTypeChange={props.handleContentTypeChange}
contentType={props.contentType}
tabId={props.tabId}
fetchResponse={props.fetchResponse}
responseData = {props.responseData}
responseError= {props.responseError}
/>
)}
/>
<ReactTable
data={props.requests}
columns={columns}
showPagination={true}
showPaginationTop={false}
showPaginationBottom={true}
defaultPageSize={10}
page={props.PageDetails[props.tabId] ? props.PageDetails[props.tabId].currentPageNumber : 0}
pageSize={
props.PageDetails[props.tabId] ? props.PageDetails[props.tabId].currentRowSize : 10
}
onPageChange={changedPageNo =>
props.handlePaginationChange(changedPageNo, props.tabId, "currentPageNumber")
}
onPageSizeChange={changedRowSize =>
props.handlePaginationChange(changedRowSize, props.tabId, "currentRowSize")
}
collapseOnDataChange={false}
SubComponent={row => (
<InterceptForm
rowProps={row}
handleStatusCodeChange={props.handleStatusCodeChange}
handleRespTextChange={props.handleRespTextChange}
responseText={props.responseText}
statusCodes={props.statusCodes}
handleContentTypeChange={props.handleContentTypeChange}
contentType={props.contentType}
tabId={props.tabId}
fetchResponse={props.fetchResponse}
responseData={props.responseData}
responseError={props.responseError}
/>
)}
/>
</div>
);
};
Expand Down
Loading