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

[Stack Monitoring] Fix date picker range options #121295

Merged
merged 3 commits into from
Dec 16, 2021

Conversation

Kerry350
Copy link
Contributor

@Kerry350 Kerry350 commented Dec 15, 2021

Summary

Fixes #120999

  • Ensures commonlyUsedRanges are passed to the EuiSuperDatePicker (and these are read from the Kibana settings)
  • Tidies up some types relating to the start contract

Screenshot 2021-12-15 at 13 07 59

Type changes

I made some minor changes to the types that relate to the start (plugins, core etc) contract as I noticed these were incorrect.

https://github.com/elastic/kibana/blob/main/x-pack/plugins/monitoring/public/types.ts#L19 suggests currently that properties such as isCloud, core, element etc exist on the plugins passed as part of start (whereas these will actually just be the defined plugin dependencies).

That type is constructed for the legacy version of the app here: https://github.com/elastic/kibana/blob/main/x-pack/plugins/monitoring/public/plugin.ts#L97

I've therefore made a legacy type, and a standard type. I've also added a StartServices type that is for use with useKibana and accurately reflects the spreading of core and plugins. It might be worth adding a KibanaContext wrapper for Stack Monitoring to wrap up some of this, e.g.: https://github.com/elastic/kibana/blob/main/x-pack/plugins/infra/public/hooks/use_kibana.ts#L18 (there are a lot of individual useKibana calls currently).

(I'm still getting up to speed with SM code, so please let me know if there are reasons for this that aren't "got missed in refactors")

@Kerry350 Kerry350 requested a review from a team December 15, 2021 14:08
@Kerry350 Kerry350 self-assigned this Dec 15, 2021
@Kerry350 Kerry350 added Feature:Stack Monitoring release_note:fix Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v8.1.0 labels Dec 15, 2021
@Kerry350 Kerry350 marked this pull request as ready for review December 15, 2021 14:11
@elasticmachine
Copy link
Contributor

Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI)

Copy link
Contributor

@claudiopro claudiopro left a comment

Choose a reason for hiding this comment

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

I have no context whether types were missed by mistake during a refactor or intentionally, but timepicker option changes look legit to me.

import { useAlertsModal } from '../application/hooks/use_alerts_modal';

export const AlertsDropdown: React.FC<{}> = () => {
const alertsEnableModalProvider = useAlertsModal();
const { navigateToApp } =
useKibana<MonitoringStartPluginDependencies['core']>().services.application;
const { navigateToApp } = useKibana<MonitoringStartServices>().services.application;
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

Comment on lines +40 to +48
const commonlyUsedRanges = useMemo(
() =>
timePickerQuickRanges.map(({ from, to, display }) => ({
start: from,
end: to,
label: display,
})),
[timePickerQuickRanges]
);
Copy link
Contributor

Choose a reason for hiding this comment

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

If TIMEPICKER_QUICK_RANGES don't change during the lifecycle of the app, they could be hoisted at module scope outside of the component... but they depend on a useKibana hook which must live inside of a component 🤷‍♂️

Copy link
Contributor Author

@Kerry350 Kerry350 Dec 16, 2021

Choose a reason for hiding this comment

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

Yep, it's a fair point. I used this chunk of code as-is from other solutions. This code (verbatim) exists in quite a few places now. We should really extract it (most likely to the kibana_react helpers) but that would be way out of scope for this bug fix. I can file an issue for later though (which wouldn't just affect Observability).

For now I'll leave it, as I think having the parity with the other locations is less jarring overall.

@Kerry350
Copy link
Contributor Author

@elasticmachine merge upstream

@Kerry350
Copy link
Contributor Author

@claudiopro Thank you for the review. I'll merge once we're green, there was a random and unrelated test failure.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
monitoring 445.4KB 445.7KB +228.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
monitoring 23.6KB 23.7KB +134.0B

History

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

cc @Kerry350

@Kerry350 Kerry350 merged commit dcd6da7 into elastic:main Dec 16, 2021
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Dec 16, 2021
gbamparop pushed a commit to gbamparop/kibana that referenced this pull request Jan 12, 2022
* Pass commonly used ranges to EuiSuperDatePicker

* Tidy up start contract types
Kerry350 added a commit to Kerry350/kibana that referenced this pull request Jan 17, 2022
* Pass commonly used ranges to EuiSuperDatePicker

* Tidy up start contract types

(cherry picked from commit dcd6da7)
Kerry350 added a commit to Kerry350/kibana that referenced this pull request Jan 17, 2022
* Pass commonly used ranges to EuiSuperDatePicker

* Tidy up start contract types

(cherry picked from commit dcd6da7)

# Conflicts:
#	x-pack/plugins/monitoring/public/plugin.ts
Kerry350 added a commit that referenced this pull request Jan 17, 2022
* Pass commonly used ranges to EuiSuperDatePicker

* Tidy up start contract types

(cherry picked from commit dcd6da7)
Kerry350 added a commit that referenced this pull request Jan 18, 2022
* Pass commonly used ranges to EuiSuperDatePicker

* Tidy up start contract types

(cherry picked from commit dcd6da7)

# Conflicts:
#	x-pack/plugins/monitoring/public/plugin.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Stack Monitoring release_note:fix Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Stack Monitoring] Incorrect Date Options in time picker
5 participants