Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
dce4d184
Unverified
Commit
dce4d184
authored
Jan 15, 2020
by
Ivana Huckova
Committed by
GitHub
Jan 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix regex in convertCSSToStyle, add test coverage (#21508)
parent
a35b2ac4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletions
+17
-1
packages/grafana-ui/src/components/Logs/LogMessageAnsi.test.tsx
+16
-0
packages/grafana-ui/src/components/Logs/LogMessageAnsi.tsx
+1
-1
No files found.
packages/grafana-ui/src/components/Logs/LogMessageAnsi.test.tsx
View file @
dce4d184
...
@@ -33,4 +33,20 @@ describe('<LogMessageAnsi />', () => {
...
@@ -33,4 +33,20 @@ describe('<LogMessageAnsi />', () => {
.
text
()
.
text
()
).
toBe
(
'ipsum'
);
).
toBe
(
'ipsum'
);
});
});
it
(
'renders string with ANSI codes with correctly converted css classnames'
,
()
=>
{
const
value
=
'Lorem [1;32mIpsum'
;
const
wrapper
=
shallow
(<
LogMessageAnsi
value=
{
value
}
/>);
expect
(
wrapper
.
find
(
'span'
)).
toHaveLength
(
1
);
expect
(
wrapper
.
find
(
'span'
)
.
first
()
.
prop
(
'style'
)
).
toMatchObject
(
expect
.
objectContaining
({
fontWeight
:
expect
.
any
(
String
),
})
);
});
});
});
packages/grafana-ui/src/components/Logs/LogMessageAnsi.tsx
View file @
dce4d184
...
@@ -15,7 +15,7 @@ function convertCSSToStyle(css: string): Style {
...
@@ -15,7 +15,7 @@ function convertCSSToStyle(css: string): Style {
const
match
=
line
.
match
(
/
([^
:
\s]
+
)\s
*:
\s
*
(
.+
)
/
);
const
match
=
line
.
match
(
/
([^
:
\s]
+
)\s
*:
\s
*
(
.+
)
/
);
if
(
match
&&
match
[
1
]
&&
match
[
2
])
{
if
(
match
&&
match
[
1
]
&&
match
[
2
])
{
const
key
=
match
[
1
].
replace
(
/-
(
a-z
)
/g
,
(
_
,
character
)
=>
character
.
toUpperCase
());
const
key
=
match
[
1
].
replace
(
/-
(
[
a-z
]
)
/g
,
(
_
,
character
)
=>
character
.
toUpperCase
());
// @ts-ignore
// @ts-ignore
accumulated
[
key
]
=
match
[
2
];
accumulated
[
key
]
=
match
[
2
];
}
}
...
...
Write
Preview
Markdown
is supported
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