Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ILM] Remove euiThemeVars and remapping colors for Borealis #204449

Merged
merged 10 commits into from
Jan 8, 2025

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,71 @@
align-items: center;
border-radius: 50%;
background-color: $euiColorLightestShade;

&--disabled {
width: $euiSize;
height: $euiSize;
margin: $euiSizeS;
}

&--delete {
background-color: $euiColorLightShade;
}

&__inner--hot {
fill: $euiColorVis9_behindText;
&--borealis {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to implement these changes with emotion instead of adding to the scss. Here's an example of how I did this for upgrade assistant - https://github.com/elastic/kibana/pull/205345/files

fill: $euiColorVis6;
}

&--amsterdam {
fill: $euiColorVis9_behindText;
}
}

&__inner--warm {
fill: $euiColorVis5_behindText;
&--borealis {
fill: $euiColorVis9;
}

&--amsterdam {
fill: $euiColorVis5_behindText;
}
}

&__inner--cold {
fill: $euiColorVis1_behindText;
&--borealis {
fill: $euiColorVis2;
}

&--amsterdam {
fill: $euiColorVis1_behindText;
}
}

&__inner--frozen {
fill: $euiColorVis4_behindText;

&--borealis {
fill: $euiColorVis4;
}

&--amsterdam {
fill: $euiColorVis4_behindText;
}
}

&__inner--delete {
fill: $euiColorDarkShade;

&--borealis,
&--amsterdam {
fill: $euiColorDarkShade;
}
}

&__inner--disabled {
fill: $euiColorMediumShade;

&--borealis,
&--amsterdam {
fill: $euiColorMediumShade;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@
*/

import React, { FunctionComponent } from 'react';
import { EuiIcon } from '@elastic/eui';
import { EuiIcon, useEuiTheme } from '@elastic/eui';
import { Phases } from '../../../../../../common/types';
import './phase_icon.scss';
interface Props {
enabled: boolean;
phase: string & keyof Phases;
}
export const PhaseIcon: FunctionComponent<Props> = ({ enabled, phase }) => {
const { euiTheme } = useEuiTheme();

const themeName = euiTheme.themeName === 'EUI_THEME_BOREALIS' ? 'borealis' : 'amsterdam';

return (
<div
className={`ilmPhaseIcon ilmPhaseIcon--${phase} ${enabled ? '' : 'ilmPhaseIcon--disabled'}`}
>
{enabled ? (
<EuiIcon
className={`ilmPhaseIcon__inner--${phase}`}
className={`ilmPhaseIcon__inner--${phase}--${themeName}`}
type={phase === 'delete' ? 'trash' : 'checkInCircleFilled'}
size={phase === 'delete' ? 'm' : 'l'}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,41 @@ $ilmTimelineBarHeight: $euiSizeS;
width: var(--ilm-timeline-hot-phase-width);

&__colorBar {
background-color: $euiColorVis9;
&__borealis {
background-color: $euiColorVis6;
}

&__amsterdam {
background-color: $euiColorVis9;
}
}
}

&__warmPhase {
width: var(--ilm-timeline-warm-phase-width);

&__colorBar {
background-color: $euiColorVis5;
&__borealis {
background-color: $euiColorVis9;
}

&__amsterdam {
background-color: $euiColorVis5;
}
}
}

&__coldPhase {
width: var(--ilm-timeline-cold-phase-width);

&__colorBar {
background-color: $euiColorVis1;
&__borealis {
background-color: $euiColorVis2;
}

&__amsterdam {
background-color: $euiColorVis1;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';

import React, { FunctionComponent, memo } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiText, EuiIconTip } from '@elastic/eui';
import {
EuiFlexGroup,
EuiFlexItem,
EuiTitle,
EuiText,
EuiIconTip,
useEuiTheme,
} from '@elastic/eui';

import { useKibana } from '../../../../../shared_imports';

Expand Down Expand Up @@ -135,6 +142,10 @@ export const Timeline: FunctionComponent<Props> = memo(
: undefined,
};

const { euiTheme } = useEuiTheme();

const themeName = euiTheme.themeName === 'EUI_THEME_BOREALIS' ? 'borealis' : 'amsterdam';

const phaseAgeInMilliseconds = calculateRelativeFromAbsoluteMilliseconds(absoluteTimings);

const widths = calculateWidths(phaseAgeInMilliseconds);
Expand Down Expand Up @@ -188,7 +199,9 @@ export const Timeline: FunctionComponent<Props> = memo(
data-test-subj="ilmTimelinePhase-hot"
className="ilmTimeline__phasesContainer__phase ilmTimeline__hotPhase"
>
<div className="ilmTimeline__colorBar ilmTimeline__hotPhase__colorBar" />
<div
className={`ilmTimeline__colorBar ilmTimeline__hotPhase__colorBar__${themeName}`}
/>
<TimelinePhaseText
phaseName={i18nTexts.hotPhase}
durationInPhase={getDurationInPhaseContent('hot')}
Expand All @@ -199,7 +212,9 @@ export const Timeline: FunctionComponent<Props> = memo(
data-test-subj="ilmTimelinePhase-warm"
className="ilmTimeline__phasesContainer__phase ilmTimeline__warmPhase"
>
<div className="ilmTimeline__colorBar ilmTimeline__warmPhase__colorBar" />
<div
className={`ilmTimeline__colorBar ilmTimeline__warmPhase__colorBar__${themeName}`}
/>
<TimelinePhaseText
phaseName={i18nTexts.warmPhase}
durationInPhase={getDurationInPhaseContent('warm')}
Expand All @@ -211,7 +226,9 @@ export const Timeline: FunctionComponent<Props> = memo(
data-test-subj="ilmTimelinePhase-cold"
className="ilmTimeline__phasesContainer__phase ilmTimeline__coldPhase"
>
<div className="ilmTimeline__colorBar ilmTimeline__coldPhase__colorBar" />
<div
className={`ilmTimeline__colorBar ilmTimeline__coldPhase__colorBar__${themeName}`}
/>
<TimelinePhaseText
phaseName={i18nTexts.coldPhase}
durationInPhase={getDurationInPhaseContent('cold')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@

import React from 'react';
import { css } from '@emotion/react';
import { euiThemeVars } from '@kbn/ui-theme';
import { useEuiTheme } from '@elastic/eui';
import type { Phase } from '../../../../../common/types';

const phaseToIndicatorColors = {
hot: euiThemeVars.euiColorVis9,
warm: euiThemeVars.euiColorVis5,
cold: euiThemeVars.euiColorVis1,
frozen: euiThemeVars.euiColorVis4,
delete: euiThemeVars.euiColorLightShade,
};
export const PhaseIndicator = ({ phase }: { phase: Phase }) => {
const { euiTheme } = useEuiTheme();

const isBorealis = euiTheme.themeName === 'EUI_THEME_BOREALIS';

// Changing the mappings for the phases in Borealis as a mid-term solution. See https://github.com/elastic/kibana/issues/203664#issuecomment-2536593361.
const phaseToIndicatorColors = {
hot: isBorealis ? euiTheme.colors.vis.euiColorVis6 : euiTheme.colors.vis.euiColorVis9,
warm: isBorealis ? euiTheme.colors.vis.euiColorVis9 : euiTheme.colors.vis.euiColorVis5,
cold: isBorealis ? euiTheme.colors.vis.euiColorVis2 : euiTheme.colors.vis.euiColorVis1,
frozen: euiTheme.colors.vis.euiColorVis4,
delete: euiTheme.colors.lightShade,
};

return (
<div
css={css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,14 @@ import {
EuiBadgeProps,
EuiBadge,
EuiCode,
useEuiTheme,
} from '@elastic/eui';
import { euiThemeVars } from '@kbn/ui-theme';

import { ApplicationStart } from '@kbn/core/public';
import { Index, IndexDetailsTab } from '@kbn/index-management-shared-types';
import { IlmExplainLifecycleLifecycleExplainManaged } from '@elastic/elasticsearch/lib/api/types';
import { Phase } from '../../../common/types';
import { getPolicyEditPath } from '../../application/services/navigation';

const phaseToBadgeMapping: Record<Phase, { color: EuiBadgeProps['color']; label: string }> = {
hot: {
color: euiThemeVars.euiColorVis9,
label: 'Hot',
},
warm: {
color: euiThemeVars.euiColorVis5,
label: 'Warm',
},
cold: {
color: euiThemeVars.euiColorVis1,
label: 'Cold',
},
frozen: {
color: euiThemeVars.euiColorVis4,
label: 'Frozen',
},
delete: {
color: 'default',
label: 'Delete',
},
};

interface Props {
index: Index;
getUrlForApp: ApplicationStart['getUrlForApp'];
Expand All @@ -64,6 +40,34 @@ export const IndexLifecycleSummary: FunctionComponent<Props> = ({ index, getUrlF
// only ILM managed indices render the ILM tab
const ilm = ilmData as IlmExplainLifecycleLifecycleExplainManaged;

const { euiTheme } = useEuiTheme();

const isBorealis = euiTheme.themeName === 'EUI_THEME_BOREALIS';

// Changing the mappings for the phases in Borealis as a mid-term solution. See https://github.com/elastic/kibana/issues/203664#issuecomment-2536593361.
const phaseToBadgeMapping: Record<Phase, { color: EuiBadgeProps['color']; label: string }> = {
hot: {
color: isBorealis ? euiTheme.colors.vis.euiColorVis6 : euiTheme.colors.vis.euiColorVis9,
label: 'Hot',
},
warm: {
color: isBorealis ? euiTheme.colors.vis.euiColorVis9 : euiTheme.colors.vis.euiColorVis5,
label: 'Warm',
},
cold: {
color: isBorealis ? euiTheme.colors.vis.euiColorVis2 : euiTheme.colors.vis.euiColorVis1,
label: 'Cold',
},
frozen: {
color: euiTheme.colors.vis.euiColorVis4,
label: 'Frozen',
},
delete: {
color: 'default',
label: 'Delete',
},
};

// if ilm.phase is an unexpected value, then display a default badge
const phaseBadgeConfig = phaseToBadgeMapping[ilm.phase as Phase] ?? {
color: 'default',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@kbn/core-http-browser",
"@kbn/config-schema",
"@kbn/shared-ux-router",
"@kbn/ui-theme",
"@kbn/shared-ux-link-redirect-app",
"@kbn/index-management-shared-types",
"@kbn/react-kibana-context-render",
Expand Down