-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
...ck/plugins/observability_solution/slo/public/pages/slos/components/common/quick_filters.scss
Outdated
Show resolved
Hide resolved
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
src/plugins/controls/public/react_controls/control_group/components/control_renderer.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 🙇
There was a problem hiding this comment.
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.
...ck/plugins/observability_solution/slo/public/pages/slos/components/common/quick_filters.scss
Outdated
Show resolved
Hide resolved
@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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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 @@ | |||
/* |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
export interface HasCompressed { | ||
compressed: boolean; | ||
} | ||
|
||
export const apiHasCompressed = (unknownApi: unknown): unknownApi is HasCompressed => { | ||
return Boolean(unknownApi) && typeof (unknownApi as HasCompressed).compressed === 'boolean'; | ||
}; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
History
To update your PR or re-run it, just comment with: cc @rshen91 |
Starting backport for target branches: 7.17, 8.15, 8.x https://github.com/elastic/kibana/actions/runs/11134794003 |
…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)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
…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]>
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.
After