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] No-data page #110432

Merged
merged 31 commits into from
Sep 21, 2021

Conversation

matschaffer
Copy link
Contributor

@matschaffer matschaffer commented Aug 30, 2021

Summary

A no-data react page that uses the NoData react component.

Screen Shot 2021-09-15 at 14 47 46

There is still one caveat:

But I think there's still benefit to merging this to help provide a better "no data" dev experience.

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

Fixes #112217

@matschaffer matschaffer added v8.0.0 Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services Feature:Stack Monitoring auto-backport Deprecated - use backport:version if exact versions are needed v7.16.0 Epic: Stack Monitoring de-angularization labels Aug 30, 2021
@matschaffer matschaffer self-assigned this Aug 30, 2021
<EuiFlexGroup gutterSize="l" justifyContent="spaceBetween" responsive>
<EuiFlexItem />
<EuiFlexItem>
<div>HERE GOES THE TIMEPICKER</div>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PageTemplate seemed like too much for this tiny page, so I just copied over this timepicker placeholder. We'll have to update it once that's sorted for the main pages.

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 it's a tiny page if you look at the controller 😅
But we can also add it later if it's needed. Since the angular page for no data has the MonitoringMain directive and the PageTemplate has some of the logic of that directive I would think that maybe there is something needed from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah maybe "tiny" is overstating it. What I meant was that since it doesn't ever have a title header or tabs, PageTemplate seemed like it might be too much.

I'll revisit once we have setup mode and $http sorted, since it looks like NoData can't do much without those dependencies.


import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
// @ts-ignore
import { NoData as NoDataComponent } from '../../components/no_data';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know your thoughts on this naming. We could potentially call this NoDataPage as an alternative, or rename the NoData component but I figured we should avoid trying to alter the angular UI.

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer calling it NoDataPage as it's how I would name it if I was implementing it from scratch. I don't think we alter the angular UI if we call it NoDataPage since in Angular this is not a component it's a route definition.

@matschaffer
Copy link
Contributor Author

matschaffer commented Aug 30, 2021

Posting as draft for now since I'm sure there's work to do here before merging. Just opening it early for feedback.

@matschaffer
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Contributor

@estermv estermv left a comment

Choose a reason for hiding this comment

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

I left a couple of comments but I didn't test the PR, so I'm not sure of close you are to a working solution (If it's already working you can ignore the comments!).

Basically, I think if we make the model part of the state and we and we update it from the Enabler class, child components should be updated.
Most of the weird things in the Angular controller seem to be to make Angular aware that the model changed inside React components and to re-render them when this happened.

Comment on lines 40 to 48
const model = {
errors: [], // errors can happen from trying to check or set ES settings
checkMessage: null, // message to show while waiting for api response
isLoading: isLoading, // flag for in-progress state of checking for no data reason
isCollectionEnabledUpdating: false, // flags to indicate whether to show a spinner while waiting for ajax
isCollectionEnabledUpdated: false,
isCollectionIntervalUpdating: false,
isCollectionIntervalUpdated: false,
};
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 this should be part of the state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, thanks! I was thinking the same but not sure if it should be one state object or discrete state variables for each (like I did with isLoading).

Comment on lines 90 to 91
const { updateModel } = new ModelUpdater(model);
const enabler = new Enabler(updateModel);
Copy link
Contributor

@estermv estermv Sep 8, 2021

Choose a reason for hiding this comment

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

We don't need the ModelUpdater class, if we make the model part of the state of the component, we could do something like this:

Suggested change
const { updateModel } = new ModelUpdater(model);
const enabler = new Enabler(updateModel);
const updateModel = (properties) => {
setModel({
...model,
...properties
})
}
const enabler = new Enabler(updateModel);

EDIT: setModel is not that simple... I didn't see that errors is an array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NIce, thanks! I'll try out model as a state object and see show that goes.

@matschaffer
Copy link
Contributor Author

@elasticmachine merge upstream

@matschaffer matschaffer changed the title [Stack monitoring] Basic no-data page [Stack monitoring] No-data page Sep 15, 2021
@matschaffer
Copy link
Contributor Author

@elasticmachine merge upstream

@matschaffer matschaffer marked this pull request as ready for review September 15, 2021 05:54
@matschaffer matschaffer requested a review from a team as a code owner September 15, 2021 05:54
@matschaffer matschaffer requested review from a team September 15, 2021 05:54
@elasticmachine
Copy link
Contributor

Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui)

@matschaffer matschaffer added the release_note:skip Skip the PR/issue when compiling release notes label Sep 15, 2021
Copy link
Contributor

@phillipb phillipb left a comment

Choose a reason for hiding this comment

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

Seems to work!

Comment on lines 120 to 121
// TODO not sure if we can add this conditional, but might be required for smooth internal collection enablement
// if (!this.isCollectionEnabledUpdating && !this.isCollectionIntervalUpdating) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Were you able to figure out if this was necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not really clear yet. I sometimes get a refresh of "we couldn't enable monitoring" that might be rooted in these conditionals missing. But I haven't been able to cleanly add them without leading to weird dependency cycles.

Comment on lines +55 to +63
const [model, setModel] = useState({
errors: [], // errors can happen from trying to check or set ES settings
checkMessage: null, // message to show while waiting for api response
isLoading: true, // flag for in-progress state of checking for no data reason
isCollectionEnabledUpdating: false, // flags to indicate whether to show a spinner while waiting for ajax
isCollectionEnabledUpdated: false,
isCollectionIntervalUpdating: false,
isCollectionIntervalUpdated: false,
} as any);
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think you need to change it for this PR, but usually you would want these to all be separate variables. For example: const [isLoading, setIsLoading] = useState(true). You usually want to group things in objects if they are updated at the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was wondering about that. Thanks for the cross check.

The no data flow in angular seemed to contain a lot of updateModel type code so I thought this approach might be better to keep the diff smaller even it's not great practice.


const clusterCheckers: SettingsChecker[] = [
{
message: 'Checking cluster settings API on production cluster',
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to i18n.translate this string

api: '../api/monitoring/v1/elasticsearch_settings/check/cluster',
},
{
message: 'Checking nodes settings API on production cluster',
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to i18n.translate this string

@matschaffer
Copy link
Contributor Author

@elasticmachine merge upstream

This replicates how the angular app did selective re-rendering of the react component, but while still being able to render the component.
@matschaffer
Copy link
Contributor Author

Fixed this caveat in the latest push.

Copy link
Contributor

@phillipb phillipb left a comment

Choose a reason for hiding this comment

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

LGTM!

@matschaffer matschaffer enabled auto-merge (squash) September 21, 2021 15:31
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
monitoring 579 582 +3

Async chunks

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

id before after diff
monitoring 782.6KB 788.4KB +5.8KB

History

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

cc @matschaffer

@matschaffer matschaffer merged commit d37ad90 into elastic:master Sep 21, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Sep 21, 2021
* Basic no-data page

* Rename to NoDataPage

* Add getData property to pass into EuiSuperDatePicker from pages

* Wire getData and redirect for no data page

* Draft port of isLoading & model updating

* Add todo on handling checkers

* Switch to model as state object

* Add checkers

* Porting enabler

* Fix build checks

* Attempting to smooth out enablement

* Clean up CI errors

* Fix breadcrumbs

* Fix linter warning

* Fix checkers dependency (I hope)

* Hook up catchReason

* Add a stub for react setup mode

* Clean warnings

* Fix toggleSetupMode by calling initSetupModeState first

* Translating checker strings

* typo on "xpack"

* Move isCollection/reason check in NoData

This replicates how the angular app did selective re-rendering of the react component, but while still being able to render the component.

Co-authored-by: Kibana Machine <[email protected]>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Sep 21, 2021
* Basic no-data page

* Rename to NoDataPage

* Add getData property to pass into EuiSuperDatePicker from pages

* Wire getData and redirect for no data page

* Draft port of isLoading & model updating

* Add todo on handling checkers

* Switch to model as state object

* Add checkers

* Porting enabler

* Fix build checks

* Attempting to smooth out enablement

* Clean up CI errors

* Fix breadcrumbs

* Fix linter warning

* Fix checkers dependency (I hope)

* Hook up catchReason

* Add a stub for react setup mode

* Clean warnings

* Fix toggleSetupMode by calling initSetupModeState first

* Translating checker strings

* typo on "xpack"

* Move isCollection/reason check in NoData

This replicates how the angular app did selective re-rendering of the react component, but while still being able to render the component.

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Mat Schaffer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Epic: Stack Monitoring de-angularization Feature:Stack Monitoring release_note:skip Skip the PR/issue when compiling release notes Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Stack Monitoring][Angular removal] NoData view
5 participants