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

[Observability] fix slo observability compressed styles to be not compressed #193081

Merged
merged 29 commits into from
Oct 1, 2024

Conversation

rshen91
Copy link
Contributor

@rshen91 rshen91 commented Sep 16, 2024

Summary

Building off of PR #192993 to revert the compressed styles for SLOs

Compressed styles PR here

Before

In the SLO page in Observability, the status and tags fields are uneven with the unified search bar.
Screenshot 2024-09-30 at 2 10 17 PM

After

Screenshot 2024-09-30 at 2 52 37 PM

@rshen91 rshen91 self-assigned this Sep 16, 2024
@rshen91 rshen91 requested a review from shahzad31 September 16, 2024 19:55
@rshen91 rshen91 marked this pull request as ready for review September 17, 2024 18:48
@rshen91 rshen91 requested review from a team as code owners September 17, 2024 18:48
@rshen91 rshen91 added the release_note:skip Skip the PR/issue when compiling release notes label Sep 17, 2024
@botelastic botelastic bot added ci:project-deploy-observability Create an Observability project Team:obs-ux-management Observability Management User Experience Team labels Sep 17, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

Copy link
Contributor

@Heenawter Heenawter Sep 17, 2024

Choose a reason for hiding this comment

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

@shahzad31 Can you confirm that it is just the SLO page that should have non-compressed styling?

From my understanding, only the SLO page's controls should be impacted - but right now, the Alerts page also uses this QuickFilters component, so the styles have been expanded here, too (and I believe they explicitly prefer the compact styling).

@rshen If possible, I think it would be better to only target the SLO page and not the whole QuickFilters component since this is used a lot more places than just SLO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry - I think this is the SLO page, totally can be misunderstanding though 😶‍🌫️ ? x-pack/plugins/observability_solution/slo/public/pages/slos/components/common/quick_filters.scss

Copy link
Contributor

Choose a reason for hiding this comment

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

i still honestly don't understand why these custom styles are kept in SLO plugin, they should be moved where the control components are.

Copy link
Contributor

@nreese nreese Sep 23, 2024

Choose a reason for hiding this comment

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

@rshen91 One solution to remove custom styles from SLO would be to add a compressed prop to ControlGroupRenderer. Then, ControlGroupRenderer could pass compressed to control group embeddable by adding a compressed boolean in the parent returned from ReactEmbeddableRenderer.getParentApi. Finally, the control group embeddable could use compressed styles if the parentApi contains compressed key where typeof parentApi.compressed === boolean && parentApi.compressed

Copy link
Contributor

@Heenawter Heenawter Sep 23, 2024

Choose a reason for hiding this comment

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

@rshen91 @shahzad31 fyi What @nreese is describing is a potential solution for #189939 that he came up with and we discussed offline :) I think it could work really well for a case like this - we can add a compressed prop to ControlGroupRenderer without having to add "serializable state" to the control group, which is what we were originally trying to avoid with these custom styles.

I think this is the best plan moving forward - sorry for the back and forth 🙇

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is an example for MapRenderer that migrates props from serialized state to parent Api.

@rshen91 rshen91 added the backport:all-open Backport to all branches that could still receive a release label Sep 20, 2024
@MichaelMarcialis
Copy link
Contributor

@rshen91: Any chance you could include before/after sceenshots for this change to help reviewers? Thanks!

})}
onApiAvailable={(controlGroupApi) => {
const controlGroupRendererApi: ControlGroupRendererApi = {
...controlGroupApi,
compressed: compressed ?? true,
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is not needed. compressed should not be something exposed from the ControlGroupApi. Its only used internally by the control group. Its value comes from the parent. Consumers do not need to know about this implementation detail.

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI I think these types / type guards should live under the control_group folder as well - I don't think we should add something so specific to controls under presentation_publishing :)

export const apiHasCompressed = (unknownApi: unknown): unknownApi is HasCompressed => {
return (
(unknownApi as HasCompressed).compressed !== undefined &&
typeof (unknownApi as HasCompressed).compressed === 'function'
Copy link
Contributor

Choose a reason for hiding this comment

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

Type should verify 'boolean', not 'function'. Also, lets put this in controls plugin, since only controls uses this interface for now

export const isCompressed = (
api: DefaultControlApi | HasParentApi | HasCompressed | null | unknown
): boolean => {
if (apiHasCompressed(api)) {
Copy link
Contributor

@nreese nreese Oct 1, 2024

Choose a reason for hiding this comment

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

This is not quite right. Try this instead

function isCompressed(api: unknown) {
    if (apiHasCompressed(api)) return api.compressed;
    return apiHasParentApi(api) ? isCompressed(api.parent) : true;
}

@@ -0,0 +1,19 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

How about moving this into is_compressed.ts?

compressed: boolean;
}

export const apiHasCompressed = (unknownApi: unknown): unknownApi is HasCompressed => {
Copy link
Contributor

Choose a reason for hiding this comment

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

type guards should check for undefined. So you guard should look like Boolean(unknownApi && typeof (unknownApi as HasCompressed).compressed === 'boolean'

import { apiHasCompressed } from './has_compressed';

export function isCompressed(api: unknown): boolean {
if (api === null) return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to check for null. The type guards check that api is defined.

@rshen91 rshen91 requested review from nreese and Heenawter October 1, 2024 19:01
Comment on lines 12 to 18
export interface HasCompressed {
compressed: boolean;
}

export const apiHasCompressed = (unknownApi: unknown): unknownApi is HasCompressed => {
return Boolean(unknownApi) && typeof (unknownApi as HasCompressed).compressed === 'boolean';
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to export these

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the range slider + time slider controls also use the compressed prop on their components, no? We should make this consistent, even if the SLO page does not use these control types

Copy link
Contributor Author

@rshen91 rshen91 Oct 1, 2024

Choose a reason for hiding this comment

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

Sounds good - I'm down for consistency bb77b0d for changes

Copy link
Contributor

@Heenawter Heenawter left a comment

Choose a reason for hiding this comment

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

Thanks for adding the unit tests 🎉 They are very clean. LGTM - code review + tested and ensured only the SLO page is rendering with compressed = false

@rshen91 rshen91 enabled auto-merge (squash) October 1, 2024 21:30
@kibana-ci
Copy link
Collaborator

kibana-ci commented Oct 1, 2024

💚 Build Succeeded

  • Buildkite Build
  • Commit: 00c0670
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-193081-00c06707dd7a

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
controls 355 356 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
controls 130 131 +1

Async chunks

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

id before after diff
controls 458.9KB 459.5KB +624.0B
slo 855.3KB 855.3KB +14.0B
total +638.0B
Unknown metric groups

API count

id before after diff
controls 134 135 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @rshen91

@rshen91 rshen91 merged commit 7a9a519 into elastic:main Oct 1, 2024
23 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 7.17, 8.15, 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 1, 2024
…pressed (elastic#193081)

## Summary

Building off of PR elastic#192993 to
revert the compressed styles for SLOs

Compressed styles PR
[here](elastic#190636)

### Before
In the SLO page in Observability, the status and tags fields are uneven
with the unified search bar.
![Screenshot 2024-09-30 at 2 10
17 PM](https://github.com/user-attachments/assets/63391aa2-ec7d-43f5-9803-8094e73b8a6c)

### After
![Screenshot 2024-09-30 at 2 52
37 PM](https://github.com/user-attachments/assets/fb70109d-15d1-4278-81c6-318da290594f)

(cherry picked from commit 7a9a519)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
7.17 Backport failed because of merge conflicts

You might need to backport the following PRs to 7.17:
- Update ftr (main) (#194509)
8.15 Backport failed because of merge conflicts
8.x

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 193081

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 2, 2024
…ot compressed (#193081) (#194650)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Observability] fix slo observability compressed styles to be not
compressed (#193081)](#193081)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Rachel
Shen","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-01T23:01:20Z","message":"[Observability]
fix slo observability compressed styles to be not compressed
(#193081)\n\n## Summary\r\n\r\nBuilding off of PR
#192993 to\r\nrevert the
compressed styles for SLOs\r\n\r\nCompressed styles
PR\r\n[here](https://github.com/elastic/kibana/pull/190636)\r\n\r\n\r\n###
Before\r\nIn the SLO page in Observability, the status and tags fields
are uneven\r\nwith the unified search bar.\r\n![Screenshot 2024-09-30 at
2
10\r\n17 PM](https://github.com/user-attachments/assets/63391aa2-ec7d-43f5-9803-8094e73b8a6c)\r\n\r\n###
After\r\n![Screenshot 2024-09-30 at 2
52\r\n37 PM](https://github.com/user-attachments/assets/fb70109d-15d1-4278-81c6-318da290594f)","sha":"7a9a5194d7acf8a9e507ae6b6acc9d22f56cf2ea","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:all-open","ci:project-deploy-observability","Team:obs-ux-management"],"title":"[Observability]
fix slo observability compressed styles to be not
compressed","number":193081,"url":"https://github.com/elastic/kibana/pull/193081","mergeCommit":{"message":"[Observability]
fix slo observability compressed styles to be not compressed
(#193081)\n\n## Summary\r\n\r\nBuilding off of PR
#192993 to\r\nrevert the
compressed styles for SLOs\r\n\r\nCompressed styles
PR\r\n[here](https://github.com/elastic/kibana/pull/190636)\r\n\r\n\r\n###
Before\r\nIn the SLO page in Observability, the status and tags fields
are uneven\r\nwith the unified search bar.\r\n![Screenshot 2024-09-30 at
2
10\r\n17 PM](https://github.com/user-attachments/assets/63391aa2-ec7d-43f5-9803-8094e73b8a6c)\r\n\r\n###
After\r\n![Screenshot 2024-09-30 at 2
52\r\n37 PM](https://github.com/user-attachments/assets/fb70109d-15d1-4278-81c6-318da290594f)","sha":"7a9a5194d7acf8a9e507ae6b6acc9d22f56cf2ea"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193081","number":193081,"mergeCommit":{"message":"[Observability]
fix slo observability compressed styles to be not compressed
(#193081)\n\n## Summary\r\n\r\nBuilding off of PR
#192993 to\r\nrevert the
compressed styles for SLOs\r\n\r\nCompressed styles
PR\r\n[here](https://github.com/elastic/kibana/pull/190636)\r\n\r\n\r\n###
Before\r\nIn the SLO page in Observability, the status and tags fields
are uneven\r\nwith the unified search bar.\r\n![Screenshot 2024-09-30 at
2
10\r\n17 PM](https://github.com/user-attachments/assets/63391aa2-ec7d-43f5-9803-8094e73b8a6c)\r\n\r\n###
After\r\n![Screenshot 2024-09-30 at 2
52\r\n37 PM](https://github.com/user-attachments/assets/fb70109d-15d1-4278-81c6-318da290594f)","sha":"7a9a5194d7acf8a9e507ae6b6acc9d22f56cf2ea"}}]}]
BACKPORT-->

Co-authored-by: Rachel Shen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:all-open Backport to all branches that could still receive a release ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants