Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mizu
Commits
203b3f0d
Commit
203b3f0d
authored
2 years ago
by
Amit Fainholts
Browse files
Options
Download
Email Patches
Plain Diff
number of lines state added
parent
5fc3e38c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ui-common/src/components/TrafficViewer/EntryDetailed/EntrySections.tsx
+21
-9
.../components/TrafficViewer/EntryDetailed/EntrySections.tsx
ui-common/src/components/UI/SyntaxHighlighter/index.tsx
+4
-1
ui-common/src/components/UI/SyntaxHighlighter/index.tsx
with
25 additions
and
10 deletions
+25
-10
ui-common/src/components/TrafficViewer/EntryDetailed/EntrySections.tsx
+
21
-
9
View file @
203b3f0d
...
...
@@ -131,6 +131,14 @@ export const EntryBodySection: React.FC<EntryBodySectionProps> = ({
const
isBase64Encoding
=
encoding
===
'
base64
'
;
const
supportsPrettying
=
supportedFormats
.
some
(
format
=>
contentType
?.
indexOf
(
format
)
>
-
1
);
const
[
isDecodeGrpc
,
setIsDecodeGrpc
]
=
useState
(
true
);
const
[
isLineNumbersGreaterThenOne
,
setIsLineNumbersGreaterThenOne
]
=
useState
(
true
);
const
lineNumbersGreaterThenOneSetter
=
(
index
)
=>
{
if
(
index
<
2
)
{
setIsLineNumbersGreaterThenOne
(
false
);
setShowLineNumbers
(
false
);
}
}
const
formatTextBody
=
(
body
:
any
):
string
=>
{
if
(
!
decodeBase64
)
return
body
;
...
...
@@ -158,9 +166,11 @@ export const EntryBodySection: React.FC<EntryBodySectionProps> = ({
return
jsonBeautify
(
protobufDecoded
,
null
,
2
,
80
);
}
}
catch
(
error
)
{
if
(
String
(
error
).
includes
(
"
More than one message in
"
)){
if
(
isDecodeGrpc
)
setIsDecodeGrpc
(
false
);
if
(
String
(
error
).
includes
(
"
More than one message in
"
))
{
if
(
isDecodeGrpc
)
setIsDecodeGrpc
(
false
);
}
else
if
(
String
(
error
).
includes
(
"
Failed to parse
"
))
{
console
.
warn
(
error
);
}
else
{
console
.
error
(
error
);
}
...
...
@@ -180,20 +190,22 @@ export const EntryBodySection: React.FC<EntryBodySectionProps> = ({
</
div
>
}
{
supportsPrettying
&&
<
span
style
=
{
{
marginLeft
:
'
.2rem
'
}
}
>
Pretty
</
span
>
}
<
div
style
=
{
{
paddingTop
:
3
,
paddingLeft
:
supportsPrettying
?
20
:
0
}
}
>
{
isLineNumbersGreaterThenOne
&&
<
div
style
=
{
{
paddingTop
:
3
,
paddingLeft
:
supportsPrettying
?
20
:
0
}
}
>
<
Checkbox
checked
=
{
showLineNumbers
}
onToggle
=
{
()
=>
{
setShowLineNumbers
(
!
showLineNumbers
)
}
}
/>
</
div
>
<
span
style
=
{
{
marginLeft
:
'
.2rem
'
}
}
>
Line numbers
</
span
>
{
isBase64Encoding
&&
<
div
style
=
{
{
paddingTop
:
3
,
paddingLeft
:
20
}
}
>
</
div
>
}
{
isLineNumbersGreaterThenOne
&&
<
span
style
=
{
{
marginLeft
:
'
.2rem
'
}
}
>
Line numbers
</
span
>
}
{
isBase64Encoding
&&
<
div
style
=
{
{
paddingTop
:
3
,
paddingLeft
:
(
isLineNumbersGreaterThenOne
||
supportsPrettying
)
?
20
:
0
}
}
>
<
Checkbox
checked
=
{
decodeBase64
}
onToggle
=
{
()
=>
{
setDecodeBase64
(
!
decodeBase64
)
}
}
/>
</
div
>
}
{
isBase64Encoding
&&
<
span
style
=
{
{
marginLeft
:
'
.2rem
'
}
}
>
Decode Base64
</
span
>
}
{
!
isDecodeGrpc
&&
<
span
style
=
{
{
fontSize
:
'
12px
'
,
color
:
'
#DB2156
'
,
marginLeft
:
'
.8rem
'
}
}
>
More than one message in protobuf payload is not supported
</
span
>
}
</
div
>
</
div
>
<
SyntaxHighlighter
<
SyntaxHighlighter
code
=
{
formatTextBody
(
content
)
}
showLineNumbers
=
{
showLineNumbers
}
lineNumbersGreaterThenOneSetter
=
{
lineNumbersGreaterThenOneSetter
}
/>
</
EntrySectionContainer
>
}
...
...
This diff is collapsed.
Click to expand it.
ui-common/src/components/UI/SyntaxHighlighter/index.tsx
+
4
-
1
View file @
203b3f0d
...
...
@@ -27,14 +27,17 @@ interface Props {
code
:
string
;
showLineNumbers
?:
boolean
;
language
?:
string
;
lineNumbersGreaterThenOneSetter
?:
(
index
)
=>
void
;
}
export
const
SyntaxHighlighter
:
React
.
FC
<
Props
>
=
({
code
,
showLineNumbers
=
false
,
language
=
null
language
=
null
,
lineNumbersGreaterThenOneSetter
})
=>
{
const
markers
=
showLineNumbers
?
code
.
split
(
"
\n
"
).
map
((
item
,
i
)
=>
{
lineNumbersGreaterThenOneSetter
(
i
);
return
{
line
:
i
+
1
,
className
:
styles
.
hljsMarkerLine
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment