({ flow }: { flow: Flow })
| 122 | }; |
| 123 | |
| 124 | function DownloadButton({ flow }: { flow: Flow }) { |
| 125 | const hasSingleFlowSelected = useAppSelector( |
| 126 | (state) => state.flows.selected.length === 1, |
| 127 | ); |
| 128 | |
| 129 | if (flow.type !== "http") |
| 130 | return ( |
| 131 | <Button icon="fa-download" onClick={() => 0} disabled> |
| 132 | Download |
| 133 | </Button> |
| 134 | ); |
| 135 | |
| 136 | if (flow.request.contentLength && !flow.response?.contentLength) { |
| 137 | return ( |
| 138 | <Button |
| 139 | icon="fa-download" |
| 140 | onClick={() => |
| 141 | openInNewTab(MessageUtils.getContentURL(flow, flow.request)) |
| 142 | } |
| 143 | disabled={!hasSingleFlowSelected} |
| 144 | > |
| 145 | Download |
| 146 | </Button> |
| 147 | ); |
| 148 | } |
| 149 | if (flow.response) { |
| 150 | const response = flow.response; |
| 151 | if (!flow.request.contentLength && flow.response.contentLength) { |
| 152 | return ( |
| 153 | <Button |
| 154 | icon="fa-download" |
| 155 | onClick={() => |
| 156 | openInNewTab(MessageUtils.getContentURL(flow, response)) |
| 157 | } |
| 158 | disabled={!hasSingleFlowSelected} |
| 159 | > |
| 160 | Download |
| 161 | </Button> |
| 162 | ); |
| 163 | } |
| 164 | if (flow.request.contentLength && flow.response.contentLength) { |
| 165 | return ( |
| 166 | <Dropdown |
| 167 | text={ |
| 168 | <Button |
| 169 | icon="fa-download" |
| 170 | onClick={() => 1} |
| 171 | disabled={!hasSingleFlowSelected} |
| 172 | > |
| 173 | Download▾ |
| 174 | </Button> |
| 175 | } |
| 176 | options={{ placement: "bottom-start" }} |
| 177 | > |
| 178 | <MenuItem |
| 179 | onClick={() => |
| 180 | openInNewTab( |
| 181 | MessageUtils.getContentURL(flow, flow.request), |
nothing calls this directly
no test coverage detected
searching dependent graphs…