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

[Infra Monitoring UI] Change infrastructure pages titles to use breadcrumbs #135874 #140824

Conversation

jennypavlova
Copy link
Member

@jennypavlova jennypavlova commented Sep 15, 2022

Summary

Related #135874
This PR changes the titles in Logs and Infrastructure apps. Similar to other apps now the titles are constructed from the breadcrumbs in reverse order. This helps us to keep the titles consistent. Also, it makes it easier for users to navigate using screen readers.

Based on the comment regarding how we should set the document title here I also changed the error page title to use chrome.docTitle.change in (ebe26be). The error page can also use the general breadcrumbs title but it has a different title now. So I kept the current title and added the Observability title part to it so it will be closer to the other page titles.

Example

Old title: Metrics | Inventory - Kibana
New title: Inventory - Infrastructure - Observability - Elastic

Testing

I checked locally. Steps:

  • Navigate to the Infrastructure page
  • Check all document titles (all pages: Hosts/Metrics Explorer/Inventory and sub-pages)
  • Same with Logs pages (Stream/Categories/Anomalies)
    ✅ check in the cloud as well.

@jennypavlova jennypavlova self-assigned this Sep 19, 2022
@jennypavlova jennypavlova added ci:cloud-deploy Create or update a Cloud deployment Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services labels Sep 19, 2022
@jennypavlova jennypavlova force-pushed the 135874-change-infrastructure-pages-titles-to-use-breadcrumbs branch from 5f3d989 to a4166c0 Compare September 22, 2022 16:14
@jennypavlova jennypavlova marked this pull request as ready for review September 23, 2022 09:24
@jennypavlova jennypavlova requested a review from a team as a code owner September 23, 2022 09:24
@elasticmachine
Copy link
Contributor

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

@jennypavlova jennypavlova added release_note:skip Skip the PR/issue when compiling release notes v8.6.0 labels Sep 23, 2022
@smith smith added the technical debt Improvement of the software architecture and operational architecture label Sep 23, 2022
Copy link
Contributor

@crespocarlos crespocarlos 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 this change and for adding the tests 💪 ! I left just a couple of comments, but nothing major.

]);
];

const docTitle: string[] = [...breadcrumbs]
Copy link
Contributor

Choose a reason for hiding this comment

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

We're already casting breadcrumb.text as string so the returned array will be a string[]. Do we still need to declare docTitle as string[]?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, there is no need to declare it. Removed.

import { ErrorPageBody } from '../../../error';
import { InfraHttpError } from '../../../../types';
import { errorTitle } from '../../../../translations';

interface Props {
name: string;
error: InfraHttpError;
}

export const PageError = ({ error, name }: Props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to add a test for this one!

Copy link
Member Author

Choose a reason for hiding this comment

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

I added one unit test for the error page component and a functional test 4e2fd39

@crespocarlos
Copy link
Contributor

crespocarlos commented Sep 26, 2022

The title changes according to what's expected, but the error page apparently has a problem. Perhaps the way I brute-forced an error, by blocking requests to 0.0.0.0:5601/ftw/api/metrics/node_details, isn't the right way. But maybe it's worth to look into.

image

Here the title should contain Uh oh, but metricbeat overview page is always the last to change the title. There is a race condition between useBreadcrumbs and useDocumentTitle, I'm trying to figure out how to solve it.

@crespocarlos
Copy link
Contributor

@elasticmachine merge upstream

@matschaffer
Copy link
Contributor

@elasticmachine merge upstream

@matschaffer

This comment was marked as resolved.

@jennypavlova
Copy link
Member Author

The title changes according to what's expected, but the error page apparently has a problem. Perhaps the way I brute-forced an error, by blocking requests to 0.0.0.0:5601/ftw/api/metrics/node_details, isn't the right way. But maybe it's worth to look into.

image

Here the title should contain Uh oh, but metricbeat overview page is always the last to change the title. There is a race condition between useBreadcrumbs and useDocumentTitle, I'm trying to figure out how to solve it.

@crespocarlos Thank you for finding that! Really interesting when I was testing it I put a not existing name in the url to force the error and it looks good:
image
I will take a look and try to reproduce your case and find a solution.

@jennypavlova jennypavlova removed the ci:cloud-deploy Create or update a Cloud deployment label Sep 28, 2022
Copy link
Contributor

@crespocarlos crespocarlos 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 tests for the page_error component! I just left a couple of comments/questions.

*/

import React from 'react';
import { mount } from 'enzyme';
Copy link
Contributor

Choose a reason for hiding this comment

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

Enzyme works just fine, especially if we need to play with component internals and state. In this case we don't need to do that so I believe we could use react-testing-library. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point, thank you. I agree, I realize that we don't actually need to change the internal state there - just to test if the hook is called and the text error message is correct. I updated it 👍

} as InfraHttpError);

const callOut = mounted.find('EuiCallOut');
expect(callOut.render()).toMatchSnapshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of matching a snapshot, how about if we just assert the existence of the "Please click the back button and try again." on the page?

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the snapshot and I added a check for the error name and message

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
infra 1007 1006 -1

Async chunks

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

id before after diff
infra 1.0MB 1022.9KB -1.6KB

History

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

cc @jennypavlova

Copy link
Contributor

@crespocarlos crespocarlos left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for all the improvements

@jennypavlova jennypavlova merged commit 82492c7 into elastic:main Sep 28, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Sep 28, 2022
@jennypavlova jennypavlova deleted the 135874-change-infrastructure-pages-titles-to-use-breadcrumbs branch September 28, 2022 11:46
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 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 technical debt Improvement of the software architecture and operational architecture v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants