diff --git a/frontend/app/components/Session_/Fetch/FetchDetails.js b/frontend/app/components/Session_/Fetch/FetchDetails.js index 666406b9f..79834d4a4 100644 --- a/frontend/app/components/Session_/Fetch/FetchDetails.js +++ b/frontend/app/components/Session_/Fetch/FetchDetails.js @@ -1,14 +1,14 @@ -import { JSONTree, Label, Button, Tabs } from 'UI' +import { JSONTree, NoContent, Button, Tabs } from 'UI' import cn from 'classnames'; import copy from 'copy-to-clipboard'; import stl from './fetchDetails.css'; -import ResultTimings from '../../shared/ResultTimings/ResultTimings'; +import Headers from './components/Headers' +const HEADERS = 'HEADERS'; const REQUEST = 'REQUEST'; const RESPONSE = 'RESPONSE'; -const TIMINGS = 'TIMINGS'; -const TABS = [ REQUEST, RESPONSE, TIMINGS ].map(tab => ({ text: tab, key: tab })); +const TABS = [ HEADERS, REQUEST, RESPONSE ].map(tab => ({ text: tab, key: tab })); export default class FetchDetails extends React.PureComponent { state = { activeTab: REQUEST, tabs: [] }; @@ -20,53 +20,62 @@ export default class FetchDetails extends React.PureComponent { } renderActiveTab = tab => { - const { resource: { duration, timings }, isResult } = this.props; + const { resource: { payload, response = this.props.resource.body} } = this.props; + let jsonPayload, jsonResponse, requestHeaders, responseHeaders = undefined; + + try { + jsonPayload = typeof payload === 'string' ? JSON.parse(payload) : payload + requestHeaders = jsonPayload.headers + delete jsonPayload.headers + } catch (e) {} + + try { + jsonResponse = typeof response === 'string' ? JSON.parse(response) : response; + responseHeaders = jsonResponse.headers + delete jsonResponse.headers + } catch (e) {} + switch(tab) { case REQUEST: - const { resource: { payload } } = this.props; - let jsonPayload = undefined; - try { - jsonPayload = typeof payload === 'string' ? JSON.parse(payload) : payload - } catch (e) {} - - return !!payload ? ( -
-
- {/*
{ 'Payload '}
*/} - { jsonPayload === undefined - ?
{ payload }
- : - } -
-
-
- ) : '' - break; + return ( + +
+
+ { jsonPayload === undefined + ?
{ payload }
+ : + } +
+
+
+ + ) case RESPONSE: - const { resource: { response = this.props.resource.body } } = this.props; // for IOS compat. - let jsonResponse = undefined; - try { - jsonResponse = JSON.parse(response); - } catch (e) {} - - return !!response ? ( -
-
- {/*
{ 'Response '}
*/} - { jsonResponse === undefined - ?
{ response }
- : - } -
-
-
- // jsonResponse === undefined - // ?
{ response }
- // : - ) : '' - break; - case TIMINGS: - return + return ( + +
+
+ { jsonResponse === undefined + ?
{ response }
+ : + } +
+
+
+ + ) + case HEADERS: + return } } @@ -78,21 +87,18 @@ export default class FetchDetails extends React.PureComponent { checkTabs() { const { resource: { payload, response, body }, isResult } = this.props; - const _tabs = TABS.filter(t => { - if (t.key == REQUEST && !!payload) { - return true - } + const _tabs = TABS + // const _tabs = TABS.filter(t => { + // if (t.key == REQUEST && !!payload) { + // return true + // } - if (t.key == RESPONSE && !!response) { - return true; - } + // if (t.key == RESPONSE && !!response) { + // return true; + // } - if (t.key == TIMINGS && isResult) { - return true; - } - - return false; - }) + // return false; + // }) this.setState({ tabs: _tabs, activeTab: _tabs.length > 0 ? _tabs[0].key : null }) } diff --git a/frontend/app/components/Session_/Fetch/components/Headers/Headers.tsx b/frontend/app/components/Session_/Fetch/components/Headers/Headers.tsx new file mode 100644 index 000000000..b54bb1de6 --- /dev/null +++ b/frontend/app/components/Session_/Fetch/components/Headers/Headers.tsx @@ -0,0 +1,50 @@ +import React from 'react' +import { NoContent } from 'UI' +import stl from './headers.css' + +function Headers(props) { + console.log('props', props); + return ( +
+ + { props.requestHeaders && ( + <> +
+
Request Headers
+ { + Object.keys(props.requestHeaders).map(h => ( +
+
{h}:
+
{props.requestHeaders[h]}
+
+ )) + } +
+
+ + )} + + { props.responseHeaders && ( +
+
Response Headers
+ { + Object.keys(props.responseHeaders).map(h => ( +
+
{h}:
+
{props.responseHeaders[h]}
+
+ )) + } +
+ )} +
+
+ ); +} + +export default Headers; \ No newline at end of file diff --git a/frontend/app/components/Session_/Fetch/components/Headers/headers.css b/frontend/app/components/Session_/Fetch/components/Headers/headers.css new file mode 100644 index 000000000..fbfae3ab0 --- /dev/null +++ b/frontend/app/components/Session_/Fetch/components/Headers/headers.css @@ -0,0 +1,8 @@ +.row { + display: flex; + padding: 5px 0px; + padding-left: 20px; + &:hover { + background-color: $active-blue; + } +} \ No newline at end of file diff --git a/frontend/app/components/Session_/Fetch/components/Headers/index.ts b/frontend/app/components/Session_/Fetch/components/Headers/index.ts new file mode 100644 index 000000000..69b6be26c --- /dev/null +++ b/frontend/app/components/Session_/Fetch/components/Headers/index.ts @@ -0,0 +1 @@ +export { default } from './Headers' \ No newline at end of file diff --git a/frontend/app/components/Session_/PageInsightsPanel/components/SelectorsList/SelectorsList.tsx b/frontend/app/components/Session_/PageInsightsPanel/components/SelectorsList/SelectorsList.tsx index bc435b26b..8f19bfad8 100644 --- a/frontend/app/components/Session_/PageInsightsPanel/components/SelectorsList/SelectorsList.tsx +++ b/frontend/app/components/Session_/PageInsightsPanel/components/SelectorsList/SelectorsList.tsx @@ -3,6 +3,7 @@ import { NoContent } from 'UI' import { connectPlayer } from 'Player/store'; import SelectorCard from '../SelectorCard/SelectorCard'; import type { MarkedTarget } from 'Player/MessageDistributor/StatedScreen/StatedScreen'; +import stl from './selectorList.css' interface Props { targets: Array, @@ -16,9 +17,11 @@ function SelectorsList({ targets, activeTargetIndex }: Props) { size="small" show={ targets && targets.length === 0 } > - { targets && targets.map((target, index) => ( - - ))} +
+ { targets && targets.map((target, index) => ( + + ))} +
) } diff --git a/frontend/app/components/Session_/PageInsightsPanel/components/SelectorsList/selectorList.css b/frontend/app/components/Session_/PageInsightsPanel/components/SelectorsList/selectorList.css new file mode 100644 index 000000000..dc90ac4e1 --- /dev/null +++ b/frontend/app/components/Session_/PageInsightsPanel/components/SelectorsList/selectorList.css @@ -0,0 +1,28 @@ +.wrapper { + height: calc(100vh - 190px); + overflow-y: auto; + &::-webkit-scrollbar { + width: 2px; + background: transparent !important; + background: rgba(0,0,0,0); + } + + &::-webkit-scrollbar-thumb { + background: transparent !important; + } + &::-webkit-scrollbar-track { + background: transparent !important; + } + &:hover { + &::-webkit-scrollbar { + width: 2px; + background: rgba(0,0,0,0.1) + } + &::-webkit-scrollbar-track { + background: rgba(0,0,0,0.1) + } + &::-webkit-scrollbar-thumb { + background: rgba(0,0,0,0.1) + } + } +} \ No newline at end of file