Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
],
"kbn_references": [
"@kbn/core-application-browser",
"@kbn/utility-types",
"@kbn/share-plugin",
]
}
8 changes: 8 additions & 0 deletions x-pack/plugins/index_management/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
}),
};
3 changes: 3 additions & 0 deletions x-pack/plugins/index_management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
37 changes: 37 additions & 0 deletions x-pack/plugins/index_management/public/locator.test.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
42 changes: 42 additions & 0 deletions x-pack/plugins/index_management/public/locator.ts
Original file line number Diff line number Diff line change
@@ -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!),
};
}
}
};
}
10 changes: 10 additions & 0 deletions x-pack/plugins/index_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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
Expand All @@ -40,6 +42,7 @@ export class IndexMgmtUIPlugin
>
{
private extensionsService = new ExtensionsService();
private locator?: IndexManagementLocator;
private kibanaVersion: SemVer;
private config: {
enableIndexActions: boolean;
Expand Down Expand Up @@ -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,
};
}

Expand Down