Skip to content

Commit

Permalink
style adjustments and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi-sl committed Aug 23, 2024
1 parent 7535895 commit ca255b0
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/Components/NetworkTable/NetworkTableBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const virtualizedTableRow = ({
entry={item}
maxTime={totalNetworkTime}
onSelect={handleReqSelect}
scrollHighlight={selectedReqIndex === index}
scrollHighlight={selectedReqIndex === item.index}
style={style}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions src/Components/ReqDetail/CopyAllButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ const CopyAllButton = ({ text }) => {
};

CopyAllButton.propTypes = {
text: PropTypes.object,
text: PropTypes.any,
};

CopyAllButton.defaultProps = {
text: 'testi testi',
text: '',
};

export default CopyAllButton;
38 changes: 28 additions & 10 deletions src/Components/ReqDetail/ReqDetail.styles.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
@import "./../../styles/variables";

.no-data {
display: flex;
align-items: center;
justify-content: center;
font-size: $font-size-h4;
width: 100%;
color: $brand-primary-dark-gray;
}

.section-container {
width: 100%;
}
Expand Down Expand Up @@ -53,7 +44,7 @@
}

.section-detail {
padding: $size-xs-s;
padding: $size-xs-s $size-s;

.info-row {
margin: 0;
Expand All @@ -74,3 +65,30 @@
word-break: break-all;
}
}

.no-payload {
display: flex;
align-items: center;
justify-content: center;
font-size: $font-size-h4;
width: 100%;
color: $brand-primary-dark-gray;
}

.response-content {
font-size: $font-size-small;
width: 100%;
display: flex;
flex-direction: column;

.copy-button {
align-self: end;
}

.payload-body {
font-family: monospace;
white-space: pre-wrap;
word-break: break-all;
}
}

7 changes: 4 additions & 3 deletions src/Components/ReqDetail/Request.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Request = ({ data }) => {
!data.headers.postData?.params &&
!data.headers.queryString?.length
) {
return (<h4 className={Styles['no-data']}>This request has no request data available.</h4>);
return (<h4 className={Styles['no-payload']}>This request has no request data available.</h4>);
}

return (!data ? null : (
Expand All @@ -23,16 +23,17 @@ const Request = ({ data }) => {
data={data}
eventKey="requestPayload"
isParseEnabled
isVisible
/>
)}
{(data.headers.queryString && data.headers.queryString.length) ? (
{data.headers.queryString && !!data.headers.queryString.length && (
<SectionInfo
component={QueryString}
data={data}
eventKey="queryString"
isEncodeEnabled
/>
) : null}
)}
{data.headers.postData && data.headers.postData.params && (
<SectionInfo
component={FormData}
Expand Down
27 changes: 0 additions & 27 deletions src/Components/ReqDetail/Request.styles.scss

This file was deleted.

18 changes: 10 additions & 8 deletions src/Components/ReqDetail/Response.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';

import Styles from './Response.styles.scss';
import Styles from './ReqDetail.styles.scss';
import CopyAllButton from './CopyAllButton';

const NoResponseText = () => (
<h4 className={Styles['no-response']}>This request has no response data available.</h4>
<h4 className={Styles['no-payload']}>This request has no response data available.</h4>
);

const Response = ({ data }) => {
Expand All @@ -16,13 +16,15 @@ const Response = ({ data }) => {
}

return (
<div className={Styles['response-content']}>
<div className={Styles['copy-button']}>
<CopyAllButton text={content} />
<div className={Styles['section-detail']}>
<div className={Styles['response-content']}>
<div className={Styles['copy-button']}>
<CopyAllButton text={content} />
</div>
<span className={Styles['payload-body']}>
{content}
</span>
</div>
<span className={Styles['response-body']}>
{content}
</span>
</div>
);
};
Expand Down
28 changes: 0 additions & 28 deletions src/Components/ReqDetail/Response.styles.scss

This file was deleted.

15 changes: 9 additions & 6 deletions src/Components/ReqDetail/sections/RequestPayload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ import PropTypes from 'prop-types';

import Styles from './../ReqDetail.styles.scss';
import { parseRequestPayload } from '../../../utils';
import CopyAllButton from '../CopyAllButton';

const RequestPayload = ({ data, isPayloadTransformed }) => {
const payloadData = data.headers.postData.text;
const parsedData = useMemo(() => parseRequestPayload(payloadData), [payloadData]);
const payload = isPayloadTransformed ? parsedData : payloadData;

return (
<div className={Styles['section-detail']}>
{isPayloadTransformed ? (
<div className={Styles['response-content']}>
<pre className={Styles['log-body-colorless']}>
{parsedData}
</pre>
<div className={Styles['response-content']}>
<div className={Styles['copy-button']}>
<CopyAllButton text={payload} />
</div>
) : payloadData}
<div className={Styles['payload-body']}>
{payload}
</div>
</div>
</div>
);
};
Expand Down
4 changes: 0 additions & 4 deletions src/Components/ReqDetail/sections/SectionInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames/bind';

import Styles from './../ReqDetail.styles.scss';
import SectionTitle from './SectionTitle';

const context = classNames.bind(Styles);

const SectionInfo = ({
eventKey,
data,
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const prepareViewerData = (entries) => {
const lastTimeOfEntry = getTotalTimeOfEntry(entry);
endTime = endTime < lastTimeOfEntry ? lastTimeOfEntry : endTime;
return {
index: +entry.connection || index,
index,
status: entry.response.status,
method: entry.request.method,
size: parseSize(entry.response),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
exports[`Response renders without crashing for content 1`] = `
<div>
<div>
<CopyAllButton
text="{\\"foo\\": \\"bar\\"}"
/>
<div>
<CopyAllButton
text="{\\"foo\\": \\"bar\\"}"
/>
</div>
<span>
{"foo": "bar"}
</span>
</div>
<span>
{"foo": "bar"}
</span>
</div>
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
exports[`RequestPayload renders without crashing 1`] = `
<div>
<div>
<pre>
<div>
<CopyAllButton
text="{ 'name': 'foo' }"
/>
</div>
<div>
{ 'name': 'foo' }
</pre>
</div>
</div>
</div>
`;
Loading

0 comments on commit ca255b0

Please sign in to comment.