Skip to content
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

Refactor saved object management registry usage #54155

Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
feef34c
Migrate registry to TypeScript
kertal Jan 7, 2020
eb45ab0
Adapt plugins
kertal Jan 7, 2020
139fcfc
Migrate management code
kertal Jan 7, 2020
f1f635f
Adapt VisualizeEmbeddableFactory to use createSavedVisLoader
kertal Jan 8, 2020
49bdf27
Merge remote-tracking branch 'upstream/master' into kertal-pr-2020-01…
kertal Jan 8, 2020
aa6ff7c
Improve VisualizeEmbeddableFactory code
kertal Jan 8, 2020
ebadc49
Migrate SavedObjectLoader services registration to management section
kertal Jan 8, 2020
f721047
Merge remote-tracking branch 'upstream/master' into kertal-pr-2020-01…
kertal Jan 8, 2020
a12e7aa
Replace Angular SavedSearchLoader in transform plugin
kertal Jan 8, 2020
efa7a1d
Add data plugin to transform plugin
kertal Jan 8, 2020
9f693c5
Merge remote-tracking branch 'upstream/master' into kertal-pr-2020-01…
kertal Jan 8, 2020
d45ad30
Fix types in transform plugin
kertal Jan 9, 2020
b2208cc
Merge branch 'master' into kertal-pr-2020-01-07-refactor-saved-object…
elasticmachine Jan 13, 2020
691351d
Address review comments
kertal Jan 15, 2020
22f586e
Merge branch 'kertal-pr-2020-01-07-refactor-saved-object-management-r…
kertal Jan 15, 2020
0bdf4df
Centralize getSavedVisualizations function
kertal Jan 20, 2020
f76aeea
Merge master/fix conflicts
kertal Jan 24, 2020
522c197
Migrate saved_visualizations from visualize to visualizations plugin
kertal Jan 24, 2020
2040176
Fix timelion
kertal Jan 24, 2020
0c7b1ac
Fix management objects _view.js angular rendering
kertal Jan 24, 2020
4eed031
Refactor savedVisualizations to getSavedVisualizationsLoader
kertal Jan 24, 2020
c0067da
Merge upstream/master, fix merge problems
kertal Jan 27, 2020
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
4 changes: 0 additions & 4 deletions src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ export default function(kibana) {

uiExports: {
hacks: ['plugins/kibana/discover', 'plugins/kibana/dev_tools', 'plugins/kibana/visualize'],
savedObjectTypes: [
'plugins/kibana/visualize/saved_visualizations/saved_visualization_register',
'plugins/kibana/dashboard/saved_dashboard/saved_dashboard_register',
],
app: {
id: 'kibana',
title: 'Kibana',
Expand Down

This file was deleted.

3 changes: 2 additions & 1 deletion src/legacy/core_plugins/kibana/public/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { npSetup, npStart, legacyChrome } from './legacy_imports';
import { DashboardPlugin, LegacyAngularInjectedDependencies } from './plugin';
import { start as data } from '../../../data/public/legacy';
import { start as embeddables } from '../../../embeddable_api/public/np_ready/public/legacy';
import './saved_dashboard/saved_dashboard_register';
import './dashboard_config';

export * from './np_ready/dashboard_constants';
Expand Down Expand Up @@ -54,3 +53,5 @@ async function getAngularDependencies(): Promise<LegacyAngularInjectedDependenci
navigation: npStart.plugins.navigation,
});
})();

export { createSavedDashboardLoader } from './saved_dashboard/saved_dashboards';

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
*/

export * from './saved_searches';
import './saved_searches_register';

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { npStart } from 'ui/new_platform';
kertal marked this conversation as resolved.
Show resolved Hide resolved
import { SavedObjectLoader } from 'ui/saved_objects';
import { createSavedVisLoader } from '../visualize';
import { createSavedDashboardLoader } from '../dashboard';
kertal marked this conversation as resolved.
Show resolved Hide resolved
import { createSavedSearchesService } from '../discover';

/**
* This registry is used for the editing mode of Saved Searches, Visualizations,
* Dashboard and Time Lion saved objects.
*/
interface SavedObjectRegistryEntry {
id: string;
service: SavedObjectLoader;
title: string;
}

const registry: SavedObjectRegistryEntry[] = [];

export const savedObjectManagementRegistry = {
register: (service: SavedObjectRegistryEntry) => {
registry.push(service);
},
all: () => {
return registry;
},
get: (id: string) => {
return _.find(registry, { id });
},
};

const services = {
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};

savedObjectManagementRegistry.register({
id: 'savedVisualizations',
service: createSavedVisLoader(services),
title: 'visualizations',
});

savedObjectManagementRegistry.register({
id: 'savedDashboards',
service: createSavedDashboardLoader(services),
title: i18n.translate('kbn.dashboard.savedDashboardsTitle', {
defaultMessage: 'dashboards',
}),
});

savedObjectManagementRegistry.register({
id: 'savedSearches',
service: createSavedSearchesService(services),
title: 'searches',
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function updateObjectsTable($scope, $injector) {
const confirmModalPromise = $injector.get('confirmModalPromise');

const savedObjectsClient = Private(SavedObjectsClientProvider);
const services = savedObjectManagementRegistry.all().map(obj => $injector.get(obj.service));
const services = savedObjectManagementRegistry.all().map(obj => obj.service);
const uiCapabilites = npStart.core.application.capabilities;

$scope.$$postDigest(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ uiModules
uiCapabilities
) {
const serviceObj = savedObjectManagementRegistry.get($routeParams.service);
const service = $injector.get(serviceObj.service);
const service = serviceObj.service;
kertal marked this conversation as resolved.
Show resolved Hide resolved
const savedObjectsClient = Private(SavedObjectsClientProvider);
kertal marked this conversation as resolved.
Show resolved Hide resolved

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export function getIndexBreadcrumbs() {
];
}

export function getViewBreadcrumbs($routeParams, $injector) {
export function getViewBreadcrumbs($routeParams) {
const serviceObj = savedObjectManagementRegistry.get($routeParams.service);
const service = $injector.get(serviceObj.service);
const service = serviceObj.service;
kertal marked this conversation as resolved.
Show resolved Hide resolved

return [
...getIndexBreadcrumbs(),
Expand Down

This file was deleted.

Loading