Skip to content

Commit 078cbaf

Browse files
kapral18niros1
authored andcommitted
[Watcher] Migrate SCSS to Emotion (#236649)
Addresses #205027 • Migrate Watcher to emotion ### Screenshots (Before | After) <img width="3196" height="1398" alt="image" src="https://github.com/user-attachments/assets/018cdae2-134c-44b6-a2fe-adeb2f175335" />
1 parent a76f89f commit 078cbaf

File tree

6 files changed

+51
-40
lines changed

6 files changed

+51
-40
lines changed

x-pack/platform/plugins/private/watcher/public/application/sections/watch_edit_page/components/threshold_watch_edit/threshold_watch_action_accordion.tsx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ import { executeWatch } from '../../../../lib/api';
4949
import { SectionError } from '../../../../components';
5050
import { useAppContext } from '../../../../app_context';
5151

52+
const useStyles = () => {
53+
const { euiTheme } = useEuiTheme();
54+
55+
return {
56+
watcherThresholdDeleteButton: css`
57+
opacity: 0;
58+
59+
&:focus,
60+
.euiAccordion:hover & {
61+
opacity: 1;
62+
}
63+
64+
${euiCanAnimate} {
65+
transition: opacity ${euiTheme.animation.normal} ${euiTheme.animation.resistance};
66+
}
67+
`,
68+
};
69+
};
70+
5271
const actionFieldsComponentMap = {
5372
[ACTION_TYPES.LOGGING]: LoggingActionFields,
5473
[ACTION_TYPES.SLACK]: SlackActionFields,
@@ -78,7 +97,7 @@ export const WatchActionsAccordion: React.FunctionComponent<Props> = ({
7897
settings,
7998
actionErrors,
8099
}) => {
81-
const { euiTheme } = useEuiTheme();
100+
const styles = useStyles();
82101
const {
83102
links: { watchActionsConfigurationMap },
84103
toasts,
@@ -126,18 +145,7 @@ export const WatchActionsAccordion: React.FunctionComponent<Props> = ({
126145
<EuiButtonIcon
127146
iconType="cross"
128147
color="danger"
129-
css={css`
130-
opacity: 0;
131-
132-
&:focus,
133-
.euiAccordion:hover & {
134-
opacity: 1;
135-
}
136-
137-
${euiCanAnimate} {
138-
transition: opacity ${euiTheme.animation.normal} ${euiTheme.animation.resistance};
139-
}
140-
`}
148+
css={styles.watcherThresholdDeleteButton}
141149
aria-label={i18n.translate(
142150
'xpack.watcher.sections.watchEdit.threshold.accordion.deleteIconAriaLabel',
143151
{
@@ -189,6 +197,7 @@ export const WatchActionsAccordion: React.FunctionComponent<Props> = ({
189197
{settings && settings.actionTypes[action.type].enabled === false ? (
190198
<Fragment>
191199
<EuiCallOut
200+
announceOnMount
192201
title={i18n.translate(
193202
'xpack.watcher.sections.watchEdit.threshold.actions.actionConfigurationWarningTitleText',
194203
{

x-pack/platform/plugins/private/watcher/public/application/sections/watch_edit_page/components/threshold_watch_edit/threshold_watch_action_dropdown.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
EuiContextMenuPanel,
1717
EuiContextMenuItem,
1818
} from '@elastic/eui';
19+
import { css } from '@emotion/react';
1920
import { i18n } from '@kbn/i18n';
2021
import React, { useContext, useState } from 'react';
2122
import { FormattedMessage } from '@kbn/i18n-react';
@@ -24,6 +25,12 @@ import { Action } from '../../../../models/action';
2425
import { ACTION_TYPES } from '../../../../../../common/constants';
2526
import { WatchContext } from '../../watch_context';
2627

28+
const styles = {
29+
watcherTresholdActionContextMenuItem: css`
30+
align-self: center;
31+
`,
32+
};
33+
2734
const disabledMessage = i18n.translate(
2835
'xpack.watcher.sections.watchEdit.actions.disabledOptionLabel',
2936
{
@@ -106,7 +113,7 @@ export const WatchActionsDropdown: React.FunctionComponent<Props> = ({ settings,
106113
}}
107114
>
108115
<EuiFlexGroup responsive={false}>
109-
<EuiFlexItem grow={false} className="watcherThresholdWatchActionContextMenuItem">
116+
<EuiFlexItem grow={false} css={styles.watcherTresholdActionContextMenuItem}>
110117
<EuiIcon type={action.iconClass} />
111118
</EuiFlexItem>
112119
<EuiFlexItem grow={false}>

x-pack/platform/plugins/private/watcher/public/application/sections/watch_edit_page/components/threshold_watch_edit/threshold_watch_action_panel.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@
66
*/
77

88
import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiSpacer } from '@elastic/eui';
9+
import { css } from '@emotion/react';
910
import { i18n } from '@kbn/i18n';
1011
import React, { useContext } from 'react';
1112
import { useLoadSettings } from '../../../../lib/api';
1213
import { WatchActionsDropdown } from './threshold_watch_action_dropdown';
1314
import { WatchActionsAccordion } from './threshold_watch_action_accordion';
1415
import { WatchContext } from '../../watch_context';
1516

17+
const styles = {
18+
watcherThresholdActionDropdownContainer: css`
19+
justify-content: flex-end;
20+
flex-direction: row;
21+
`,
22+
};
23+
1624
interface Props {
1725
actionErrors: {
1826
[key: string]: {
@@ -42,7 +50,7 @@ export const WatchActionsPanel: React.FunctionComponent<Props> = ({ actionErrors
4250
</h2>
4351
</EuiTitle>
4452
</EuiFlexItem>
45-
<EuiFlexItem className="watcherThresholdWatchActionDropdownContainer">
53+
<EuiFlexItem css={styles.watcherThresholdActionDropdownContainer}>
4654
<WatchActionsDropdown settings={settings} isLoading={isLoading} />
4755
</EuiFlexItem>
4856
</EuiFlexGroup>

x-pack/platform/plugins/private/watcher/public/application/sections/watch_edit_page/components/threshold_watch_edit/threshold_watch_edit.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
EuiPageHeader,
2828
EuiPageSection,
2929
} from '@elastic/eui';
30+
import { css } from '@emotion/react';
3031
import { i18n } from '@kbn/i18n';
3132
import { FormattedMessage } from '@kbn/i18n-react';
3233
import { TIME_UNITS } from '../../../../../../common/constants';
@@ -46,6 +47,15 @@ import { goToWatchList } from '../../../../lib/navigation';
4647
import { RequestFlyout } from '../request_flyout';
4748
import { useAppContext } from '../../../../app_context';
4849

50+
const styles = {
51+
watcherThresholdAlertAggFieldContainer: css`
52+
width: 300px;
53+
`,
54+
watcherThresholdInBetweenComparatorText: css`
55+
align-self: center;
56+
`,
57+
};
58+
4959
const expressionFieldsWithValidation = [
5060
'aggField',
5161
'termSize',
@@ -544,7 +554,7 @@ export const ThresholdWatchEdit = ({ pageTitle }: { pageTitle: string }) => {
544554
<EuiFlexGroup>
545555
<EuiFlexItem
546556
grow={false}
547-
className="watcherThresholdAlertAggFieldContainer"
557+
css={styles.watcherThresholdAlertAggFieldContainer}
548558
>
549559
<ErrableFormRow
550560
errorKey="aggField"
@@ -762,7 +772,7 @@ export const ThresholdWatchEdit = ({ pageTitle }: { pageTitle: string }) => {
762772
{i > 0 ? (
763773
<EuiFlexItem
764774
grow={false}
765-
className="watcherThresholdWatchInBetweenComparatorText"
775+
css={styles.watcherThresholdInBetweenComparatorText}
766776
>
767777
<EuiText>{andThresholdText}</EuiText>
768778
{hasErrors && <EuiSpacer />}

x-pack/platform/plugins/private/watcher/public/index.scss

Lines changed: 0 additions & 22 deletions
This file was deleted.

x-pack/platform/plugins/private/watcher/public/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* 2.0.
66
*/
77

8-
import './index.scss';
98
import { WatcherUIPlugin } from './plugin';
109

1110
export const plugin = () => new WatcherUIPlugin();

0 commit comments

Comments
 (0)