Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* 2.0.
*/

import { EuiThemeComputed } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { EuiTheme } from '@kbn/kibana-react-plugin/common';

import { ML_ANOMALY_SEVERITY } from '@kbn/ml-anomaly-utils/anomaly_severity';

export enum ServiceHealthStatus {
Expand Down Expand Up @@ -34,29 +35,32 @@ export function getServiceHealthStatus({ severity }: { severity: ML_ANOMALY_SEVE
}
}

export function getServiceHealthStatusColor(theme: EuiTheme, status: ServiceHealthStatus) {
export function getServiceHealthStatusColor(theme: EuiThemeComputed, status: ServiceHealthStatus) {
switch (status) {
case ServiceHealthStatus.healthy:
return theme.eui.euiColorVis0;
return theme.colors.vis.euiColorVisSuccess0;
case ServiceHealthStatus.warning:
return theme.eui.euiColorVis5;
return theme.colors.vis.euiColorVisWarning0;
case ServiceHealthStatus.critical:
return theme.eui.euiColorVis9;
return theme.colors.vis.euiColorVisDanger0;
case ServiceHealthStatus.unknown:
return theme.eui.euiColorMediumShade;
return theme.colors.mediumShade;
}
}

export function getServiceHealthStatusBadgeColor(theme: EuiTheme, status: ServiceHealthStatus) {
export function getServiceHealthStatusBadgeColor(
theme: EuiThemeComputed,
status: ServiceHealthStatus
) {
switch (status) {
case ServiceHealthStatus.healthy:
return theme.eui.euiColorVis0_behindText;
return theme.colors.vis.euiColorVisSuccess0;
case ServiceHealthStatus.warning:
return theme.eui.euiColorVis5_behindText;
return theme.colors.vis.euiColorVisWarning0;
case ServiceHealthStatus.critical:
return theme.eui.euiColorVis9_behindText;
return theme.colors.vis.euiColorVisDanger0;
case ServiceHealthStatus.unknown:
return theme.eui.euiColorMediumShade;
return theme.colors.mediumShade;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import { euiLightVars as lightTheme } from '@kbn/ui-theme';

function getVizColorsForTheme(theme = lightTheme) {
// Regarding https://github.com/elastic/kibana/issues/203338
// Guidance right now is to keep these as they are for now (meaning to keep using the JSON
Comment thread
fkanout marked this conversation as resolved.
return [
theme.euiColorVis0,
theme.euiColorVis1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export function ChartPreview({
timeUnit = 'm',
totalGroups,
}: ChartPreviewProps) {
const theme = useTheme();
const { euiTheme } = useTheme();
const thresholdOpacity = 0.3;
const DEFAULT_DATE_FORMAT = 'Y-MM-DD HH:mm:ss';

const style = {
fill: theme.eui.euiColorVis2,
fill: euiTheme.colors.vis.euiColorVis2,
line: {
strokeWidth: 2,
stroke: theme.eui.euiColorVis2,
stroke: euiTheme.colors.vis.euiColorVis2,
opacity: 1,
},
opacity: thresholdOpacity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export function FieldStatsPopover({
const field = dataView?.getFieldByName(fieldName);

const closePopover = useCallback(() => setInfoOpen(false), []);
const theme = useTheme();
const { euiTheme } = useTheme();

const params = useFetchParams();

Expand Down Expand Up @@ -280,7 +280,7 @@ export function FieldStatsPopover({
}
)}
data-test-subj={'apmCorrelationsContextPopoverButton'}
style={{ marginLeft: theme.eui.euiSizeXS }}
style={{ marginLeft: euiTheme.size.xs }}
/>
</EuiToolTip>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function CorrelationsTable<T extends FieldValuePair>({
sorting,
rowHeader,
}: CorrelationsTableProps<T>) {
const euiTheme = useTheme();
const { euiTheme } = useTheme();
const trackApmEvent = useUiTracker({ app: 'apm' });
const trackSelectSignificantCorrelationTerm = useCallback(
() => debounce(() => trackApmEvent({ metric: 'select_significant_term' }), 1000),
Expand Down Expand Up @@ -105,7 +105,7 @@ export function CorrelationsTable<T extends FieldValuePair>({
selectedTerm.fieldValue === term.fieldValue &&
selectedTerm.fieldName === term.fieldName
? {
backgroundColor: euiTheme.eui.euiColorLightestShade,
backgroundColor: euiTheme.colors.lightestShade,
}
: null,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { MIN_TAB_TITLE_HEIGHT } from '../../shared/charts/duration_distribution_
import { TotalDocCountLabel } from '../../shared/charts/duration_distribution_chart/total_doc_count_label';

export function FailedTransactionsCorrelations({ onFilter }: { onFilter: () => void }) {
const euiTheme = useTheme();
const { euiTheme } = useTheme();

const {
core: { notifications },
Expand Down Expand Up @@ -456,7 +456,7 @@ export function FailedTransactionsCorrelations({ onFilter }: { onFilter: () => v
style={{
display: 'flex',
flexDirection: 'row',
paddingLeft: euiTheme.eui.euiSizeS,
paddingLeft: euiTheme.size.s,
}}
>
<EuiSwitch
Expand All @@ -473,7 +473,7 @@ export function FailedTransactionsCorrelations({ onFilter }: { onFilter: () => v
<EuiIconTip
size="m"
iconProps={{
style: { marginLeft: euiTheme.eui.euiSizeXS },
style: { marginLeft: euiTheme.size.xs },
}}
content={i18n.translate(
'xpack.apm.correlations.latencyCorrelations.advancedStatisticsTooltipContent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { EuiTheme } from '@kbn/kibana-react-plugin/common';
import { EuiThemeComputed } from '@elastic/eui';
import type { HistogramItem } from '../../../../common/correlations/types';
import { DurationDistributionChartData } from '../../shared/charts/duration_distribution_chart';
import { LatencyCorrelation } from '../../../../common/correlations/latency_correlations/types';
Expand All @@ -18,7 +18,7 @@ export function getTransactionDistributionChartData({
failedTransactionsHistogram,
selectedTerm,
}: {
euiTheme: EuiTheme;
euiTheme: EuiThemeComputed;
allTransactionsHistogram?: HistogramItem[];
failedTransactionsHistogram?: HistogramItem[];
selectedTerm?: LatencyCorrelation | FailedTransactionsCorrelation | undefined;
Expand All @@ -31,7 +31,7 @@ export function getTransactionDistributionChartData({
defaultMessage: 'All transactions',
}),
histogram: allTransactionsHistogram,
areaSeriesColor: euiTheme.eui.euiColorVis1,
areaSeriesColor: euiTheme.colors.vis.euiColorVis0,
});
}

Expand All @@ -41,15 +41,15 @@ export function getTransactionDistributionChartData({
defaultMessage: 'Failed transactions',
}),
histogram: failedTransactionsHistogram,
areaSeriesColor: euiTheme.eui.euiColorVis7,
areaSeriesColor: euiTheme.colors.vis.euiColorVis7,
});
}

if (selectedTerm && Array.isArray(selectedTerm.histogram)) {
transactionDistributionChartData.push({
id: `${selectedTerm.fieldName}:${selectedTerm.fieldValue}`,
histogram: selectedTerm.histogram,
areaSeriesColor: euiTheme.eui.euiColorVis2,
areaSeriesColor: euiTheme.colors.vis.euiColorVis2,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function LatencyCorrelations({ onFilter }: { onFilter: () => void }) {
core: { notifications },
} = useApmPluginContext();

const euiTheme = useTheme();
const { euiTheme } = useTheme();

const { progress, response, startFetch, cancelFetch } = useLatencyCorrelations();
const { overallHistogram, hasData, status } = getOverallHistogram(response, progress.isRunning);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function DependencyOperationDistributionChart() {
// there is no "current" event in the dependency operation detail view
const markerCurrentEvent = undefined;

const euiTheme = useTheme();
const { euiTheme } = useTheme();

const {
query: {
Expand Down Expand Up @@ -67,14 +67,14 @@ export function DependencyOperationDistributionChart() {

const chartData: DurationDistributionChartData[] = [
{
areaSeriesColor: euiTheme.eui.euiColorVis1,
areaSeriesColor: euiTheme.colors.vis.euiColorVis1,
histogram: data?.allSpansDistribution.overallHistogram ?? [],
id: i18n.translate('xpack.apm.dependencyOperationDistributionChart.allSpansLegendLabel', {
defaultMessage: 'All spans',
}),
},
{
areaSeriesColor: euiTheme.eui.euiColorVis7,
areaSeriesColor: euiTheme.colors.vis.euiColorVis7,
histogram: data?.failedSpansDistribution?.overallHistogram ?? [],
id: i18n.translate('xpack.apm.dependencyOperationDistributionChart.failedSpansLegendLabel', {
defaultMessage: 'Failed spans',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
* 2.0.
*/

import { EuiButtonEmpty, EuiEmptyPrompt, EuiImage, EuiLink, EuiLoadingSpinner } from '@elastic/eui';
import {
COLOR_MODES_STANDARD,
EuiButtonEmpty,
EuiEmptyPrompt,
EuiImage,
EuiLink,
EuiLoadingSpinner,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
Expand Down Expand Up @@ -65,7 +72,7 @@ export function EntityLink() {
icon={
<EuiImage
size="fullWidth"
src={theme.darkMode ? dashboardsDark : dashboardsLight}
src={theme.colorMode === COLOR_MODES_STANDARD.dark ? dashboardsDark : dashboardsLight}
alt=""
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
DARK_THEME,
LegendValue,
} from '@elastic/charts';
import { EuiTitle } from '@elastic/eui';
import { COLOR_MODES_STANDARD, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
Expand Down Expand Up @@ -97,7 +97,7 @@ export function ErrorDistribution({ distribution, title, fetchStatus }: Props) {
showLegend
legendValues={[LegendValue.CurrentAndLastValue]}
legendPosition={Position.Bottom}
theme={theme.darkMode ? DARK_THEME : LIGHT_THEME}
theme={theme.colorMode === COLOR_MODES_STANDARD.dark ? DARK_THEME : LIGHT_THEME}
locale={i18n.getLocale()}
/>
<Axis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import {
COLOR_MODES_STANDARD,
EuiDescriptionList,
EuiDescriptionListDescription,
EuiDescriptionListTitle,
Expand Down Expand Up @@ -54,7 +55,10 @@ export function EmptyPrompt() {
function NoResultsIllustration() {
const theme = useTheme();

const illustration = theme.darkMode ? noResultsIllustrationDark : noResultsIllustrationLight;
const illustration =
theme.colorMode === COLOR_MODES_STANDARD.dark
? noResultsIllustrationDark
: noResultsIllustrationLight;

return (
<EuiImage alt={noResultsIllustrationAlternativeText} size="fullWidth" src={illustration} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/
import React from 'react';
import { EuiEmptyPrompt, EuiImage } from '@elastic/eui';
import { COLOR_MODES_STANDARD, EuiEmptyPrompt, EuiImage } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { dashboardsDark, dashboardsLight } from '@kbn/shared-svg';
import { useTheme } from '../../../hooks/use_theme';
Expand All @@ -25,7 +25,7 @@ export function EmptyDashboards({ actions }: Props) {
icon={
<EuiImage
size="fullWidth"
src={theme.darkMode ? dashboardsDark : dashboardsLight}
src={theme.colorMode === COLOR_MODES_STANDARD.dark ? dashboardsDark : dashboardsLight}
alt=""
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
import { useTheme } from '../../../../hooks/use_theme';

export function HealthBadge({ healthStatus }: { healthStatus: ServiceHealthStatus }) {
const theme = useTheme();
const { euiTheme } = useTheme();

return (
<EuiBadge color={getServiceHealthStatusBadgeColor(theme, healthStatus)}>
<EuiBadge color={getServiceHealthStatusBadgeColor(euiTheme, healthStatus)}>
{getServiceHealthStatusLabel(healthStatus)}
</EuiBadge>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function Controls() {
);

const [zoom, setZoom] = useState((cy && cy.zoom()) || 1);
const duration = parseInt(theme.eui.euiAnimSpeedFast, 10);
const duration = parseInt(theme.euiTheme.animation.fast || '0', 10);
const downloadUrl = useDebugDownloadUrl(cy);
const viewFullMapUrl = getLegacyApmHref({
basePath,
Expand Down
Loading