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

[ML] Migrate anomaly explorer components from SCSS to Emotion #212793

Merged

Conversation

peteharverson
Copy link
Contributor

@peteharverson peteharverson commented Feb 28, 2025

Summary

Part of: #140695
Migrates SCSS to emotion for several of the components used across the Anomaly Explorer and Single Metric Viewer.

Removes the following SCSS files:

- x-pack/platform/plugins/shared/m/public/application/components/annotations/annotation_description_list/_index.scss
- x-pack/platform/plugins/shared/ml/public/application/components/entity_cell/_index.scss
- x-pack/platform/plugins/shared/ml/public/application/components/entity_cell/entity_cell.scss
- x-pack/platform/plugins/shared/ml/public/application/components/help_popover/help_popover.scss
- x-pack/platform/plugins/shared/ml/public/application/components/detector_description_list/_detector_description_list.scss
- x-pack/platform/plugins/shared/ml/public/application/components/rule_editor/components/detector_description_list/_index.scss
- x-pack/platform/plugins/shared/ml/public/application/explorer/explorer_charts/components/explorer_chart_label/_explorer_chart_label_badge.scss
- x-pack/platform/plugins/shared/ml/public/application/explorer/explorer_charts/components/explorer_chart_label/entity_filter/_entity_filter.scss

Components edited:

  • Help popover
Screenshot 2025-02-28 at 16 28 27
  • Annotation description list:
Screenshot 2025-02-28 at 16 29 16
  • Rule editor detector description list:
Screenshot 2025-02-28 at 16 30 02
  • Anomalies table entity filters:
Screenshot 2025-02-28 at 16 30 53
  • Explorer chart label badge and entity filters:
Screenshot 2025-02-28 at 16 31 37

@peteharverson peteharverson added chore :ml release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Feb 28, 2025
@peteharverson peteharverson self-assigned this Feb 28, 2025
@peteharverson peteharverson requested review from a team as code owners February 28, 2025 16:32
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Comment on lines 87 to 104
<EuiButtonIcon
size="s"
css={filterButton}
onClick={blurButtonOnClick(() => {
influencerFilter(
influencer.influencerFieldName,
influencer.influencerFieldValue,
'+'
);
})}
iconType="plusInCircle"
aria-label={i18n.translate(
'xpack.ml.anomaliesTable.influencersCell.addFilterAriaLabel',
{
defaultMessage: 'Add filter',
}
)}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the influencers filter should be visible only if the influencerFilter prop is defined. Currently, we always see the buttons, but clicking them throws an error in the console:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in cafbf1e

const { filterButton } = useEntityCellStyles();

const [showAllInfluencers, setShowAllInfluencers] = useState(false);
const toggleAllInfluencers = setShowAllInfluencers.bind(null, (prev) => !prev);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if bind is necessary here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in cafbf1e

@@ -10,12 +10,12 @@ import React, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import type { EuiLinkButtonProps, EuiPopoverProps } from '@elastic/eui';
import { EuiButtonIcon, EuiPopover, EuiPopoverTitle, EuiText } from '@elastic/eui';
import './help_popover.scss';
// import './help_popover.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// import './help_popover.scss';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in cafbf1e

@@ -2,10 +2,6 @@
.ml-rule-editor-flyout {
font-size: $euiFontSizeS;

.select-rule-action .rule-detector-description-list {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in cafbf1e

Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: this is the same as the filterButton style in x-pack/platform/plugins/shared/ml/public/application/components/entity_cell/entity_cell_styles.ts. Maybe it could be extracted into something like filter_button_styles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree that this would be the ideal approach, with some refactoring to create a separate component for the filter button which is used in several places. But I want to keep the scope of this PR small, and save that refactoring for future work.

@peteharverson
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

Left a nitpick, but

@@ -53,10 +55,13 @@ function getAddFilter({ entityName, entityValue, filter }: EntityCellProps) {
/>
</EuiToolTip>
);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Nit, we usually return early with null rather than have it in an else as it is easier to read.
e.g.

if (filter === undefined) {
  return null;
}

return (
  .....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in ac5e22e

@@ -81,8 +86,10 @@ function getRemoveFilter({ entityName, entityValue, filter }: EntityCellProps) {
/>
</EuiToolTip>
);
} else {
return null;
Copy link
Member

Choose a reason for hiding this comment

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

same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in ac5e22e

opacity: 0.5,
width: euiTheme.size.base,
height: euiTheme.size.base,
'-webkit-transform': 'translateY(-1px)',
Copy link
Member

Choose a reason for hiding this comment

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

I'm seeing errors in the console which are being caused by these -webkit-transform rules.
image

The errors do not appear if these are removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in ac5e22e

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

LGTM

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2337 2322 -15

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 5.2MB 5.2MB -11.9KB

History

cc @peteharverson

Copy link
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

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

SCSS changes

Copy link
Contributor

@rbrtj rbrtj left a comment

Choose a reason for hiding this comment

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

Latest changes LGTM 👍

@peteharverson peteharverson merged commit a1c520c into elastic:main Mar 5, 2025
9 checks passed
@peteharverson peteharverson deleted the ml-anomaly-explorer-scss-migration branch March 5, 2025 17:27
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/13681856437

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 212793

Questions ?

Please refer to the Backport tool documentation

@peteharverson
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels chore :ml release_note:skip Skip the PR/issue when compiling release notes v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants