-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Stacktrace heading styles (#26456)
* [APM] fixes #23560 by separating frame headers from code preview and only displaying code preview when stackframe has source code context * [APM] fixes #26239 by checking for valid line number before displaying it * [APM] Converted CodePreview and Stacktace to typescript and consolidated Stackframe types * [APM] pull out components and util functions into own files and added tests
- Loading branch information
Showing
11 changed files
with
444 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { get } from 'lodash'; | ||
import React, { Fragment } from 'react'; | ||
import styled from 'styled-components'; | ||
import { Stackframe } from '../../../../typings/APMDoc'; | ||
import { colors, fontFamilyCode, px, units } from '../../../style/variables'; | ||
|
||
const FileDetails = styled.div` | ||
color: ${colors.gray3}; | ||
padding: ${px(units.half)}; | ||
font-family: ${fontFamilyCode}; | ||
`; | ||
const LibraryFrameFileDetail = styled.span` | ||
color: ${colors.gray2}; | ||
`; | ||
const AppFrameFileDetail = styled.span` | ||
font-weight: bold; | ||
color: ${colors.black}; | ||
`; | ||
|
||
interface Props { | ||
stackframe: Stackframe; | ||
isLibraryFrame?: boolean; | ||
} | ||
|
||
const FrameHeading: React.SFC<Props> = ({ | ||
stackframe, | ||
isLibraryFrame = false | ||
}) => { | ||
const FileDetail = isLibraryFrame | ||
? LibraryFrameFileDetail | ||
: AppFrameFileDetail; | ||
const lineNumber: number = get(stackframe, 'line.number'); | ||
return ( | ||
<FileDetails> | ||
<FileDetail>{stackframe.filename}</FileDetail> in{' '} | ||
<FileDetail>{stackframe.function}</FileDetail> | ||
{lineNumber > 0 && ( | ||
<Fragment> | ||
{' at '} | ||
<FileDetail>line {stackframe.line.number}</FileDetail> | ||
</Fragment> | ||
)} | ||
</FileDetails> | ||
); | ||
}; | ||
|
||
export { FrameHeading }; |
63 changes: 63 additions & 0 deletions
63
x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryFrames.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EuiLink } from '@elastic/eui'; | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { Stackframe } from '../../../../typings/APMDoc'; | ||
import { px, units } from '../../../style/variables'; | ||
import { CodePreview } from '../../shared/CodePreview'; | ||
// @ts-ignore | ||
import { Ellipsis } from '../../shared/Icons'; | ||
import { FrameHeading } from './FrameHeading'; | ||
import { hasSourceLines } from './stacktraceUtils'; | ||
|
||
const LibraryFrameToggle = styled.div` | ||
margin: 0 0 ${px(units.plus)} 0; | ||
user-select: none; | ||
`; | ||
|
||
interface Props { | ||
visible?: boolean; | ||
stackframes: Stackframe[]; | ||
codeLanguage?: string; | ||
onClick: () => void; | ||
} | ||
|
||
export const LibraryFrames: React.SFC<Props> = ({ | ||
visible, | ||
stackframes, | ||
codeLanguage, | ||
onClick | ||
}) => { | ||
return ( | ||
<div> | ||
<LibraryFrameToggle> | ||
<EuiLink onClick={onClick}> | ||
<Ellipsis horizontal={visible} style={{ marginRight: units.half }} />{' '} | ||
{stackframes.length} library frames | ||
</EuiLink> | ||
</LibraryFrameToggle> | ||
|
||
<div> | ||
{visible && | ||
stackframes.map( | ||
(stackframe, i) => | ||
hasSourceLines(stackframe) ? ( | ||
<CodePreview | ||
key={i} | ||
stackframe={stackframe} | ||
isLibraryFrame | ||
codeLanguage={codeLanguage} | ||
/> | ||
) : ( | ||
<FrameHeading key={i} stackframe={stackframe} isLibraryFrame /> | ||
) | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.