mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-29 09:39:54 +00:00
Instead of passing the style to Queryable
, pass the children components directly
This commit is contained in:
parent
fb11d566b1
commit
2ca16a0b81
@ -38,28 +38,36 @@ const EntryTitle: React.FC<any> = ({protocol, data, bodySize, elapsedTime, updat
|
|||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const response = data.response;
|
const response = data.response;
|
||||||
|
|
||||||
|
const bodySizeChild = <div
|
||||||
|
style={{margin: "0 18px", opacity: 0.5}}
|
||||||
|
>
|
||||||
|
{formatSize(bodySize)}
|
||||||
|
</div>;
|
||||||
|
|
||||||
|
const elapsedTimeChild = <div
|
||||||
|
style={{marginRight: 18, opacity: 0.5}}
|
||||||
|
>
|
||||||
|
{Math.round(elapsedTime)}ms
|
||||||
|
</div>;
|
||||||
|
|
||||||
|
|
||||||
return <div className={classes.entryTitle}>
|
return <div className={classes.entryTitle}>
|
||||||
<Protocol protocol={protocol} horizontal={true} updateQuery={null}/>
|
<Protocol protocol={protocol} horizontal={true} updateQuery={null}/>
|
||||||
<div style={{right: "30px", position: "absolute", display: "flex"}}>
|
<div style={{right: "30px", position: "absolute", display: "flex"}}>
|
||||||
{response && <Queryable
|
{response && <Queryable
|
||||||
text={formatSize(bodySize)}
|
|
||||||
query={`response.bodySize == ${bodySize}`}
|
query={`response.bodySize == ${bodySize}`}
|
||||||
updateQuery={updateQuery}
|
updateQuery={updateQuery}
|
||||||
textStyle={{opacity: 0.5}}
|
|
||||||
wrapperStyle={{margin: "0 18px"}}
|
|
||||||
applyTextEllipsis={false}
|
|
||||||
displayIconOnMouseOver={true}
|
displayIconOnMouseOver={true}
|
||||||
/>}
|
>
|
||||||
|
{bodySizeChild}
|
||||||
|
</Queryable>}
|
||||||
{response && <Queryable
|
{response && <Queryable
|
||||||
text={`${Math.round(elapsedTime)}ms`}
|
|
||||||
query={`elapsedTime >= ${elapsedTime}`}
|
query={`elapsedTime >= ${elapsedTime}`}
|
||||||
updateQuery={updateQuery}
|
updateQuery={updateQuery}
|
||||||
textStyle={{opacity: 0.5}}
|
|
||||||
wrapperStyle={{marginRight: 18}}
|
|
||||||
applyTextEllipsis={false}
|
|
||||||
displayIconOnMouseOver={true}
|
displayIconOnMouseOver={true}
|
||||||
/>}
|
>
|
||||||
|
{elapsedTimeChild}
|
||||||
|
</Queryable>}
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
@ -29,14 +29,12 @@ const EntryViewLine: React.FC<EntryViewLineProps> = ({label, value, updateQuery,
|
|||||||
return (label && value && <tr className={styles.dataLine}>
|
return (label && value && <tr className={styles.dataLine}>
|
||||||
<td>
|
<td>
|
||||||
<Queryable
|
<Queryable
|
||||||
text={label}
|
|
||||||
query={query}
|
query={query}
|
||||||
updateQuery={updateQuery}
|
updateQuery={updateQuery}
|
||||||
wrapperStyle={{float: "right"}}
|
|
||||||
className={`${styles.dataKey}`}
|
|
||||||
applyTextEllipsis={false}
|
|
||||||
displayIconOnMouseOver={true}
|
displayIconOnMouseOver={true}
|
||||||
/>
|
>
|
||||||
|
<div className={`${styles.dataKey}`}>{label}</div>
|
||||||
|
</Queryable>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<FancyTextDisplay
|
<FancyTextDisplay
|
||||||
@ -59,9 +57,9 @@ interface EntrySectionCollapsibleTitleProps {
|
|||||||
|
|
||||||
const EntrySectionCollapsibleTitle: React.FC<EntrySectionCollapsibleTitleProps> = ({title, color, isExpanded}) => {
|
const EntrySectionCollapsibleTitle: React.FC<EntrySectionCollapsibleTitleProps> = ({title, color, isExpanded}) => {
|
||||||
return <div className={styles.title}>
|
return <div className={styles.title}>
|
||||||
<span className={`${styles.button} ${isExpanded ? styles.expanded : ''}`} style={{backgroundColor: color}}>
|
<div className={`${styles.button} ${isExpanded ? styles.expanded : ''}`} style={{backgroundColor: color}}>
|
||||||
{isExpanded ? '-' : '+'}
|
{isExpanded ? '-' : '+'}
|
||||||
</span>
|
</div>
|
||||||
<span>{title}</span>
|
<span>{title}</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@
|
|||||||
flex-direction: column
|
flex-direction: column
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
padding-right: 10px
|
padding-right: 10px
|
||||||
padding-left: 10px
|
|
||||||
flex-grow: 1
|
flex-grow: 1
|
||||||
|
|
||||||
.separatorRight
|
.separatorRight
|
||||||
|
@ -4,24 +4,18 @@ import AddCircleIcon from '@material-ui/icons/AddCircle';
|
|||||||
import './style/Queryable.sass';
|
import './style/Queryable.sass';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
text: string | number,
|
|
||||||
query: string,
|
query: string,
|
||||||
updateQuery: any,
|
updateQuery: any,
|
||||||
title?: string,
|
style?: object,
|
||||||
textStyle?: object,
|
|
||||||
wrapperStyle?: object,
|
|
||||||
className?: string,
|
className?: string,
|
||||||
isPossibleToCopy?: boolean,
|
|
||||||
applyTextEllipsis?: boolean,
|
|
||||||
useTooltip?: boolean,
|
useTooltip?: boolean,
|
||||||
displayIconOnMouseOver?: boolean,
|
displayIconOnMouseOver?: boolean,
|
||||||
onClick?: React.EventHandler<React.MouseEvent<HTMLElement>>;
|
flipped?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Queryable: React.FC<Props> = ({text, query, updateQuery, title, textStyle, wrapperStyle, className, isPossibleToCopy = true, applyTextEllipsis = true, useTooltip= false, displayIconOnMouseOver = false}) => {
|
const Queryable: React.FC<Props> = ({query, updateQuery, style, className, useTooltip= false, displayIconOnMouseOver = false, flipped = false, children}) => {
|
||||||
const [showAddedNotification, setAdded] = useState(false);
|
const [showAddedNotification, setAdded] = useState(false);
|
||||||
const [showTooltip, setShowTooltip] = useState(false);
|
const [showTooltip, setShowTooltip] = useState(false);
|
||||||
text = String(text);
|
|
||||||
|
|
||||||
const onCopy = () => {
|
const onCopy = () => {
|
||||||
setAdded(true)
|
setAdded(true)
|
||||||
@ -39,28 +33,27 @@ const Queryable: React.FC<Props> = ({text, query, updateQuery, title, textStyle,
|
|||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [showAddedNotification]);
|
}, [showAddedNotification]);
|
||||||
|
|
||||||
const textElement = <span title={title} className={'Queryable-Text'} style={textStyle}>{text}</span>;
|
const addButton = query ? <CopyToClipboard text={query} onCopy={onCopy}>
|
||||||
|
|
||||||
const copyButton = text ? <CopyToClipboard text={text} onCopy={onCopy}>
|
|
||||||
<span
|
<span
|
||||||
className={`Queryable-Icon`}
|
className={`Queryable-Icon`}
|
||||||
title={`Add "${query}" to the filter`}
|
title={`Add "${query}" to the filter`}
|
||||||
>
|
>
|
||||||
<AddCircleIcon fontSize="small" color="inherit"></AddCircleIcon>
|
<AddCircleIcon fontSize="small" color="inherit"></AddCircleIcon>
|
||||||
{showAddedNotification && <span className={'Queryable-CopyNotifier'}>Added</span>}
|
{showAddedNotification && <span className={'Queryable-AddNotifier'}>Added</span>}
|
||||||
</span>
|
</span>
|
||||||
</CopyToClipboard> : null;
|
</CopyToClipboard> : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`Queryable-Container displayIconOnMouseOver ${className ? className : ''} ${displayIconOnMouseOver ? 'displayIconOnMouseOver ' : ''} ${applyTextEllipsis ? ' Queryable-ContainerEllipsis' : ''}`}
|
className={`Queryable-Container displayIconOnMouseOver ${className ? className : ''} ${displayIconOnMouseOver ? 'displayIconOnMouseOver ' : ''}`}
|
||||||
style={wrapperStyle}
|
style={style}
|
||||||
onMouseOver={ e => setShowTooltip(true)}
|
onMouseOver={ e => setShowTooltip(true)}
|
||||||
onMouseLeave={ e => setShowTooltip(false)}
|
onMouseLeave={ e => setShowTooltip(false)}
|
||||||
>
|
>
|
||||||
{textElement}
|
{flipped && addButton}
|
||||||
{copyButton}
|
{children}
|
||||||
{useTooltip && showTooltip && <span className={'Queryable-CopyNotifier'}>{text}</span>}
|
{!flipped && addButton}
|
||||||
|
{useTooltip && showTooltip && <span className={'Queryable-AddNotifier'}></span>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import styles from './style/StatusCode.module.sass';
|
import styles from './style/StatusCode.module.sass';
|
||||||
|
import Queryable from "./Queryable";
|
||||||
|
|
||||||
export enum StatusCodeClassification {
|
export enum StatusCodeClassification {
|
||||||
SUCCESS = "success",
|
SUCCESS = "success",
|
||||||
@ -16,15 +17,21 @@ const StatusCode: React.FC<EntryProps> = ({statusCode, updateQuery}) => {
|
|||||||
|
|
||||||
const classification = getClassification(statusCode)
|
const classification = getClassification(statusCode)
|
||||||
|
|
||||||
return <span
|
const child = <span
|
||||||
title="Status Code"
|
title="Status Code"
|
||||||
className={`queryable ${styles[classification]} ${styles.base}`}
|
className={`${styles[classification]} ${styles.base}`}
|
||||||
onClick={() => {
|
|
||||||
updateQuery(`response.status == ${statusCode}`)
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{statusCode}
|
{statusCode}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
return <Queryable
|
||||||
|
query={`response.status == ${statusCode}`}
|
||||||
|
updateQuery={updateQuery}
|
||||||
|
style={{minWidth: "68px"}}
|
||||||
|
displayIconOnMouseOver={true}
|
||||||
|
>
|
||||||
|
{child}
|
||||||
|
</Queryable>
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getClassification(statusCode: number): string {
|
export function getClassification(statusCode: number): string {
|
||||||
|
@ -10,25 +10,35 @@ interface SummaryProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Summary: React.FC<SummaryProps> = ({method, summary, updateQuery}) => {
|
export const Summary: React.FC<SummaryProps> = ({method, summary, updateQuery}) => {
|
||||||
|
|
||||||
|
const methodChild = <span
|
||||||
|
className={`queryable`}
|
||||||
|
>
|
||||||
|
{method}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
const summaryChild = <div
|
||||||
|
className={`queryable ${styles.summary}`}
|
||||||
|
>
|
||||||
|
{summary}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
return <div className={styles.container}>
|
return <div className={styles.container}>
|
||||||
{method && <Queryable
|
{method && <Queryable
|
||||||
text={method}
|
|
||||||
query={`method == "${method}"`}
|
query={`method == "${method}"`}
|
||||||
updateQuery={updateQuery}
|
|
||||||
title="Method"
|
|
||||||
className={`${miscStyles.protocol} ${miscStyles.method}`}
|
className={`${miscStyles.protocol} ${miscStyles.method}`}
|
||||||
wrapperStyle={{height: "14px"}}
|
updateQuery={updateQuery}
|
||||||
applyTextEllipsis={false}
|
|
||||||
displayIconOnMouseOver={true}
|
displayIconOnMouseOver={true}
|
||||||
/>}
|
>
|
||||||
|
{methodChild}
|
||||||
|
</Queryable>}
|
||||||
{summary && <Queryable
|
{summary && <Queryable
|
||||||
text={summary}
|
|
||||||
query={`summary == "${summary}"`}
|
query={`summary == "${summary}"`}
|
||||||
updateQuery={updateQuery}
|
updateQuery={updateQuery}
|
||||||
title="Summary"
|
|
||||||
className={`${styles.summary}`}
|
|
||||||
applyTextEllipsis={false}
|
|
||||||
displayIconOnMouseOver={true}
|
displayIconOnMouseOver={true}
|
||||||
/>}
|
>
|
||||||
|
{summaryChild}
|
||||||
|
</Queryable>}
|
||||||
</div>
|
</div>
|
||||||
};
|
};
|
||||||
|
@ -25,15 +25,7 @@
|
|||||||
border-radius: 4px
|
border-radius: 4px
|
||||||
color: #1E884B
|
color: #1E884B
|
||||||
|
|
||||||
&.Queryable-ContainerEllipsis
|
.Queryable-AddNotifier
|
||||||
.Queryable-Text
|
|
||||||
text-align: left
|
|
||||||
text-overflow: ellipsis
|
|
||||||
overflow: hidden
|
|
||||||
white-space: nowrap
|
|
||||||
width: calc(100% - 30px)
|
|
||||||
|
|
||||||
.Queryable-CopyNotifier
|
|
||||||
background-color: #1E884B
|
background-color: #1E884B
|
||||||
font-weight: normal
|
font-weight: normal
|
||||||
padding: 2px 5px
|
padding: 2px 5px
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
&.method
|
&.method
|
||||||
margin-right: 10px
|
margin-right: 10px
|
||||||
|
height: 14px
|
||||||
|
|
||||||
&.filterPlate
|
&.filterPlate
|
||||||
border-color: #bcc6dd20
|
border-color: #bcc6dd20
|
||||||
|
Loading…
Reference in New Issue
Block a user