From 6142552b5e3c9d383ba8890e86ddc2e32e003c0b Mon Sep 17 00:00:00 2001
From: liqiang <974923609@qq.com>
Date: Wed, 24 Mar 2021 18:08:15 +0800
Subject: [PATCH] feat: web addon breakpoint frontend
---
addon/web/client/src/App.js | 29 ++---
addon/web/client/src/components/BreakPoint.js | 109 ++++++++++++++++++
2 files changed, 116 insertions(+), 22 deletions(-)
create mode 100644 addon/web/client/src/components/BreakPoint.js
diff --git a/addon/web/client/src/App.js b/addon/web/client/src/App.js
index 7ab7d1a..3b7eb01 100644
--- a/addon/web/client/src/App.js
+++ b/addon/web/client/src/App.js
@@ -4,6 +4,8 @@ import Form from 'react-bootstrap/Form'
import Button from 'react-bootstrap/Button'
import './App.css'
+import BreakPoint from './components/BreakPoint'
+
import { FlowManager } from './flow'
import { isTextResponse, getSize } from './utils'
import { parseMessage, sendMessageEnum, buildMessageEdit, buildMessageMeta } from './message'
@@ -20,10 +22,6 @@ class App extends React.Component {
flow: null,
flowTab: 'Headers', // Headers, Preview, Response
-
- // TODO: change to rules
- interceptUriInputing: '',
- interceptUri: '',
}
this.ws = null
@@ -195,7 +193,7 @@ class App extends React.Component {
}
render() {
- const { flows, interceptUriInputing, interceptUri } = this.state
+ const { flows } = this.state
return (
@@ -216,23 +214,10 @@ class App extends React.Component {
-
-
{
- this.setState({ interceptUriInputing: e.target.value || '' })
- }}>
-
- {
- interceptUri ? {`Intercept:${interceptUri}`} : null
- }
-
+
{
+ const msg = buildMessageMeta(sendMessageEnum.changeBreakPointRules, rules)
+ this.ws.send(msg)
+ }} />
diff --git a/addon/web/client/src/components/BreakPoint.js b/addon/web/client/src/components/BreakPoint.js
new file mode 100644
index 0000000..00b63c0
--- /dev/null
+++ b/addon/web/client/src/components/BreakPoint.js
@@ -0,0 +1,109 @@
+import React from 'react'
+import Button from 'react-bootstrap/Button'
+import Modal from 'react-bootstrap/Modal'
+import Form from 'react-bootstrap/Form'
+import Row from 'react-bootstrap/Row'
+import Col from 'react-bootstrap/Col'
+
+class BreakPoint extends React.Component {
+ constructor(props) {
+ super(props)
+
+ this.state = {
+ show: false,
+
+ rule: {
+ method: 'ALL',
+ url: '',
+ action: '1',
+ }
+ }
+
+ this.handleClose = this.handleClose.bind(this)
+ this.handleShow = this.handleShow.bind(this)
+ this.handleSave = this.handleSave.bind(this)
+ }
+
+ handleClose() {
+ this.setState({ show: false })
+ }
+
+ handleShow() {
+ this.setState({ show: true })
+ }
+
+ handleSave() {
+ const { rule } = this.state
+ const rules = []
+ if (rule.url) {
+ rules.push({
+ method: rule.method === 'ALL' ? '' : rule.method,
+ url: rule.url,
+ action: parseInt(rule.action)
+ })
+ }
+
+ this.props.onSave(rules)
+ this.handleClose()
+ }
+
+ render() {
+ const { rule } = this.state
+
+ return (
+
+
+
+
+
+ Set BreakPoint
+
+
+
+
+ Method
+
+ { this.setState({ rule: { ...rule, method: e.target.value } }) }}>
+
+
+
+
+
+
+
+
+
+
+ URL
+ { this.setState({ rule: { ...rule, url: e.target.value } }) }} />
+
+
+
+ Action
+
+ { this.setState({ rule: { ...rule, action: e.target.value } }) }}>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
+
+export default BreakPoint