({ flow, message, startEdit }: HttpMessageViewProps)
| 98 | }; |
| 99 | |
| 100 | function HttpMessageView({ flow, message, startEdit }: HttpMessageViewProps) { |
| 101 | const dispatch = useAppDispatch(); |
| 102 | const part = flow.request === message ? "request" : "response"; |
| 103 | const contentView = useAppSelector( |
| 104 | (state) => state.ui.flow.contentViewFor[flow.id + part] || "Auto", |
| 105 | ); |
| 106 | |
| 107 | const [maxLines, setMaxLines] = useState<number>( |
| 108 | useAppSelector((state) => state.options.content_view_lines_cutoff), |
| 109 | ); |
| 110 | const showMore = useCallback( |
| 111 | () => setMaxLines(Math.max(1024, maxLines * 2)), |
| 112 | [maxLines], |
| 113 | ); |
| 114 | |
| 115 | const contentViewData = useContentView( |
| 116 | flow, |
| 117 | message, |
| 118 | contentView, |
| 119 | maxLines + 1, |
| 120 | message.contentHash, |
| 121 | ); |
| 122 | |
| 123 | let desc: string; |
| 124 | if (message.contentLength === 0) { |
| 125 | desc = "No content"; |
| 126 | } else if (contentViewData === undefined) { |
| 127 | desc = "Loading..."; |
| 128 | } else { |
| 129 | desc = |
| 130 | `${contentViewData.view_name} ${contentViewData.description}`.trimEnd(); |
| 131 | } |
| 132 | |
| 133 | return ( |
| 134 | <div className="contentview" key="view"> |
| 135 | <div className="controls"> |
| 136 | <h5>{desc}</h5> |
| 137 | {contentViewData && contentViewData?.text.length > 0 && ( |
| 138 | <CopyButton flow={flow} message={message} /> |
| 139 | )} |
| 140 | |
| 141 | <Button onClick={startEdit} icon="fa-edit" className="btn-xs"> |
| 142 | Edit |
| 143 | </Button> |
| 144 | |
| 145 | <FileChooser |
| 146 | icon="fa-upload" |
| 147 | text="Replace" |
| 148 | title="Upload a file to replace the content." |
| 149 | onOpenFile={(content) => |
| 150 | dispatch(uploadContent(flow, content, part)) |
| 151 | } |
| 152 | className="btn btn-default btn-xs" |
| 153 | /> |
| 154 | |
| 155 | <ViewSelector |
| 156 | value={contentView} |
| 157 | onChange={(cv) => |
nothing calls this directly
no test coverage detected
searching dependent graphs…