@@ -92,6 +92,22 @@ viewTabs maybeEvent activeTab maybeDiagnosis =
9292 , tabButton " CORS" CorsTab activeTab
9393 , tabButton " SDK State" SdkStateTab activeTab
9494 ]
95+ ++ ( case maybeEvent of
96+ Just event ->
97+ case event. data of
98+ Network net ->
99+ if net. requestBody /= Nothing || net. responseBody /= Nothing then
100+ [ tabButton " Payload" PayloadTab activeTab ]
101+
102+ else
103+ []
104+
105+ _ ->
106+ []
107+
108+ Nothing ->
109+ []
110+ )
95111 ++ ( if isSdkEvent then
96112 [ tabButton " Collectors" CollectorsTab activeTab ]
97113
@@ -166,19 +182,35 @@ viewContent maybeEvent activeTab maybeDiagnosis =
166182 Just h -> JsonTree . view " Response Headers" h
167183 Nothing -> viewEmptySection " Response Headers"
168184 ]
169- ++ ( case net. requestBody of
170- Just b -> [ JsonTree . view " Request Body" b ]
171- Nothing -> []
172- )
185+ )
186+
187+ _ ->
188+ div [ class " insp-empty" ]
189+ [ text " Select a network request to see headers." ]
190+
191+ ( Just event, PayloadTab ) ->
192+ case event. data of
193+ Network net ->
194+ div []
195+ (( case net. requestBody of
196+ Just b ->
197+ [ viewPayloadSection " Request Body" b ]
198+
199+ Nothing ->
200+ []
201+ )
173202 ++ ( case net. responseBody of
174- Just b -> [ JsonTree . view " Response Body" b ]
175- Nothing -> []
203+ Just b ->
204+ [ viewPayloadSection " Response Body" b ]
205+
206+ Nothing ->
207+ []
176208 )
177209 )
178210
179211 _ ->
180212 div [ class " insp-empty" ]
181- [ text " Select a network request to see headers ." ]
213+ [ text " No payload data for this event ." ]
182214
183215 ( Just event, CookiesTab ) ->
184216 case event. data of
@@ -407,6 +439,21 @@ viewEmptySection label =
407439 ]
408440
409441
442+ viewPayloadSection : String -> Decode .Value -> Html Msg
443+ viewPayloadSection label body =
444+ div [ class " payload-section" ]
445+ [ div [ class " payload-header" ]
446+ [ div [ class " sect-hdr" , style " margin" " 0" , style " border" " none" , style " padding" " 0" ] [ text label ]
447+ , button
448+ [ class " fv-copy-btn"
449+ , onClick ( CopyToClipboard ( Encode . encode 4 body))
450+ ]
451+ [ text " \u{2398}" ]
452+ ]
453+ , JsonTree . view " " body
454+ ]
455+
456+
410457viewCookies : NetworkData -> List (Html Msg )
411458viewCookies net =
412459 let
0 commit comments