Skip to content

Commit

Permalink
Remove the feature catalogue registry (#56755)
Browse files Browse the repository at this point in the history
* Remove FeatureCatalogueRegistryProvider from x-pack:

	*infra
	*maps
	*reporting

* Remove FeatureCatalogueRegistryProvider from x-pack:

	*canvas
	*grokdebugger
	*logstash

* Remove feature_catalogue registry

* Fix featureCatalogue register

* Fix getting all of the registered features

* Remove unused timelion feature register

* Move feature registering into np

* Rename translations

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
sulemanof and elasticmachine authored Feb 10, 2020
1 parent a02232d commit 7f942e5
Show file tree
Hide file tree
Showing 51 changed files with 412 additions and 574 deletions.
15 changes: 0 additions & 15 deletions src/legacy/core_plugins/kibana/public/home/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import { FeatureCatalogueRegistryProvider } from 'ui/registry/feature_catalogue';
import { npSetup, npStart } from 'ui/new_platform';
import chrome from 'ui/chrome';
import { HomePlugin, LegacyAngularInjectedDependencies } from './plugin';
Expand All @@ -44,26 +43,12 @@ async function getAngularDependencies(): Promise<LegacyAngularInjectedDependenci
};
}

let copiedLegacyCatalogue = false;

(async () => {
const instance = new HomePlugin();
instance.setup(npSetup.core, {
...npSetup.plugins,
__LEGACY: {
metadata: npStart.core.injectedMetadata.getLegacyMetadata(),
getFeatureCatalogueEntries: async () => {
if (!copiedLegacyCatalogue) {
const injector = await chrome.dangerouslyGetActiveInjector();
const Private = injector.get<IPrivate>('Private');
// Merge legacy registry with new registry
(Private(FeatureCatalogueRegistryProvider as any) as any).inTitleOrder.map(
npSetup.plugins.home.featureCatalogue.register
);
copiedLegacyCatalogue = true;
}
return npStart.plugins.home.featureCatalogue.get();
},
getAngularDependencies,
},
});
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/kibana/public/home/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ import {
import { UiStatsMetricType } from '@kbn/analytics';
import {
Environment,
FeatureCatalogueEntry,
HomePublicPluginSetup,
FeatureCatalogueEntry,
} from '../../../../../plugins/home/public';
import { KibanaLegacySetup } from '../../../../../plugins/kibana_legacy/public';

export interface HomeKibanaServices {
indexPatternService: any;
getFeatureCatalogueEntries: () => Promise<readonly FeatureCatalogueEntry[]>;
metadata: {
app: unknown;
bundleId: string;
Expand All @@ -58,6 +57,7 @@ export interface HomeKibanaServices {
uiSettings: IUiSettingsClient;
config: KibanaLegacySetup['config'];
homeConfig: HomePublicPluginSetup['config'];
directories: readonly FeatureCatalogueEntry[];
http: HttpStart;
savedObjectsClient: SavedObjectsClientContract;
toastNotifications: NotificationsSetup['toasts'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import { getServices } from '../kibana_services';

export const renderApp = async (element: HTMLElement) => {
const homeTitle = i18n.translate('kbn.home.breadcrumbs.homeTitle', { defaultMessage: 'Home' });
const { getFeatureCatalogueEntries, chrome } = getServices();
const directories = await getFeatureCatalogueEntries();
const { directories, chrome } = getServices();
chrome.setBreadcrumbs([{ text: homeTitle }]);

render(<HomeApp directories={directories} />, element);
Expand Down
6 changes: 4 additions & 2 deletions src/legacy/core_plugins/kibana/public/home/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import { KibanaLegacySetup } from '../../../../../plugins/kibana_legacy/public';
import { UsageCollectionSetup } from '../../../../../plugins/usage_collection/public';
import {
Environment,
FeatureCatalogueEntry,
HomePublicPluginStart,
HomePublicPluginSetup,
FeatureCatalogueEntry,
} from '../../../../../plugins/home/public';

export interface LegacyAngularInjectedDependencies {
Expand Down Expand Up @@ -55,7 +55,6 @@ export interface HomePluginSetupDependencies {
devMode: boolean;
uiSettings: { defaults: UiSettingsState; user?: UiSettingsState | undefined };
};
getFeatureCatalogueEntries: () => Promise<readonly FeatureCatalogueEntry[]>;
getAngularDependencies: () => Promise<LegacyAngularInjectedDependencies>;
};
usageCollection: UsageCollectionSetup;
Expand All @@ -67,6 +66,7 @@ export class HomePlugin implements Plugin {
private dataStart: DataPublicPluginStart | null = null;
private savedObjectsClient: any = null;
private environment: Environment | null = null;
private directories: readonly FeatureCatalogueEntry[] | null = null;

setup(
core: CoreSetup,
Expand Down Expand Up @@ -100,6 +100,7 @@ export class HomePlugin implements Plugin {
environment: this.environment!,
config: kibanaLegacy.config,
homeConfig: home.config,
directories: this.directories!,
...angularDependencies,
});
const { renderApp } = await import('./np_ready/application');
Expand All @@ -110,6 +111,7 @@ export class HomePlugin implements Plugin {

start(core: CoreStart, { data, home }: HomePluginStartDependencies) {
this.environment = home.environment.get();
this.directories = home.featureCatalogue.get();
this.dataStart = data;
this.savedObjectsClient = core.savedObjects.client;
}
Expand Down
21 changes: 0 additions & 21 deletions src/legacy/core_plugins/kibana/public/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { render, unmountComponentAtNode } from 'react-dom';
import { FormattedMessage } from '@kbn/i18n/react';

Expand All @@ -30,10 +29,6 @@ import appTemplate from './app.html';
import landingTemplate from './landing.html';
import { management, MANAGEMENT_BREADCRUMB } from 'ui/management';
import { ManagementSidebarNav } from '../../../../../plugins/management/public';
import {
FeatureCatalogueRegistryProvider,
FeatureCatalogueCategory,
} from 'ui/registry/feature_catalogue';
import { timefilter } from 'ui/timefilter';
import {
EuiPageContent,
Expand Down Expand Up @@ -170,19 +165,3 @@ uiModules.get('apps/management').directive('kbnManagementLanding', function(kbnV
},
};
});

FeatureCatalogueRegistryProvider.register(() => {
return {
id: 'stack-management',
title: i18n.translate('kbn.stackManagement.managementLabel', {
defaultMessage: 'Stack Management',
}),
description: i18n.translate('kbn.stackManagement.managementDescription', {
defaultMessage: 'Your center console for managing the Elastic Stack.',
}),
icon: 'managementApp',
path: '/app/kibana#/management',
showOnHomePage: false,
category: FeatureCatalogueCategory.ADMIN,
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ import indexTemplate from './index.html';
import indexPatternListTemplate from './list.html';
import { IndexPatternTable } from './index_pattern_table';
import { npStart } from 'ui/new_platform';
import {
FeatureCatalogueRegistryProvider,
FeatureCatalogueCategory,
} from 'ui/registry/feature_catalogue';
import { i18n } from '@kbn/i18n';
import { I18nContext } from 'ui/i18n';
import { UICapabilitiesProvider } from 'ui/capabilities/react';
Expand Down Expand Up @@ -175,19 +171,3 @@ management.getSection('kibana').register('index_patterns', {
order: 0,
url: '#/management/kibana/index_patterns/',
});

FeatureCatalogueRegistryProvider.register(() => {
return {
id: 'index_patterns',
title: i18n.translate('kbn.management.indexPatternHeader', {
defaultMessage: 'Index Patterns',
}),
description: i18n.translate('kbn.management.indexPatternLabel', {
defaultMessage: 'Manage the index patterns that help retrieve your data from Elasticsearch.',
}),
icon: 'indexPatternApp',
path: '/app/kibana#/management/kibana/index_patterns',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import './_view';
import './_objects';
import 'ace';
import { uiModules } from 'ui/modules';
import {
FeatureCatalogueRegistryProvider,
FeatureCatalogueCategory,
} from 'ui/registry/feature_catalogue';

// add the module deps to this module
uiModules.get('apps/management');
Expand All @@ -38,20 +34,3 @@ management.getSection('kibana').register('objects', {
order: 10,
url: '#/management/kibana/objects',
});

FeatureCatalogueRegistryProvider.register(() => {
return {
id: 'saved_objects',
title: i18n.translate('kbn.management.objects.savedObjectsTitle', {
defaultMessage: 'Saved Objects',
}),
description: i18n.translate('kbn.management.objects.savedObjectsDescription', {
defaultMessage:
'Import, export, and manage your saved searches, visualizations, and dashboards.',
}),
icon: 'savedObjectsApp',
path: '/app/kibana#/management/kibana/objects',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import { uiModules } from 'ui/modules';
import { capabilities } from 'ui/capabilities';
import { I18nContext } from 'ui/i18n';
import indexTemplate from './index.html';
import {
FeatureCatalogueRegistryProvider,
FeatureCatalogueCategory,
} from 'ui/registry/feature_catalogue';

import React from 'react';
import { AdvancedSettings } from './advanced_settings';
Expand Down Expand Up @@ -83,19 +79,3 @@ management.getSection('kibana').register('settings', {
order: 20,
url: '#/management/kibana/settings',
});

FeatureCatalogueRegistryProvider.register(() => {
return {
id: 'advanced_settings',
title: i18n.translate('kbn.management.settings.advancedSettingsLabel', {
defaultMessage: 'Advanced Settings',
}),
description: i18n.translate('kbn.management.settings.advancedSettingsDescription', {
defaultMessage: 'Directly edit settings that control behavior in Kibana.',
}),
icon: 'advancedSettingsApp',
path: '/app/kibana#/management/kibana/settings',
showOnHomePage: false,
category: FeatureCatalogueCategory.ADMIN,
};
});
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/management/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ import { plugin } from '.';

const pluginInstance = plugin({} as PluginInitializerContext);

export const setup = pluginInstance.setup(npSetup.core, {});
export const setup = pluginInstance.setup(npSetup.core, { home: npSetup.plugins.home });
export const start = pluginInstance.start(npStart.core, {});
15 changes: 13 additions & 2 deletions src/legacy/core_plugins/management/public/np_ready/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@

import { PluginInitializerContext } from 'src/core/public';
import { coreMock } from '../../../../../core/public/mocks';
import { ManagementSetup, ManagementStart, ManagementPlugin } from './plugin';
import {
ManagementSetup,
ManagementStart,
ManagementPlugin,
ManagementPluginSetupDependencies,
} from './plugin';

const createSetupContract = (): ManagementSetup => ({
indexPattern: {
Expand Down Expand Up @@ -49,7 +54,13 @@ const createStartContract = (): ManagementStart => ({});
const createInstance = async () => {
const plugin = new ManagementPlugin({} as PluginInitializerContext);

const setup = plugin.setup(coreMock.createSetup(), {});
const setup = plugin.setup(coreMock.createSetup(), ({
home: {
featureCatalogue: {
register: jest.fn(),
},
},
} as unknown) as ManagementPluginSetupDependencies);
const doStart = () => plugin.start(coreMock.createStart(), {});

return {
Expand Down
12 changes: 7 additions & 5 deletions src/legacy/core_plugins/management/public/np_ready/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
* under the License.
*/
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
import { HomePublicPluginSetup } from 'src/plugins/home/public';
import { IndexPatternManagementService, IndexPatternManagementSetup } from './services';
import {
SavedObjectsManagementService,
SavedObjectsManagementServiceSetup,
} from './services/saved_objects_management';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface ManagementPluginSetupDependencies {}
export interface ManagementPluginSetupDependencies {
home: HomePublicPluginSetup;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface ManagementPluginStartDependencies {}
Expand All @@ -50,10 +52,10 @@ export class ManagementPlugin

constructor(initializerContext: PluginInitializerContext) {}

public setup(core: CoreSetup, deps: ManagementPluginSetupDependencies) {
public setup(core: CoreSetup, { home }: ManagementPluginSetupDependencies) {
return {
indexPattern: this.indexPattern.setup({ httpClient: core.http }),
savedObjects: this.savedObjects.setup(),
indexPattern: this.indexPattern.setup({ httpClient: core.http, home }),
savedObjects: this.savedObjects.setup({ home }),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import {
FeatureCatalogueCategory,
HomePublicPluginSetup,
} from '../../../../../../../plugins/home/public';
import { HttpSetup } from '../../../../../../../core/public';
import { IndexPatternCreationManager, IndexPatternCreationConfig } from './creation';
import { IndexPatternListManager, IndexPatternListConfig } from './list';

interface SetupDependencies {
httpClient: HttpSetup;
home: HomePublicPluginSetup;
}

/**
Expand All @@ -31,13 +37,28 @@ interface SetupDependencies {
* @internal
*/
export class IndexPatternManagementService {
public setup({ httpClient }: SetupDependencies) {
public setup({ httpClient, home }: SetupDependencies) {
const creation = new IndexPatternCreationManager(httpClient);
const list = new IndexPatternListManager();

creation.add(IndexPatternCreationConfig);
list.add(IndexPatternListConfig);

home.featureCatalogue.register({
id: 'index_patterns',
title: i18n.translate('management.indexPatternHeader', {
defaultMessage: 'Index Patterns',
}),
description: i18n.translate('management.indexPatternLabel', {
defaultMessage:
'Manage the index patterns that help retrieve your data from Elasticsearch.',
}),
icon: 'indexPatternApp',
path: '/app/kibana#/management/kibana/index_patterns',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
});

return {
creation,
list,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,35 @@
* specific language governing permissions and limitations
* under the License.
*/

import { i18n } from '@kbn/i18n';
import {
FeatureCatalogueCategory,
HomePublicPluginSetup,
} from '../../../../../../../plugins/home/public';
import { SavedObjectsManagementActionRegistry } from './saved_objects_management_action_registry';

interface SetupDependencies {
home: HomePublicPluginSetup;
}

export class SavedObjectsManagementService {
public setup() {
public setup({ home }: SetupDependencies) {
home.featureCatalogue.register({
id: 'saved_objects',
title: i18n.translate('management.objects.savedObjectsTitle', {
defaultMessage: 'Saved Objects',
}),
description: i18n.translate('management.objects.savedObjectsDescription', {
defaultMessage:
'Import, export, and manage your saved searches, visualizations, and dashboards.',
}),
icon: 'savedObjectsApp',
path: '/app/kibana#/management/kibana/objects',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
});

return {
registry: SavedObjectsManagementActionRegistry,
};
Expand Down
Loading

0 comments on commit 7f942e5

Please sign in to comment.