-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Onboarding] Expose settings component in index_management to r…
…euse in search_indices (#193492) (#193870) # Backport This will backport the following commits from `main` to `8.x`: - [[Onboarding] Expose settings component in index_management to reuse in search_indices (#193492)](#193492) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Saarika Bhasi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-24T13:13:31Z","message":"[Onboarding] Expose settings component in index_management to reuse in search_indices (#193492)\n\n## Summary\r\nThis PR exposes `index_management` index details [settings component\r\n](https://github.com/elastic/kibana/blob/main/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/details_page_settings.tsx#L16)during\r\n`index_management` plugin start. This would enable `search_indices`\r\nplugin to reuse.\r\n\r\nWith this change, in new search index details page user can :\r\n\r\n- Can View settings \r\n- Update settings & save \r\n- Reset changes\r\n\r\n<img width=\"1719\" alt=\"Screenshot 2024-09-19 at 5 48 28 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/a6179fb6-c180-434e-bdb1-3c784006069f\">\r\n\r\n**How to test:** \r\n1. Enable searchIndices plugin in `kibana.dev.yml` as this plugin is\r\nbehind Feature flag\r\n```\r\nxpack.searchIndices.enabled: true\r\n\r\n```\r\n2. [Create new\r\nindex](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html)\r\n3. Navigate to\r\n`/app/elasticsearch/indices/index_details/${indexName}/settings`\r\n\r\n \r\n\r\n### Checklist\r\n\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d925391b90d2ed06c3e940d4112baaa634a9182a","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","backport:prev-minor","v8.16.0"],"title":"[Onboarding] Expose settings component in index_management to reuse in search_indices ","number":193492,"url":"https://github.com/elastic/kibana/pull/193492","mergeCommit":{"message":"[Onboarding] Expose settings component in index_management to reuse in search_indices (#193492)\n\n## Summary\r\nThis PR exposes `index_management` index details [settings component\r\n](https://github.com/elastic/kibana/blob/main/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/details_page_settings.tsx#L16)during\r\n`index_management` plugin start. This would enable `search_indices`\r\nplugin to reuse.\r\n\r\nWith this change, in new search index details page user can :\r\n\r\n- Can View settings \r\n- Update settings & save \r\n- Reset changes\r\n\r\n<img width=\"1719\" alt=\"Screenshot 2024-09-19 at 5 48 28 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/a6179fb6-c180-434e-bdb1-3c784006069f\">\r\n\r\n**How to test:** \r\n1. Enable searchIndices plugin in `kibana.dev.yml` as this plugin is\r\nbehind Feature flag\r\n```\r\nxpack.searchIndices.enabled: true\r\n\r\n```\r\n2. [Create new\r\nindex](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html)\r\n3. Navigate to\r\n`/app/elasticsearch/indices/index_details/${indexName}/settings`\r\n\r\n \r\n\r\n### Checklist\r\n\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d925391b90d2ed06c3e940d4112baaa634a9182a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193492","number":193492,"mergeCommit":{"message":"[Onboarding] Expose settings component in index_management to reuse in search_indices (#193492)\n\n## Summary\r\nThis PR exposes `index_management` index details [settings component\r\n](https://github.com/elastic/kibana/blob/main/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/details_page_settings.tsx#L16)during\r\n`index_management` plugin start. This would enable `search_indices`\r\nplugin to reuse.\r\n\r\nWith this change, in new search index details page user can :\r\n\r\n- Can View settings \r\n- Update settings & save \r\n- Reset changes\r\n\r\n<img width=\"1719\" alt=\"Screenshot 2024-09-19 at 5 48 28 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/a6179fb6-c180-434e-bdb1-3c784006069f\">\r\n\r\n**How to test:** \r\n1. Enable searchIndices plugin in `kibana.dev.yml` as this plugin is\r\nbehind Feature flag\r\n```\r\nxpack.searchIndices.enabled: true\r\n\r\n```\r\n2. [Create new\r\nindex](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html)\r\n3. Navigate to\r\n`/app/elasticsearch/indices/index_details/${indexName}/settings`\r\n\r\n \r\n\r\n### Checklist\r\n\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d925391b90d2ed06c3e940d4112baaa634a9182a"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Saarika Bhasi <[email protected]>
- Loading branch information
1 parent
1e77656
commit 6d44a14
Showing
14 changed files
with
220 additions
and
28 deletions.
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 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
File renamed without changes.
29 changes: 29 additions & 0 deletions
29
...ctions/home/index_list/details_page/with_context_components/index_settings_embeddable.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,29 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/* 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 { EuiLoadingSpinner } from '@elastic/eui'; | ||
import { dynamic } from '@kbn/shared-ux-utility'; | ||
import React, { Suspense, ComponentType } from 'react'; | ||
import { IndexSettingWithContextProps } from './index_settings_with_context_types'; | ||
|
||
const IndexSettingsWithContext = dynamic<ComponentType<IndexSettingWithContextProps>>(() => | ||
import('./index_settings_with_context').then((mod) => ({ default: mod.IndexSettingsWithContext })) | ||
); | ||
|
||
export const IndexSettings: React.FC<IndexSettingWithContextProps> = (props) => { | ||
return ( | ||
<Suspense fallback={<EuiLoadingSpinner />}> | ||
<IndexSettingsWithContext {...props} /> | ||
</Suspense> | ||
); | ||
}; |
52 changes: 52 additions & 0 deletions
52
...ions/home/index_list/details_page/with_context_components/index_settings_with_context.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,52 @@ | ||
/* | ||
* 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 { documentationService } from '../../../../../services'; | ||
import { UIM_APP_NAME } from '../../../../../../../common/constants/ui_metric'; | ||
import { httpService } from '../../../../../services/http'; | ||
import { notificationService } from '../../../../../services/notification'; | ||
import { UiMetricService } from '../../../../../services/ui_metric'; | ||
import { AppDependencies, IndexManagementAppContext } from '../../../../..'; | ||
import { DetailsPageSettings } from '../details_page_settings'; | ||
import { IndexSettingWithContextProps } from './index_settings_with_context_types'; | ||
import { setUiMetricService } from '../../../../../services/api'; | ||
|
||
export const IndexSettingsWithContext: React.FC<IndexSettingWithContextProps> = ({ | ||
core, | ||
dependencies, | ||
indexName, | ||
usageCollection, | ||
}) => { | ||
// this normally happens when the index management app is rendered | ||
// but if components are embedded elsewhere that setup is skipped, so we have to do it here | ||
// would do it in plugin.ts but that blows up the bundle size | ||
// can't do it in an effect because then the first http call fails as the instantiation happens after first render | ||
if (!httpService.httpClient) { | ||
httpService.setup(core.http); | ||
notificationService.setup(core.notifications); | ||
} | ||
documentationService.setup(core.docLinks); | ||
|
||
const uiMetricService = new UiMetricService(UIM_APP_NAME); | ||
setUiMetricService(uiMetricService); | ||
uiMetricService.setup(usageCollection); | ||
|
||
const newDependencies: AppDependencies = { | ||
...dependencies, | ||
services: { | ||
...(dependencies.services || {}), | ||
httpService, | ||
notificationService, | ||
uiMetricService, | ||
}, | ||
}; | ||
return ( | ||
<IndexManagementAppContext core={core} dependencies={newDependencies}> | ||
<DetailsPageSettings indexName={indexName} /> | ||
</IndexManagementAppContext> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
...ome/index_list/details_page/with_context_components/index_settings_with_context_types.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,22 @@ | ||
/* | ||
* 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 { CoreStart } from '@kbn/core/public'; | ||
import type { IndexSettingProps } from '@kbn/index-management-shared-types'; | ||
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public'; | ||
import { AppDependencies } from '../../../../../app_context'; | ||
import { ExtensionsService } from '../../../../../../services/extensions_service'; | ||
|
||
export type IndexSettingWithContextProps = { | ||
core: CoreStart; | ||
// omitting services here to constitute them inside the component | ||
// this helps reduce bundle size significantly | ||
dependencies: Omit<AppDependencies, 'services'> & { | ||
services: { extensionsService: ExtensionsService }; | ||
}; | ||
usageCollection: UsageCollectionSetup; | ||
} & IndexSettingProps; |
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
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/search_indices/public/components/indices/details_page_settings.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,24 @@ | ||
/* | ||
* 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 { useMemo } from 'react'; | ||
import { useKibana } from '../../hooks/use_kibana'; | ||
|
||
interface SearchIndexDetailsSettingsProps { | ||
indexName: string; | ||
} | ||
export const SearchIndexDetailsSettings = ({ indexName }: SearchIndexDetailsSettingsProps) => { | ||
const { indexManagement, history } = useKibana().services; | ||
|
||
const IndexSettingsComponent = useMemo( | ||
() => indexManagement.getIndexSettingsComponent({ history }), | ||
[indexManagement, history] | ||
); | ||
|
||
return <IndexSettingsComponent indexName={indexName} />; | ||
}; |
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
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