[8.x] [Index management] Add locator for deep linking into datastreams flyout (#195299) (#196123)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Index management] Add locator for deep linking into datastreams
flyout (#195299)](https://github.com/elastic/kibana/pull/195299)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Ignacio
Rivas","email":"rivasign@gmail.com"},"sourceCommit":{"committedDate":"2024-10-08T12:36:55Z","message":"[Index
management] Add locator for deep linking into datastreams flyout
(#195299)","sha":"17ae71b3d9008bc41582c8c92e1c3dadddd2e38b","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Index
Management","Team:Kibana
Management","release_note:skip","v9.0.0","backport:prev-minor"],"title":"[Index
management] Add locator for deep linking into datastreams
flyout","number":195299,"url":"https://github.com/elastic/kibana/pull/195299","mergeCommit":{"message":"[Index
management] Add locator for deep linking into datastreams flyout
(#195299)","sha":"17ae71b3d9008bc41582c8c92e1c3dadddd2e38b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195299","number":195299,"mergeCommit":{"message":"[Index
management] Add locator for deep linking into datastreams flyout
(#195299)","sha":"17ae71b3d9008bc41582c8c92e1c3dadddd2e38b"}}]}]
BACKPORT-->

Co-authored-by: Ignacio Rivas <rivasign@gmail.com>
This commit is contained in:
Kibana Machine 2024-10-15 00:47:57 +11:00 committed by GitHub
parent 2d16d45d1d
commit d3a6059054
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 112 additions and 0 deletions

View file

@ -12,12 +12,22 @@ import {
Uuid,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { ScopedHistory } from '@kbn/core-application-browser';
import type { SerializableRecord } from '@kbn/utility-types';
import type { LocatorPublic } from '@kbn/share-plugin/public';
import { ExtensionsSetup } from './services/extensions_service';
import { PublicApiServiceSetup } from './services/public_api_service';
export interface IndexManagementLocatorParams extends SerializableRecord {
page: 'data_streams_details';
dataStreamName?: string;
}
export type IndexManagementLocator = LocatorPublic<IndexManagementLocatorParams>;
export interface IndexManagementPluginSetup {
apiService: PublicApiServiceSetup;
extensionsService: ExtensionsSetup;
locator?: IndexManagementLocator;
}
export interface IndexManagementPluginStart {

View file

@ -17,5 +17,7 @@
],
"kbn_references": [
"@kbn/core-application-browser",
"@kbn/utility-types",
"@kbn/share-plugin",
]
}

View file

@ -5,6 +5,7 @@
* 2.0.
*/
import { i18n } from '@kbn/i18n';
export { BASE_PATH } from './base_path';
export { API_BASE_PATH, INTERNAL_API_BASE_PATH } from './api_base_path';
export { INVALID_INDEX_PATTERN_CHARS, INVALID_TEMPLATE_NAME_CHARS } from './invalid_characters';
@ -57,3 +58,10 @@ export { MAJOR_VERSION } from './plugin';
export { Section, IndexDetailsSection } from '@kbn/index-management-shared-types';
export type { IndexDetailsTab, IndexDetailsTabId } from '@kbn/index-management-shared-types';
export * from './allow_auto_create';
export const PLUGIN = {
ID: 'index_management',
TITLE: i18n.translate('xpack.idxMgmt.appTitle', {
defaultMessage: 'Index Management',
}),
};

View file

@ -22,3 +22,6 @@ export type {
} from '@kbn/index-management-shared-types';
export { getIndexListUri, getTemplateDetailsLink } from './application/services/routing';
export type { IndexManagementLocatorParams } from '@kbn/index-management-shared-types';
export { INDEX_MANAGEMENT_LOCATOR_ID } from './locator';

View file

@ -0,0 +1,37 @@
/*
* 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 { sharePluginMock } from '@kbn/share-plugin/public/mocks';
import { ManagementAppLocatorDefinition } from '@kbn/management-plugin/common/locator';
import { IndexManagementLocatorDefinition, INDEX_MANAGEMENT_LOCATOR_ID } from './locator';
describe('Index Management URL locator', () => {
let locator: IndexManagementLocatorDefinition;
beforeEach(() => {
const managementDefinition = new ManagementAppLocatorDefinition();
locator = new IndexManagementLocatorDefinition({
managementAppLocator: {
...sharePluginMock.createLocator(),
getLocation: (params) => managementDefinition.getLocation(params),
},
});
});
test('locator has the right ID', () => {
expect(locator.id).toBe(INDEX_MANAGEMENT_LOCATOR_ID);
});
test('locator returns the correct url for data streams details', async () => {
const { path } = await locator.getLocation({
page: 'data_streams_details',
dataStreamName: 'test',
});
expect(path).toBe('/data/index_management/data_streams/test');
});
});

View file

@ -0,0 +1,42 @@
/*
* 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 { ManagementAppLocator } from '@kbn/management-plugin/common';
import { LocatorDefinition } from '@kbn/share-plugin/public';
import { IndexManagementLocatorParams } from '@kbn/index-management-shared-types';
import { getDataStreamDetailsLink } from './application/services/routing';
import { PLUGIN } from '../common/constants';
export const INDEX_MANAGEMENT_LOCATOR_ID = 'INDEX_MANAGEMENT_LOCATOR_ID';
export interface IndexManagementLocatorDefinitionDependencies {
managementAppLocator: ManagementAppLocator;
}
export class IndexManagementLocatorDefinition
implements LocatorDefinition<IndexManagementLocatorParams>
{
constructor(protected readonly deps: IndexManagementLocatorDefinitionDependencies) {}
public readonly id = INDEX_MANAGEMENT_LOCATOR_ID;
public readonly getLocation = async (params: IndexManagementLocatorParams) => {
const location = await this.deps.managementAppLocator.getLocation({
sectionId: 'data',
appId: PLUGIN.ID,
});
switch (params.page) {
case 'data_streams_details': {
return {
...location,
path: location.path + getDataStreamDetailsLink(params.dataStreamName!),
};
}
}
};
}

View file

@ -19,6 +19,7 @@ import {
IndexManagementPluginSetup,
IndexManagementPluginStart,
} from '@kbn/index-management-shared-types';
import { IndexManagementLocator } from '@kbn/index-management-shared-types';
import { setExtensionsService } from './application/store/selectors/extension_service';
import { ExtensionsService } from './services/extensions_service';
@ -29,6 +30,7 @@ import { PLUGIN } from '../common/constants/plugin';
import { IndexMapping } from './application/sections/home/index_list/details_page/with_context_components/index_mappings_embeddable';
import { PublicApiService } from './services/public_api_service';
import { IndexSettings } from './application/sections/home/index_list/details_page/with_context_components/index_settings_embeddable';
import { IndexManagementLocatorDefinition } from './locator';
export class IndexMgmtUIPlugin
implements
@ -40,6 +42,7 @@ export class IndexMgmtUIPlugin
>
{
private extensionsService = new ExtensionsService();
private locator?: IndexManagementLocator;
private kibanaVersion: SemVer;
private config: {
enableIndexActions: boolean;
@ -112,9 +115,16 @@ export class IndexMgmtUIPlugin
});
}
this.locator = plugins.share.url.locators.create(
new IndexManagementLocatorDefinition({
managementAppLocator: plugins.management.locator,
})
);
return {
apiService: new PublicApiService(coreSetup.http),
extensionsService: this.extensionsService.setup(),
locator: this.locator,
};
}