mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-02 11:05:22 +00:00
Fix all of the minor issues in the React code
This commit is contained in:
@@ -201,7 +201,6 @@ export const EntryPolicySectionContainer: React.FC<EntryPolicySectionContainerPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const EntryTablePolicySection: React.FC<EntryPolicySectionProps> = ({service, title, color, response, latency, arrayToIterate}) => {
|
export const EntryTablePolicySection: React.FC<EntryPolicySectionProps> = ({service, title, color, response, latency, arrayToIterate}) => {
|
||||||
// const base64ToJson = response.content.mimeType === "application/json; charset=utf-8" ? JSON.parse(Buffer.from(response.content.text, "base64").toString()) : {};
|
|
||||||
return <React.Fragment>
|
return <React.Fragment>
|
||||||
{
|
{
|
||||||
arrayToIterate && arrayToIterate.length > 0 ?
|
arrayToIterate && arrayToIterate.length > 0 ?
|
||||||
@@ -215,39 +214,32 @@ export const EntryTablePolicySection: React.FC<EntryPolicySectionProps> = ({serv
|
|||||||
{
|
{
|
||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
rule.Key !== "" ?
|
rule.Key &&
|
||||||
<tr className={styles.dataValue}><td><b>Key</b>:</td><td>{rule.Key}</td></tr>
|
<tr className={styles.dataValue}><td><b>Key</b>:</td><td>{rule.Key}</td></tr>
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
rule.Latency !== "" ?
|
rule.Latency &&
|
||||||
<tr className={styles.dataValue}><td><b>Latency:</b></td> <td>{rule.Latency}</td></tr>
|
<tr className={styles.dataValue}><td><b>Latency:</b></td> <td>{rule.Latency}</td></tr>
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
rule.Method !== "" ?
|
rule.Method &&
|
||||||
<tr className={styles.dataValue}><td><b>Method:</b></td> <td>{rule.Method}</td></tr>
|
<tr className={styles.dataValue}><td><b>Method:</b></td> <td>{rule.Method}</td></tr>
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
rule.Path !== "" ?
|
rule.Path &&
|
||||||
<tr className={styles.dataValue}><td><b>Path:</b></td> <td>{rule.Path}</td></tr>
|
<tr className={styles.dataValue}><td><b>Path:</b></td> <td>{rule.Path}</td></tr>
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
rule.Service !== "" ?
|
rule.Service &&
|
||||||
<tr className={styles.dataValue}><td><b>Service:</b></td> <td>{service}</td></tr>
|
<tr className={styles.dataValue}><td><b>Service:</b></td> <td>{service}</td></tr>
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
rule.Type !== "" ?
|
rule.Type &&
|
||||||
<tr className={styles.dataValue}><td><b>Type:</b></td> <td>{rule.Type}</td></tr>
|
<tr className={styles.dataValue}><td><b>Type:</b></td> <td>{rule.Type}</td></tr>
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
rule.Value !== "" ?
|
rule.Value &&
|
||||||
<tr className={styles.dataValue}><td><b>Value:</b></td> <td>{rule.Value}</td></tr>
|
<tr className={styles.dataValue}><td><b>Value:</b></td> <td>{rule.Value}</td></tr>
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
@@ -3,18 +3,23 @@ import styles from './EntryViewer.module.sass';
|
|||||||
import Tabs from "../UI/Tabs";
|
import Tabs from "../UI/Tabs";
|
||||||
import {EntryTableSection, EntryBodySection, EntryTablePolicySection} from "./EntrySections";
|
import {EntryTableSection, EntryBodySection, EntryTablePolicySection} from "./EntrySections";
|
||||||
|
|
||||||
|
enum SectionTypes {
|
||||||
|
SectionTable = "table",
|
||||||
|
SectionBody = "body",
|
||||||
|
}
|
||||||
|
|
||||||
const SectionsRepresentation: React.FC<any> = ({data, color}) => {
|
const SectionsRepresentation: React.FC<any> = ({data, color}) => {
|
||||||
const sections = []
|
const sections = []
|
||||||
|
|
||||||
if (data !== undefined) {
|
if (data) {
|
||||||
for (const [i, row] of data.entries()) {
|
for (const [i, row] of data.entries()) {
|
||||||
switch (row.type) {
|
switch (row.type) {
|
||||||
case "table":
|
case SectionTypes.SectionTable:
|
||||||
sections.push(
|
sections.push(
|
||||||
<EntryTableSection key={i} title={row.title} color={color} arrayToIterate={JSON.parse(row.data)}/>
|
<EntryTableSection key={i} title={row.title} color={color} arrayToIterate={JSON.parse(row.data)}/>
|
||||||
)
|
)
|
||||||
break;
|
break;
|
||||||
case "body":
|
case SectionTypes.SectionBody:
|
||||||
sections.push(
|
sections.push(
|
||||||
<EntryBodySection key={i} color={color} content={row.data} encoding={row.encoding} contentType={row.mime_type}/>
|
<EntryBodySection key={i} color={color} content={row.data} encoding={row.encoding} contentType={row.mime_type}/>
|
||||||
)
|
)
|
||||||
@@ -28,13 +33,14 @@ const SectionsRepresentation: React.FC<any> = ({data, color}) => {
|
|||||||
return <>{sections}</>;
|
return <>{sections}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AutoRepresentation: React.FC<any> = ({representation, color, isResponseMocked}) => {
|
const AutoRepresentation: React.FC<any> = ({representation, color}) => {
|
||||||
const rulesMatched = []
|
const rulesMatched = []
|
||||||
const TABS = [
|
const TABS = [
|
||||||
{tab: 'request'},
|
{
|
||||||
|
tab: 'request'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
tab: 'response',
|
tab: 'response',
|
||||||
badge: <>{isResponseMocked && <span className="smallBadge virtual mock">MOCK</span>}</>
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tab: 'Rules',
|
tab: 'Rules',
|
||||||
@@ -43,7 +49,7 @@ const AutoRepresentation: React.FC<any> = ({representation, color, isResponseMoc
|
|||||||
const [currentTab, setCurrentTab] = useState(TABS[0].tab);
|
const [currentTab, setCurrentTab] = useState(TABS[0].tab);
|
||||||
|
|
||||||
// Don't fail even if `representation` is an empty string
|
// Don't fail even if `representation` is an empty string
|
||||||
if (representation.length === 0) {
|
if (!representation) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,12 +78,10 @@ const AutoRepresentation: React.FC<any> = ({representation, color, isResponseMoc
|
|||||||
interface Props {
|
interface Props {
|
||||||
representation: any;
|
representation: any;
|
||||||
color: string,
|
color: string,
|
||||||
isResponseMocked?: boolean;
|
|
||||||
showTitle?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const EntryViewer: React.FC<Props> = ({representation, color, isResponseMocked, showTitle=true}) => {
|
const EntryViewer: React.FC<Props> = ({representation, color}) => {
|
||||||
return <AutoRepresentation representation={representation} color={color} isResponseMocked={isResponseMocked} showTitle={showTitle}/>
|
return <AutoRepresentation representation={representation} color={color}/>
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EntryViewer;
|
export default EntryViewer;
|
||||||
|
@@ -25,6 +25,8 @@ const StatusCode: React.FC<EntryProps> = ({statusCode}) => {
|
|||||||
export function getClassification(statusCode: number): string {
|
export function getClassification(statusCode: number): string {
|
||||||
let classification = StatusCodeClassification.NEUTRAL;
|
let classification = StatusCodeClassification.NEUTRAL;
|
||||||
|
|
||||||
|
// 1 - 16 HTTP/2 (gRPC) status codes
|
||||||
|
// 2xx - 5xx HTTP/1.1 status codes
|
||||||
if ((statusCode >= 200 && statusCode <= 399) || statusCode === 0) {
|
if ((statusCode >= 200 && statusCode <= 399) || statusCode === 0) {
|
||||||
classification = StatusCodeClassification.SUCCESS;
|
classification = StatusCodeClassification.SUCCESS;
|
||||||
} else if (statusCode >= 400 || (statusCode >= 1 && statusCode <= 16)) {
|
} else if (statusCode >= 400 || (statusCode >= 1 && statusCode <= 16)) {
|
||||||
|
@@ -5,18 +5,18 @@
|
|||||||
font-weight: 600
|
font-weight: 600
|
||||||
background-color: #000
|
background-color: #000
|
||||||
color: #fff
|
color: #fff
|
||||||
margin-left: -8px;
|
margin-left: -8px
|
||||||
margin-bottom: -4px;
|
margin-bottom: -4px
|
||||||
|
|
||||||
.vertical
|
.vertical
|
||||||
line-height: 22px
|
line-height: 22px
|
||||||
letter-spacing: 0.5px;
|
letter-spacing: 0.5px
|
||||||
width: 22px
|
width: 22px
|
||||||
height: 48px
|
height: 48px
|
||||||
border-radius: 0px 4px 4px 0
|
border-radius: 0px 4px 4px 0
|
||||||
writing-mode: vertical-lr;
|
writing-mode: vertical-lr
|
||||||
transform: rotate(-180deg);
|
transform: rotate(-180deg)
|
||||||
text-orientation: mixed;
|
text-orientation: mixed
|
||||||
|
|
||||||
.horizontal
|
.horizontal
|
||||||
border-radius: 4px
|
border-radius: 4px
|
||||||
|
Reference in New Issue
Block a user