-
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
[Infra Monitoring UI] Change infrastructure pages titles to use breadcrumbs #135874 #140824
Merged
jennypavlova
merged 22 commits into
elastic:main
from
jennypavlova:135874-change-infrastructure-pages-titles-to-use-breadcrumbs
Sep 28, 2022
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e53c650
Use breadcrumbs to set page title intead of DocumentTitle
jennypavlova b3dd5d3
Remove document title component and use breadcrumbs - Logs Page
jennypavlova 4ea8b09
Remove no longer needed document title translations
jennypavlova 4ca752d
Use docTitle.change in error page and remove document title component
jennypavlova 50cc230
Add document title check to the functional tests
jennypavlova 12c7820
Move test to check title after load
jennypavlova a4166c0
test: Title change
jennypavlova 66c356f
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
jennypavlova 80e772a
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
jennypavlova 21fa65d
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
kibanamachine 9c6893c
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
kibanamachine 247702b
Remove unnecessary docTitle type
jennypavlova 4e2fd39
Add error page tests
jennypavlova a801588
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
jennypavlova 88968d8
Update snapshot
jennypavlova 98b9124
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
jennypavlova b084fb7
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
jennypavlova 2245f97
Functional tests: Wait for loading the header before checking the title
jennypavlova 5c9b6d5
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
jennypavlova 525c577
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
jennypavlova e548f25
Merge branch 'main' into 135874-change-infrastructure-pages-titles-to…
jennypavlova 95a5de0
Change test to use react testing library
jennypavlova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { ChromeBreadcrumb } from '@kbn/core/public'; | ||
import { useEffect } from 'react'; | ||
import { observabilityTitle } from '../translations'; | ||
import { useKibanaContextForPlugin } from './use_kibana'; | ||
|
||
export const useDocumentTitle = (extraTitles: ChromeBreadcrumb[]) => { | ||
const { | ||
services: { chrome }, | ||
} = useKibanaContextForPlugin(); | ||
|
||
useEffect(() => { | ||
const docTitle = [{ text: observabilityTitle }, ...extraTitles] | ||
.reverse() | ||
.map((breadcrumb) => breadcrumb.text as string); | ||
|
||
chrome.docTitle.change(docTitle); | ||
}, [chrome, extraTitles]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
x-pack/plugins/infra/public/pages/logs/stream/page_header.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
x-pack/plugins/infra/public/pages/metrics/metric_detail/components/page_error.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import { PageError } from './page_error'; | ||
import { errorTitle } from '../../../../translations'; | ||
import { InfraHttpError } from '../../../../types'; | ||
import { useDocumentTitle } from '../../../../hooks/use_document_title'; | ||
import { I18nProvider } from '@kbn/i18n-react'; | ||
|
||
jest.mock('../../../../hooks/use_document_title', () => ({ | ||
useDocumentTitle: jest.fn(), | ||
})); | ||
|
||
const renderErrorPage = () => | ||
render( | ||
<I18nProvider> | ||
<PageError | ||
name={'test'} | ||
error={ | ||
{ | ||
body: { | ||
statusCode: 500, | ||
message: 'Error Message', | ||
}, | ||
message: 'Error Message', | ||
} as InfraHttpError | ||
} | ||
/> | ||
</I18nProvider> | ||
); | ||
|
||
describe('PageError component', () => { | ||
it('renders correctly and set title', () => { | ||
const { getByText } = renderErrorPage(); | ||
expect(useDocumentTitle).toHaveBeenCalledWith([{ text: `${errorTitle}` }]); | ||
|
||
expect(getByText('Error Message')).toBeInTheDocument(); | ||
expect(getByText('Please click the back button and try again.')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It would be nice to add a test for this one!
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 added one unit test for the error page component and a functional test 4e2fd39