Skip to content
Copy link
Copy Markdown
Contributor Author

@MiriamAparicio MiriamAparicio Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why this file ended up in my PR after the merge, can you check if it's ok and approve? @elastic/search-kibana

Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ export const NewSearchIndexTemplate: React.FC<Props> = ({
optionally set a default {language_analyzer} for the index."
values={{
language_analyzer: (
<EuiLink target="_blank" href={docLinks.languageAnalyzers}>
<EuiLink
data-test-subj="enterpriseSearchNewSearchIndexTemplateLanguageAnalyzerLink"
target="_blank"
href={docLinks.languageAnalyzers}
>
{i18n.translate(
'xpack.enterpriseSearch.content.newIndex.newSearchIndexTemplate.formDescription.linkText',
{
Expand Down Expand Up @@ -247,6 +251,7 @@ export const NewSearchIndexTemplate: React.FC<Props> = ({
)}
>
<EuiSelect
data-test-subj="enterpriseSearchNewSearchIndexTemplateSelect"
data-telemetry-id={`entSearchContent-${type}-newIndex-languageAnalyzer`}
disabled={disabled}
options={SUPPORTED_LANGUAGES}
Expand All @@ -261,7 +266,11 @@ export const NewSearchIndexTemplate: React.FC<Props> = ({
<EuiSpacer />
<EuiFlexGroup direction="column" gutterSize="xs">
<EuiFlexItem>
<EuiLink target="_blank" href={docLinks.elasticsearchGettingStarted}>
<EuiLink
data-test-subj="enterpriseSearchNewSearchIndexTemplateLearnMoreAboutIndicesLink"
target="_blank"
href={docLinks.elasticsearchGettingStarted}
>
{i18n.translate(
'xpack.enterpriseSearch.content.newIndex.newSearchIndexTemplate.learnMoreIndices.linkText',
{
Expand All @@ -273,7 +282,11 @@ export const NewSearchIndexTemplate: React.FC<Props> = ({

{type === INGESTION_METHOD_IDS.CONNECTOR && (
<EuiFlexItem grow={false}>
<EuiLink target="_blank" href={docLinks.connectors}>
<EuiLink
data-test-subj="enterpriseSearchNewSearchIndexTemplateLearnMoreAboutConnectorsLink"
target="_blank"
href={docLinks.connectors}
>
{i18n.translate(
'xpack.enterpriseSearch.content.newIndex.newSearchIndexTemplate.learnMoreConnectors.linkText',
{
Expand All @@ -285,7 +298,11 @@ export const NewSearchIndexTemplate: React.FC<Props> = ({
)}
{type === INGESTION_METHOD_IDS.CRAWLER && (
<EuiFlexItem grow={false}>
<EuiLink target="_blank" href={docLinks.crawlerOverview}>
<EuiLink
data-test-subj="enterpriseSearchNewSearchIndexTemplateLearnMoreAboutTheElasticWebCrawlerLink"
target="_blank"
href={docLinks.crawlerOverview}
>
{i18n.translate(
'xpack.enterpriseSearch.content.newIndex.newSearchIndexTemplate.learnMoreCrawler.linkText',
{
Expand All @@ -297,7 +314,11 @@ export const NewSearchIndexTemplate: React.FC<Props> = ({
)}
{type === INGESTION_METHOD_IDS.API && (
<EuiFlexItem grow={false}>
<EuiLink target="_blank" href={docLinks.ingestionApis}>
<EuiLink
data-test-subj="enterpriseSearchNewSearchIndexTemplateLearnMoreAboutIngestionApIsLink"
target="_blank"
href={docLinks.ingestionApis}
>
{i18n.translate(
'xpack.enterpriseSearch.content.newIndex.newSearchIndexTemplate.learnMoreApis.linkText',
{
Expand All @@ -312,6 +333,7 @@ export const NewSearchIndexTemplate: React.FC<Props> = ({
<EuiFlexGroup direction="row" alignItems="center" justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="enterpriseSearchNewSearchIndexTemplateButton"
data-telemetry-id={`entSearchContent-${type}-newIndex-goBack`}
isDisabled={buttonLoading}
onClick={() => history.back()}
Expand Down
14 changes: 14 additions & 0 deletions x-pack/plugins/observability_solution/infra/emotion.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import '@emotion/react';
import type { UseEuiTheme } from '@elastic/eui';

declare module '@emotion/react' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Theme extends UseEuiTheme {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

import React from 'react';
import { Chart, Metric, Settings } from '@elastic/charts';
import { EuiIcon, EuiPanel, useEuiBackgroundColor } from '@elastic/eui';
import { EuiIcon, EuiPanel, type UseEuiTheme, useEuiTheme } from '@elastic/eui';
import type { PartialTheme, Theme } from '@elastic/charts';
import { i18n } from '@kbn/i18n';
import { COMPARATORS } from '@kbn/alerting-comparators';

export interface ChartProps {
theme?: PartialTheme;
theme?: UseEuiTheme<{}>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work? {} is the default value of the generic parameter

Suggested change
theme?: UseEuiTheme<{}>;
theme?: UseEuiTheme;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, i'll fix it on the next PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use this anywhere but it is meant to be the chart PartialTheme which can be used to override values from the baseTheme.

baseTheme: Theme;
}

Expand Down Expand Up @@ -41,7 +41,8 @@ export const Threshold = ({
valueFormatter,
warning,
}: Props) => {
const color = useEuiBackgroundColor('danger');
const { euiTheme } = useEuiTheme();
const color = euiTheme.colors.backgroundBaseDanger;

return (
<EuiPanel
Expand All @@ -56,7 +57,7 @@ export const Threshold = ({
data-test-subj={`threshold-${thresholds.join('-')}-${value}`}
>
<Chart>
<Settings theme={theme} baseTheme={baseTheme} locale={i18n.getLocale()} />
<Settings theme={theme as PartialTheme} baseTheme={baseTheme} locale={i18n.getLocale()} />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to use as PartialTheme here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The types coming from the emotion Theme and the type requested for Settings theme doesn't match, we need to cast it as PartialTheme to work, I'm open to suggestions on how to fix it in a different way

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MiriamAparicio sorry I missed this comment. We are often too loose using as to solve type issues in kibana.

I prefer to use the satisfies operator over as whenever possible. If that does not suffice the type is either wrong or too ambiguous (e.g. any or unknown).

I added a fix for this in #206133 if you have a minute to review.

<Metric
id={id}
data={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import React from 'react';
import { AnnotationDomainType, LineAnnotation, Position } from '@elastic/charts';
import moment from 'moment';
import { EuiIcon } from '@elastic/eui';
import { EuiIcon, useEuiTheme } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-theme';
import { UI_SETTINGS } from '@kbn/data-plugin/public';
import { useKibanaContextForPlugin } from '../../../../../hooks/use_kibana';

export function AlertAnnotation({ alertStarted }: { alertStarted: number }) {
const { uiSettings } = useKibanaContextForPlugin().services;
const { euiTheme } = useEuiTheme();

return (
<LineAnnotation
Expand All @@ -32,7 +33,7 @@ export function AlertAnnotation({ alertStarted }: { alertStarted: number }) {
style={{
line: {
strokeWidth: 3,
stroke: euiThemeVars.euiColorDangerText,
stroke: euiTheme.colors.textDanger,
opacity: 1,
},
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
import { LEGACY_LIGHT_THEME } from '@elastic/charts';
import { LIGHT_THEME } from '@elastic/charts';
import { EuiPanel } from '@elastic/eui';
import {
ALERT_CONTEXT,
Expand Down Expand Up @@ -93,8 +93,7 @@ const AlertDetailsAppSection = ({ rule, alert }: AlertDetailsAppSectionProps) =>
<EuiSpacer size="s" />
<Threshold
title={`Threshold breached`}
// @ts-expect-error this chart needs to be migrated to the new chart theming system, comment should be removed once https://github.com/elastic/kibana/issues/202138 is resolved
chartProps={{ theme, baseTheme: LEGACY_LIGHT_THEME }}
chartProps={{ theme, baseTheme: LIGHT_THEME }}
comparator={ComparatorToi18nSymbolsMap[rule.params.count.comparator]}
id={'threshold-ratio-chart'}
thresholds={[rule.params.count.value]}
Expand Down Expand Up @@ -161,8 +160,7 @@ const AlertDetailsAppSection = ({ rule, alert }: AlertDetailsAppSectionProps) =>
<EuiSpacer size="s" />
<Threshold
title={`Threshold breached`}
// @ts-expect-error this chart needs to be migrated to the new chart theming system, comment should be removed once https://github.com/elastic/kibana/issues/202138 is resolved
chartProps={{ theme, baseTheme: LEGACY_LIGHT_THEME }}
chartProps={{ theme, baseTheme: LIGHT_THEME }}
comparator={ComparatorToi18nSymbolsMap[rule.params.count.comparator]}
id="logCountThreshold"
thresholds={[rule.params.count.value]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { omit } from 'lodash';
import React, { PropsWithChildren, useCallback, useMemo, useState } from 'react';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import styled from '@emotion/styled';
import {
AggregationType,
IErrorObject,
Expand Down Expand Up @@ -46,13 +46,15 @@ interface ExpressionRowProps {
setRuleParams(id: number, params: MetricExpression): void;
}

const NegativeHorizontalMarginDiv = euiStyled.div`margin: 0 -4px;`;
const NegativeHorizontalMarginDiv = styled.div`
margin: 0 -4px;
Comment thread
mgadewoll marked this conversation as resolved.
Outdated
`;

const StyledExpression = euiStyled.div`
const StyledExpression = styled.div`
padding: 0 4px;
`;

const StyledHealth = euiStyled(EuiHealth)`
const StyledHealth = styled(EuiHealth)`
margin-left: 4px;
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
EuiButton,
EuiSpacer,
} from '@elastic/eui';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import styled from '@emotion/styled';
import useToggle from 'react-use/lib/useToggle';
import { type Message } from '@kbn/observability-ai-assistant-plugin/public';
import { useKibanaContextForPlugin } from '../../../../hooks/use_kibana';
Expand Down Expand Up @@ -199,34 +199,33 @@ const explainProcessMessageTitle = i18n.translate(
}
);

const ExpandedRowDescriptionList = euiStyled(EuiDescriptionList).attrs({
compressed: true,
})`
const ExpandedRowDescriptionList = styled(EuiDescriptionList)`
width: 100%;
`;

const CodeListItem = euiStyled(EuiCode).attrs({
transparentBackground: true,
})`
ExpandedRowDescriptionList.defaultProps = { compressed: true };

const CodeListItem = styled(EuiCode)`
padding: 0 !important;
& code.euiCodeBlock__code {
white-space: nowrap !important;
vertical-align: middle;
}
`;

const ExpandedCommandLine = euiStyled(EuiCode).attrs({
transparentBackground: true,
})`
CodeListItem.defaultProps = { transparentBackground: true };

const ExpandedCommandLine = styled(EuiCode)`
padding: 0 !important;
margin-bottom: ${(props) => props.theme.eui.euiSizeS};
margin-bottom: ${(props) => props.theme.euiTheme.size.s};
`;

const ExpandedRowCell = euiStyled(EuiTableRowCell).attrs({
textOnly: false,
colSpan: 6,
})`
padding-top: ${(props) => props.theme.eui.euiSizeM} !important;
padding-bottom: ${(props) => props.theme.eui.euiSizeM} !important;
background-color: ${(props) => props.theme.eui.euiColorLightestShade};
ExpandedCommandLine.defaultProps = { transparentBackground: true };

const ExpandedRowCell = styled(EuiTableRowCell)`
padding-top: ${(props) => props.theme.euiTheme.size.m} !important;
padding-bottom: ${(props) => props.theme.euiTheme.size.m} !important;
background-color: ${(props) => props.theme.euiTheme.colors.lightestShade};
`;

ExpandedRowCell.defaultProps = { textOnly: false, colSpan: 6 };
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ const columns: Array<{
];

const CodeLine = ({ command }: { command: string }) => {
const euiTheme = useEuiTheme();
const { euiTheme } = useEuiTheme();
return (
<div
css={css`
Expand All @@ -379,8 +379,8 @@ const CodeLine = ({ command }: { command: string }) => {
<EuiCode
transparentBackground
css={css`
color: ${euiTheme.euiTheme.colors.text};
font-weight: ${euiTheme.euiTheme.font.weight.medium};
color: ${euiTheme.colors.textParagraph};
font-weight: ${euiTheme.font.weight.medium};
`}
>
{command}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { EuiFieldSearch, EuiOutsideClickDetector, EuiPanel } from '@elastic/eui';
import React from 'react';
import { QuerySuggestion } from '@kbn/unified-search-plugin/public';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import styled from '@emotion/styled';
import { composeStateUpdaters } from '../../utils/typed_react';
import { SuggestionItem } from './suggestion_item';

Expand Down Expand Up @@ -302,19 +302,18 @@ const withUnfocused = (state: AutocompleteFieldState) => ({
isFocused: false,
});

const AutocompleteContainer = euiStyled.div`
const AutocompleteContainer = styled.div`
position: relative;
`;

const SuggestionsPanel = euiStyled(EuiPanel).attrs(() => ({
paddingSize: 'none',
hasShadow: true,
}))`
const SuggestionsPanel = styled(EuiPanel)`
position: absolute;
width: 100%;
margin-top: 2px;
overflow-x: hidden;
overflow-y: scroll;
z-index: ${(props) => props.theme.eui.euiZLevel1};
z-index: ${(props) => props.theme.euiTheme.levels.maskBelowHeader};
max-height: 322px;
`;

SuggestionsPanel.defaultProps = { paddingSize: 'none', hasShadow: true };
Loading