-
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.
Merge remote-tracking branch 'upstream/main' into task/avc-banner-pac…
…kage
- Loading branch information
Showing
166 changed files
with
2,011 additions
and
1,772 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
Binary file not shown.
Binary file not shown.
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
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
9 changes: 9 additions & 0 deletions
9
packages/kbn-discover-utils/src/data_types/logs/components/index.ts
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,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export * from './log_level_badge'; |
40 changes: 40 additions & 0 deletions
40
packages/kbn-discover-utils/src/data_types/logs/components/log_level_badge.test.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,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { LogLevelBadge } from './log_level_badge'; | ||
|
||
const renderBadge = (logLevel: string) => { | ||
render( | ||
<LogLevelBadge | ||
logLevel={logLevel} | ||
fallback={<span data-test-subj="logLevelBadge-unknown">{logLevel}</span>} | ||
/> | ||
); | ||
}; | ||
|
||
describe('LogLevelBadge', () => { | ||
it('renders badge with color based on provided logLevel', () => { | ||
renderBadge('info'); | ||
const badge = screen.getByTestId('logLevelBadge-info'); | ||
expect(badge).toBeInTheDocument(); | ||
expect(badge).toHaveTextContent('info'); | ||
expect(getComputedStyle(badge).getPropertyValue('--euiBadgeBackgroundColor')).toEqual( | ||
'#90b0d1' | ||
); | ||
}); | ||
|
||
it('renders without a badge if logLevel is not recognized', () => { | ||
renderBadge('unknown_level'); | ||
const badge = screen.getByTestId('logLevelBadge-unknown'); | ||
expect(badge).toBeInTheDocument(); | ||
expect(badge).toHaveTextContent('unknown_level'); | ||
expect(getComputedStyle(badge).getPropertyValue('--euiBadgeBackgroundColor')).toEqual(''); | ||
}); | ||
}); |
58 changes: 58 additions & 0 deletions
58
packages/kbn-discover-utils/src/data_types/logs/components/log_level_badge.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,58 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React, { ReactElement } from 'react'; | ||
import { EuiBadge, EuiBadgeProps, mathWithUnits, useEuiTheme } from '@elastic/eui'; | ||
import { CSSObject } from '@emotion/react'; | ||
import { euiThemeVars } from '@kbn/ui-theme'; | ||
import { getLogLevelCoalescedValue, getLogLevelColor } from '../utils'; | ||
|
||
const badgeCss: CSSObject = { | ||
maxWidth: mathWithUnits(euiThemeVars.euiSize, (size) => size * 7.5), | ||
}; | ||
|
||
export const LogLevelBadge = ({ | ||
logLevel, | ||
fallback, | ||
'data-test-subj': dataTestSubj = 'logLevelBadge', | ||
...badgeProps | ||
}: Omit<EuiBadgeProps, 'children' | 'color'> & { | ||
logLevel: {}; | ||
fallback?: ReactElement; | ||
}) => { | ||
const { euiTheme } = useEuiTheme(); | ||
const coalescedValue = getLogLevelCoalescedValue(logLevel); | ||
const color = coalescedValue ? getLogLevelColor(coalescedValue, euiTheme) : undefined; | ||
const castedBadgeProps = badgeProps as EuiBadgeProps; | ||
|
||
if (!color || !coalescedValue) { | ||
return fallback ? ( | ||
fallback | ||
) : ( | ||
<EuiBadge | ||
{...castedBadgeProps} | ||
color="hollow" | ||
data-test-subj={`${dataTestSubj}-unknown`} | ||
css={badgeCss} | ||
> | ||
{logLevel} | ||
</EuiBadge> | ||
); | ||
} | ||
|
||
return ( | ||
<EuiBadge | ||
{...castedBadgeProps} | ||
color={color} | ||
data-test-subj={`${dataTestSubj}-${coalescedValue}`} | ||
css={badgeCss} | ||
> | ||
{logLevel} | ||
</EuiBadge> | ||
); | ||
}; |
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
2 changes: 1 addition & 1 deletion
2
...xpressions/expression_gauge/public/components/__snapshots__/gauge_component.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
...ssion_partition_vis/public/components/__snapshots__/partition_vis_component.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.