({ flow, message, stopEdit }: HttpMessageEditProps)
| 48 | }; |
| 49 | |
| 50 | function HttpMessageEdit({ flow, message, stopEdit }: HttpMessageEditProps) { |
| 51 | const dispatch = useAppDispatch(); |
| 52 | |
| 53 | const part = flow.request === message ? "request" : "response"; |
| 54 | const url = MessageUtils.getContentURL(flow, message); |
| 55 | const content = useContent(url, message.contentHash); |
| 56 | const [editedContent, setEditedContent] = useState<string>(); |
| 57 | |
| 58 | const save = async () => { |
| 59 | await dispatch( |
| 60 | flowActions.update(flow, { |
| 61 | [part]: { content: editedContent ?? content ?? "" }, |
| 62 | }), |
| 63 | ); |
| 64 | stopEdit(); |
| 65 | }; |
| 66 | return ( |
| 67 | <div className="contentview" key="edit"> |
| 68 | <div className="controls"> |
| 69 | <h5>[Editing]</h5> |
| 70 | <Button |
| 71 | onClick={save} |
| 72 | icon="fa-check text-success" |
| 73 | className="btn-xs" |
| 74 | > |
| 75 | Done |
| 76 | </Button> |
| 77 | |
| 78 | <Button |
| 79 | onClick={() => stopEdit()} |
| 80 | icon="fa-times text-danger" |
| 81 | className="btn-xs" |
| 82 | > |
| 83 | Cancel |
| 84 | </Button> |
| 85 | </div> |
| 86 | <CodeEditor |
| 87 | initialContent={content || ""} |
| 88 | onChange={setEditedContent} |
| 89 | /> |
| 90 | </div> |
| 91 | ); |
| 92 | } |
| 93 | |
| 94 | type HttpMessageViewProps = { |
| 95 | flow: HTTPFlow; |
nothing calls this directly
no test coverage detected
searching dependent graphs…