-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Index Management] Add an index details page behind a dev feature flag #163521
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1d59bda
[Index Management] Add a dev feature flag for the index details page,…
yuliacech 988f4fd
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 6f7ea50
[Index Management] Fix functional tests
yuliacech 58923ae
[Index Management] Add unit tests for the index details page
yuliacech 4935103
[Index Management] Add functional tests for the index details page
yuliacech 7ea1ce0
[Index Management][Index details page] Add useMemo for the header tabs
yuliacech 370d19c
[Index details page] Fix the feature flag after merge conflicts
yuliacech e7eac96
Merge branch 'main' into im/create_details_page
yuliacech e642eff
[Index details page] Fix functional tests after merge conflicts
yuliacech b5f61a1
Merge branch 'main' into im/create_details_page
yuliacech 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 hidden or 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 hidden or 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
68 changes: 68 additions & 0 deletions
68
...x_management/__jest__/client_integration/index_details_page/index_details_page.helpers.ts
This file contains hidden or 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,68 @@ | ||
| /* | ||
| * 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 { AsyncTestBedConfig, registerTestBed, TestBed } from '@kbn/test-jest-helpers'; | ||
| import { HttpSetup } from '@kbn/core/public'; | ||
| import { act } from 'react-dom/test-utils'; | ||
| import { | ||
| IndexDetailsPage, | ||
| IndexDetailsSection, | ||
| } from '../../../public/application/sections/home/index_list/details_page'; | ||
| import { WithAppDependencies } from '../helpers'; | ||
|
|
||
| const testBedConfig: AsyncTestBedConfig = { | ||
| memoryRouter: { | ||
| initialEntries: [`/indices/test_index`], | ||
| componentRoutePath: `/indices/:indexName/:indexDetailsSection?`, | ||
| }, | ||
| doMountAsync: true, | ||
| }; | ||
|
|
||
| export interface IndexDetailsPageTestBed extends TestBed { | ||
| actions: { | ||
| getHeader: () => string; | ||
| clickIndexDetailsTab: (tab: IndexDetailsSection) => Promise<void>; | ||
| getActiveTabContent: () => string; | ||
| }; | ||
| } | ||
|
|
||
| export const setup = async ( | ||
| httpSetup: HttpSetup, | ||
| overridingDependencies: any = {} | ||
| ): Promise<IndexDetailsPageTestBed> => { | ||
| const initTestBed = registerTestBed( | ||
| WithAppDependencies(IndexDetailsPage, httpSetup, overridingDependencies), | ||
| testBedConfig | ||
| ); | ||
| const testBed = await initTestBed(); | ||
|
|
||
| const getHeader = () => { | ||
| return testBed.component.find('[data-test-subj="indexDetailsHeader"] h1').text(); | ||
| }; | ||
|
|
||
| const clickIndexDetailsTab = async (tab: IndexDetailsSection) => { | ||
| const { find, component } = testBed; | ||
|
|
||
| await act(async () => { | ||
| find(`indexDetailsTab-${tab}`).simulate('click'); | ||
| }); | ||
| component.update(); | ||
| }; | ||
|
|
||
| const getActiveTabContent = () => { | ||
| return testBed.find('indexDetailsContent').text(); | ||
| }; | ||
|
|
||
| return { | ||
| ...testBed, | ||
| actions: { | ||
| getHeader, | ||
| clickIndexDetailsTab, | ||
| getActiveTabContent, | ||
| }, | ||
| }; | ||
| }; |
61 changes: 61 additions & 0 deletions
61
...ndex_management/__jest__/client_integration/index_details_page/index_details_page.test.ts
This file contains hidden or 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,61 @@ | ||
| /* | ||
| * 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 { setupEnvironment } from '../helpers'; | ||
| import { IndexDetailsPageTestBed, setup } from './index_details_page.helpers'; | ||
| import { act } from 'react-dom/test-utils'; | ||
| import { httpServiceMock } from '@kbn/core/public/mocks'; | ||
| import { IndexDetailsSection } from '../../../public/application/sections/home/index_list/details_page'; | ||
|
|
||
| describe('<IndexDetailsPage />', () => { | ||
| let testBed: IndexDetailsPageTestBed; | ||
| let httpSetup: ReturnType<typeof setupEnvironment>['httpSetup']; | ||
|
|
||
| beforeEach(async () => { | ||
| httpSetup = httpServiceMock.createSetupContract(); | ||
|
|
||
| await act(async () => { | ||
| testBed = await setup(httpSetup); | ||
| }); | ||
| testBed.component.update(); | ||
| }); | ||
|
|
||
| it('displays index name in the header', () => { | ||
| const header = testBed.actions.getHeader(); | ||
| // test_index is configured in initialEntries of the memory router | ||
| expect(header).toEqual('test_index'); | ||
| }); | ||
|
|
||
| it('defaults to overview tab', () => { | ||
| const tabContent = testBed.actions.getActiveTabContent(); | ||
| expect(tabContent).toEqual('Overview'); | ||
| }); | ||
|
|
||
| it('documents tab', async () => { | ||
| await testBed.actions.clickIndexDetailsTab(IndexDetailsSection.Documents); | ||
| const tabContent = testBed.actions.getActiveTabContent(); | ||
| expect(tabContent).toEqual('Documents'); | ||
| }); | ||
|
|
||
| it('mappings tab', async () => { | ||
| await testBed.actions.clickIndexDetailsTab(IndexDetailsSection.Mappings); | ||
| const tabContent = testBed.actions.getActiveTabContent(); | ||
| expect(tabContent).toEqual('Mappings'); | ||
| }); | ||
|
|
||
| it('settings tab', async () => { | ||
| await testBed.actions.clickIndexDetailsTab(IndexDetailsSection.Settings); | ||
| const tabContent = testBed.actions.getActiveTabContent(); | ||
| expect(tabContent).toEqual('Settings'); | ||
| }); | ||
|
|
||
| it('pipelines tab', async () => { | ||
| await testBed.actions.clickIndexDetailsTab(IndexDetailsSection.Pipelines); | ||
| const tabContent = testBed.actions.getActiveTabContent(); | ||
| expect(tabContent).toEqual('Pipelines'); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
121 changes: 121 additions & 0 deletions
121
...ndex_management/public/application/sections/home/index_list/details_page/details_page.tsx
This file contains hidden or 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,121 @@ | ||
| /* | ||
| * 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, { useCallback, useMemo } from 'react'; | ||
| import { Redirect, RouteComponentProps } from 'react-router-dom'; | ||
| import { Route, Routes } from '@kbn/shared-ux-router'; | ||
| import { FormattedMessage } from '@kbn/i18n-react'; | ||
| import { EuiPageHeader, EuiSpacer, EuiPageHeaderProps } from '@elastic/eui'; | ||
| import { Section } from '../../home'; | ||
|
|
||
| export enum IndexDetailsSection { | ||
| Overview = 'overview', | ||
| Documents = 'documents', | ||
| Mappings = 'mappings', | ||
| Settings = 'settings', | ||
| Pipelines = 'pipelines', | ||
| } | ||
| const tabs = [ | ||
| { | ||
| id: IndexDetailsSection.Overview, | ||
| name: ( | ||
| <FormattedMessage id="xpack.idxMgmt.indexDetails.overviewTitle" defaultMessage="Overview" /> | ||
| ), | ||
| }, | ||
| { | ||
| id: IndexDetailsSection.Documents, | ||
| name: ( | ||
| <FormattedMessage id="xpack.idxMgmt.indexDetails.documentsTitle" defaultMessage="Documents" /> | ||
| ), | ||
| }, | ||
| { | ||
| id: IndexDetailsSection.Mappings, | ||
| name: ( | ||
| <FormattedMessage id="xpack.idxMgmt.indexDetails.mappingsTitle" defaultMessage="Mappings" /> | ||
| ), | ||
| }, | ||
| { | ||
| id: IndexDetailsSection.Settings, | ||
| name: ( | ||
| <FormattedMessage id="xpack.idxMgmt.indexDetails.settingsTitle" defaultMessage="Settings" /> | ||
| ), | ||
| }, | ||
| { | ||
| id: IndexDetailsSection.Pipelines, | ||
| name: ( | ||
| <FormattedMessage id="xpack.idxMgmt.indexDetails.pipelinesTitle" defaultMessage="Pipelines" /> | ||
| ), | ||
| }, | ||
| ]; | ||
| export const DetailsPage: React.FunctionComponent< | ||
| RouteComponentProps<{ indexName: string; indexDetailsSection: IndexDetailsSection }> | ||
| > = ({ | ||
| match: { | ||
| params: { indexName, indexDetailsSection }, | ||
| }, | ||
| history, | ||
| }) => { | ||
| const onSectionChange = useCallback( | ||
| (newSection: IndexDetailsSection) => { | ||
| return history.push(encodeURI(`/indices/${indexName}/${newSection}`)); | ||
| }, | ||
| [history, indexName] | ||
| ); | ||
|
|
||
| const headerTabs = useMemo<EuiPageHeaderProps['tabs']>(() => { | ||
| return tabs.map((tab) => ({ | ||
| onClick: () => onSectionChange(tab.id), | ||
| isSelected: tab.id === indexDetailsSection, | ||
| key: tab.id, | ||
| 'data-test-subj': `indexDetailsTab-${tab.id}`, | ||
| label: tab.name, | ||
| })); | ||
| }, [indexDetailsSection, onSectionChange]); | ||
|
|
||
| return ( | ||
| <> | ||
| <EuiPageHeader | ||
| data-test-subj="indexDetailsHeader" | ||
| pageTitle={indexName} | ||
| bottomBorder | ||
| rightSideItems={[]} | ||
| tabs={headerTabs} | ||
| /> | ||
|
|
||
| <EuiSpacer size="l" /> | ||
|
|
||
| <div data-test-subj={`indexDetailsContent`}> | ||
| <Routes> | ||
| <Route | ||
| path={`/${Section.Indices}/${indexName}/${IndexDetailsSection.Overview}`} | ||
| render={() => <div>Overview</div>} | ||
sabarasaba marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /> | ||
| <Route | ||
| path={`/${Section.Indices}/${indexName}/${IndexDetailsSection.Documents}`} | ||
| render={() => <div>Documents</div>} | ||
| /> | ||
| <Route | ||
| path={`/${Section.Indices}/${indexName}/${IndexDetailsSection.Mappings}`} | ||
| render={() => <div>Mappings</div>} | ||
| /> | ||
| <Route | ||
| path={`/${Section.Indices}/${indexName}/${IndexDetailsSection.Settings}`} | ||
| render={() => <div>Settings</div>} | ||
| /> | ||
| <Route | ||
| path={`/${Section.Indices}/${indexName}/${IndexDetailsSection.Pipelines}`} | ||
| render={() => <div>Pipelines</div>} | ||
| /> | ||
| <Redirect | ||
| from={`/${Section.Indices}/${indexName}`} | ||
| to={`/${Section.Indices}/${indexName}/${IndexDetailsSection.Overview}`} | ||
| /> | ||
| </Routes> | ||
| </div> | ||
| </> | ||
| ); | ||
| }; | ||
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.
is this needed at all?
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.
We'll be adding action buttons on the right side in the next iteration