Remove SavedObjectRegistryProvider from codebase (#53455) (#53745)

This commit is contained in:
Matthias Wilhelm 2019-12-21 13:29:02 +01:00 committed by GitHub
parent a7b7a24b45
commit 4b2a4196f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 317 additions and 366 deletions

View file

@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [BasePath](./kibana-plugin-server.basepath.md) &gt; [get](./kibana-plugin-server.basepath.get.md)
## BasePath.get property
returns `basePath` value, specific for an incoming request.
<b>Signature:</b>
```typescript
get: (request: KibanaRequest<unknown, unknown, unknown, any> | LegacyRequest) => string;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [BasePath](./kibana-plugin-server.basepath.md) &gt; [get](./kibana-plugin-server.basepath.get.md)
## BasePath.get property
returns `basePath` value, specific for an incoming request.
<b>Signature:</b>
```typescript
(request: KibanaRequest<unknown, unknown, unknown, any> | LegacyRequest) => string;
```

View file

@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [BasePath](./kibana-plugin-server.basepath.md) &gt; [set](./kibana-plugin-server.basepath.set.md)
## BasePath.set property
sets `basePath` value, specific for an incoming request.
<b>Signature:</b>
```typescript
set: (request: KibanaRequest<unknown, unknown, unknown, any> | LegacyRequest, requestSpecificBasePath: string) => void;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [BasePath](./kibana-plugin-server.basepath.md) &gt; [set](./kibana-plugin-server.basepath.set.md)
## BasePath.set property
sets `basePath` value, specific for an incoming request.
<b>Signature:</b>
```typescript
(request: KibanaRequest<unknown, unknown, unknown, any> | LegacyRequest, requestSpecificBasePath: string) => void;
```

View file

@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [IRouter](./kibana-plugin-server.irouter.md) &gt; [handleLegacyErrors](./kibana-plugin-server.irouter.handlelegacyerrors.md)
## IRouter.handleLegacyErrors property
Wrap a router handler to catch and converts legacy boom errors to proper custom errors.
<b>Signature:</b>
```typescript
handleLegacyErrors: <P, Q, B>(handler: RequestHandler<P, Q, B>) => RequestHandler<P, Q, B>;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [IRouter](./kibana-plugin-server.irouter.md) &gt; [handleLegacyErrors](./kibana-plugin-server.irouter.handlelegacyerrors.md)
## IRouter.handleLegacyErrors property
Wrap a router handler to catch and converts legacy boom errors to proper custom errors.
<b>Signature:</b>
```typescript
<P, Q, B>(handler: RequestHandler<P, Q, B>) => RequestHandler<P, Q, B>;
```

View file

@ -1,62 +1,62 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteConfig](./kibana-plugin-server.routeconfig.md) &gt; [validate](./kibana-plugin-server.routeconfig.validate.md)
## RouteConfig.validate property
A schema created with `@kbn/config-schema` that every request will be validated against.
<b>Signature:</b>
```typescript
validate: RouteValidatorFullConfig<P, Q, B> | false;
```
## Remarks
You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `validate: false`<!-- -->. In this case request params, query, and body will be \*\*empty\*\* objects and have no access to raw values. In some cases you may want to use another validation library. To do this, you need to instruct the `@kbn/config-schema` library to output \*\*non-validated values\*\* with setting schema as `schema.object({}, { allowUnknowns: true })`<!-- -->;
## Example
```ts
import { schema } from '@kbn/config-schema';
router.get({
path: 'path/{id}',
validate: {
params: schema.object({
id: schema.string(),
}),
query: schema.object({...}),
body: schema.object({...}),
},
},
(context, req, res,) {
req.params; // type Readonly<{id: string}>
console.log(req.params.id); // value
});
router.get({
path: 'path/{id}',
validate: false, // handler has no access to params, query, body values.
},
(context, req, res,) {
req.params; // type Readonly<{}>;
console.log(req.params.id); // undefined
});
router.get({
path: 'path/{id}',
validate: {
// handler has access to raw non-validated params in runtime
params: schema.object({}, { allowUnknowns: true })
},
},
(context, req, res,) {
req.params; // type Readonly<{}>;
console.log(req.params.id); // value
myValidationLibrary.validate({ params: req.params });
});
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteConfig](./kibana-plugin-server.routeconfig.md) &gt; [validate](./kibana-plugin-server.routeconfig.validate.md)
## RouteConfig.validate property
A schema created with `@kbn/config-schema` that every request will be validated against.
<b>Signature:</b>
```typescript
RouteValidatorFullConfig<P, Q, B> | false;
```
## Remarks
You \*must\* specify a validation schema to be able to read: - url path segments - request query - request body To opt out of validating the request, specify `validate: false`<!-- -->. In this case request params, query, and body will be \*\*empty\*\* objects and have no access to raw values. In some cases you may want to use another validation library. To do this, you need to instruct the `@kbn/config-schema` library to output \*\*non-validated values\*\* with setting schema as `schema.object({}, { allowUnknowns: true })`<!-- -->;
## Example
```ts
import { schema } from '@kbn/config-schema';
router.get({
path: 'path/{id}',
validate: {
params: schema.object({
id: schema.string(),
}),
query: schema.object({...}),
body: schema.object({...}),
},
},
(context, req, res,) {
req.params; // type Readonly<{id: string}>
console.log(req.params.id); // value
});
router.get({
path: 'path/{id}',
validate: false, // handler has no access to params, query, body values.
},
(context, req, res,) {
req.params; // type Readonly<{}>;
console.log(req.params.id); // undefined
});
router.get({
path: 'path/{id}',
validate: {
// handler has access to raw non-validated params in runtime
params: schema.object({}, { allowUnknowns: true })
},
},
(context, req, res,) {
req.params; // type Readonly<{}>;
console.log(req.params.id); // value
myValidationLibrary.validate({ params: req.params });
});
```

View file

@ -1,21 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) &gt; [(constructor)](./kibana-plugin-server.routevalidationerror._constructor_.md)
## RouteValidationError.(constructor)
Constructs a new instance of the `RouteValidationError` class
<b>Signature:</b>
```typescript
constructor(error: Error | string, path?: string[]);
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| error | <code>Error &#124; string</code> | |
| path | <code>string[]</code> | |
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) &gt; [(constructor)](./kibana-plugin-server.routevalidationerror._constructor_.md)
## RouteValidationError.(constructor)
Constructs a new instance of the `RouteValidationError` class
<b>Signature:</b>
```typescript
constructor(error;: Error | string, path?: string[];)
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| error | <code>Error &#124; string</code> | |
| path | <code>string[]</code> | |

View file

@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) &gt; [badRequest](./kibana-plugin-server.routevalidationresultfactory.badrequest.md)
## RouteValidationResultFactory.badRequest property
<b>Signature:</b>
```typescript
badRequest: (error: Error | string, path?: string[]) => {
error: RouteValidationError;
};
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) &gt; [badRequest](./kibana-plugin-server.routevalidationresultfactory.badrequest.md)
## RouteValidationResultFactory.badRequest property
<b>Signature:</b>
```typescript
(error: Error | string, path?: string[]) => {
RouteValidationError;
};
```

View file

@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) &gt; [ok](./kibana-plugin-server.routevalidationresultfactory.ok.md)
## RouteValidationResultFactory.ok property
<b>Signature:</b>
```typescript
ok: <T>(value: T) => {
value: T;
};
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) &gt; [ok](./kibana-plugin-server.routevalidationresultfactory.ok.md)
## RouteValidationResultFactory.ok property
<b>Signature:</b>
```typescript
<T>(value: T) => {
T;
};
```

View file

@ -1,17 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) &gt; [unsafe](./kibana-plugin-server.routevalidatoroptions.unsafe.md)
## RouteValidatorOptions.unsafe property
Set the `unsafe` config to avoid running some additional internal \*safe\* validations on top of your custom validation
<b>Signature:</b>
```typescript
unsafe?: {
params?: boolean;
query?: boolean;
body?: boolean;
};
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) &gt; [unsafe](./kibana-plugin-server.routevalidatoroptions.unsafe.md)
## RouteValidatorOptions.unsafe property
Set the `unsafe` config to avoid running some additional internal \*safe\* validations on top of your custom validation
<b>Signature:</b>
```typescript
unsafe?: {
params?: boolean;
query?: boolean;
body?: boolean;
}
```

View file

@ -17,17 +17,11 @@
* under the License.
*/
import {
npSetup,
npStart,
SavedObjectRegistryProvider,
legacyChrome,
IPrivate,
} from './legacy_imports';
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_dashboards';
import './saved_dashboard/saved_dashboard_register';
import './dashboard_config';
export * from './np_ready/dashboard_constants';
@ -39,14 +33,8 @@ export * from './np_ready/dashboard_constants';
async function getAngularDependencies(): Promise<LegacyAngularInjectedDependencies> {
const injector = await legacyChrome.dangerouslyGetActiveInjector();
const Private = injector.get<IPrivate>('Private');
const savedObjectRegistry = Private(SavedObjectRegistryProvider);
return {
dashboardConfig: injector.get('dashboardConfig'),
savedObjectRegistry,
savedDashboards: injector.get('savedDashboards'),
};
}

View file

@ -32,7 +32,6 @@ export { AppState } from 'ui/state_management/app_state';
export { AppStateClass } from 'ui/state_management/app_state';
export { SavedObjectSaveOpts } from 'ui/saved_objects/types';
export { npSetup, npStart } from 'ui/new_platform';
export { SavedObjectRegistryProvider } from 'ui/saved_objects';
export { IPrivate } from 'ui/private';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
@ -65,5 +64,6 @@ export { stateMonitorFactory, StateMonitor } from 'ui/state_management/state_mon
export { ensureDefaultIndexPattern } from 'ui/legacy_compat';
export { unhashUrl } from '../../../../../plugins/kibana_utils/public';
export { IInjector } from 'ui/chrome';
export { SavedObjectLoader } from 'ui/saved_objects';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../visualize_embeddable';
export { registerTimefilterWithGlobalStateFactory } from 'ui/timefilter/setup_router';

View file

@ -42,6 +42,7 @@ import {
RedirectWhenMissingProvider,
confirmModalFactory,
configureAppAngularModule,
SavedObjectLoader,
IPrivate,
} from '../legacy_imports';
@ -57,9 +58,8 @@ export interface RenderDeps {
npDataStart: NpDataStart;
navigation: NavigationStart;
savedObjectsClient: SavedObjectsClientContract;
savedObjectRegistry: any;
savedDashboards: SavedObjectLoader;
dashboardConfig: any;
savedDashboards: any;
dashboardCapabilities: any;
uiSettings: IUiSettingsClient;
chrome: ChromeStart;

View file

@ -98,7 +98,8 @@ export function initDashboardApp(app, deps) {
...defaults,
template: dashboardListingTemplate,
controller($injector, $location, $scope) {
const services = deps.savedObjectRegistry.byLoaderPropertiesName;
const service = deps.savedDashboards;
const kbnUrl = $injector.get('kbnUrl');
const dashboardConfig = deps.dashboardConfig;
@ -107,7 +108,7 @@ export function initDashboardApp(app, deps) {
kbnUrl.redirect(DashboardConstants.CREATE_NEW_DASHBOARD_URL);
};
$scope.find = search => {
return services.dashboards.find(search, $scope.listingLimit);
return service.find(search, $scope.listingLimit);
};
$scope.editItem = ({ id }) => {
kbnUrl.redirect(`${createDashboardEditUrl(id)}?_a=(viewMode:edit)`);
@ -116,7 +117,7 @@ export function initDashboardApp(app, deps) {
return deps.addBasePath(`#${createDashboardEditUrl(id)}`);
};
$scope.delete = dashboards => {
return services.dashboards.delete(dashboards.map(d => d.id));
return service.delete(dashboards.map(d => d.id));
};
$scope.hideWriteControls = dashboardConfig.getHideWriteControls();
$scope.initialFilter = $location.search().filter || EMPTY_FILTER;

View file

@ -39,11 +39,10 @@ import {
FeatureCatalogueCategory,
} from '../../../../../plugins/home/public';
import { KibanaLegacySetup } from '../../../../../plugins/kibana_legacy/public';
import { createSavedDashboardLoader } from './saved_dashboard/saved_dashboards';
export interface LegacyAngularInjectedDependencies {
dashboardConfig: any;
savedObjectRegistry: any;
savedDashboards: any;
}
export interface DashboardPluginStartDependencies {
@ -90,6 +89,13 @@ export class DashboardPlugin implements Plugin {
npDataStart,
} = this.startDependencies;
const angularDependencies = await getAngularDependencies();
const savedDashboards = createSavedDashboardLoader({
savedObjectsClient,
indexPatterns: npDataStart.indexPatterns,
chrome: contextCore.chrome,
overlays: contextCore.overlays,
});
const deps: RenderDeps = {
core: contextCore as LegacyCoreStart,
...angularDependencies,
@ -97,6 +103,7 @@ export class DashboardPlugin implements Plugin {
share,
npDataStart,
savedObjectsClient,
savedDashboards,
chrome: contextCore.chrome,
addBasePath: contextCore.http.basePath.prepend,
uiSettings: contextCore.uiSettings,

View file

@ -16,10 +16,31 @@
* specific language governing permissions and limitations
* under the License.
*/
import { i18n } from '@kbn/i18n';
import { npStart } from 'ui/new_platform';
// @ts-ignore
import { uiModules } from 'ui/modules';
// @ts-ignore
import { savedObjectManagementRegistry } from '../../management/saved_object_registry';
import { createSavedDashboardLoader } from './saved_dashboards';
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import './saved_dashboards';
const module = uiModules.get('app/dashboard');
SavedObjectRegistryProvider.register((savedDashboards: any) => {
return savedDashboards;
// Register this service with the saved object registry so it can be
// edited by the object editor.
savedObjectManagementRegistry.register({
service: 'savedDashboards',
title: i18n.translate('kbn.dashboard.savedDashboardsTitle', {
defaultMessage: 'dashboards',
}),
});
// this is no longer used in the conroller, but just here for savedObjectManagementRegistry
module.service('savedDashboards', () =>
createSavedDashboardLoader({
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
})
);

View file

@ -17,36 +17,11 @@
* under the License.
*/
import { i18n } from '@kbn/i18n';
import { npStart } from 'ui/new_platform';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { SavedObjectLoader } from 'ui/saved_objects';
// @ts-ignore
import { savedObjectManagementRegistry } from '../../management/saved_object_registry';
import { SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { createSavedDashboardClass } from './saved_dashboard';
const module = uiModules.get('app/dashboard');
// Register this service with the saved object registry so it can be
// edited by the object editor.
savedObjectManagementRegistry.register({
service: 'savedDashboards',
title: i18n.translate('kbn.dashboard.savedDashboardsTitle', {
defaultMessage: 'dashboards',
}),
});
// This is the only thing that gets injected into controllers
module.service('savedDashboards', function() {
const savedObjectsClient = npStart.core.savedObjects.client;
const services = {
savedObjectsClient,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};
export function createSavedDashboardLoader(services: SavedObjectKibanaServices) {
const SavedDashboard = createSavedDashboardClass(services);
return new SavedObjectLoader(SavedDashboard, savedObjectsClient, npStart.core.chrome);
});
return new SavedObjectLoader(SavedDashboard, services.savedObjectsClient, services.chrome);
}

View file

@ -18,7 +18,6 @@
*/
import { PluginInitializer, PluginInitializerContext } from 'kibana/public';
import { npSetup, npStart } from 'ui/new_platform';
import { SavedObjectRegistryProvider } from 'ui/saved_objects';
import { DiscoverPlugin, DiscoverSetup, DiscoverStart } from './plugin';
// Core will be looking for this when loading our plugin in the new platform
@ -33,8 +32,4 @@ export const pluginInstance = plugin({} as PluginInitializerContext);
pluginInstance.start(npStart.core, npStart.plugins);
})();
SavedObjectRegistryProvider.register((savedSearches: any) => {
return savedSearches;
});
export { createSavedSearchesService } from './saved_searches/saved_searches';

View file

@ -31,13 +31,13 @@ savedObjectManagementRegistry.register({
service: 'savedSearches',
title: 'searches',
});
const services = {
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};
const savedSearches = createSavedSearchesService(services);
const module = uiModules.get('discover/saved_searches');
module.service('savedSearches', () => {
const services = {
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};
return createSavedSearchesService(services);
});
module.service('savedSearches', () => savedSearches);

View file

@ -25,7 +25,6 @@ import {
legacyChrome,
npSetup,
npStart,
SavedObjectRegistryProvider,
VisEditorTypesRegistryProvider,
} from './legacy_imports';
import { VisualizePlugin, LegacyAngularInjectedDependencies } from './plugin';
@ -45,13 +44,10 @@ async function getAngularDependencies(): Promise<LegacyAngularInjectedDependenci
const Private = injector.get<IPrivate>('Private');
const editorTypes = Private(VisEditorTypesRegistryProvider);
const savedObjectRegistry = Private(SavedObjectRegistryProvider);
return {
legacyChrome,
editorTypes,
savedObjectRegistry,
savedVisualizations: injector.get('savedVisualizations'),
};
}
@ -69,3 +65,5 @@ async function getAngularDependencies(): Promise<LegacyAngularInjectedDependenci
visualizations,
});
})();
export { createSavedVisLoader } from './saved_visualizations/saved_visualizations';

View file

@ -48,7 +48,6 @@ export interface VisualizeKibanaServices {
navigation: NavigationStart;
toastNotifications: ToastsStart;
savedObjectsClient: SavedObjectsClientContract;
savedObjectRegistry: any;
savedQueryService: DataPublicPluginStart['query']['savedQueries'];
savedVisualizations: SavedVisualizations;
share: SharePluginStart;

View file

@ -43,7 +43,6 @@ export { IPrivate } from 'ui/private';
// @ts-ignore
export { PrivateProvider } from 'ui/private/private';
export { SavedObjectRegistryProvider } from 'ui/saved_objects';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';

View file

@ -48,8 +48,8 @@ export function VisualizeListingController($injector, createNewVis) {
addBasePath,
chrome,
legacyChrome,
savedObjectRegistry,
savedObjectsClient,
savedVisualizations,
data: {
query: {
timefilter: { timefilter },
@ -97,15 +97,11 @@ export function VisualizeListingController($injector, createNewVis) {
// In case the user navigated to the page via the /visualize/new URL we start the dialog immediately
this.createNewVis();
}
// TODO: Extract this into an external service.
const services = savedObjectRegistry.byLoaderPropertiesName;
const visualizationService = services.visualizations;
this.visTypeRegistry = visualizations.types;
this.fetchItems = filter => {
const isLabsEnabled = uiSettings.get('visualize:enableLabs');
return visualizationService
return savedVisualizations
.findListItems(filter, uiSettings.get('savedObjects:listingLimit'))
.then(result => {
this.totalItems = result.total;

View file

@ -46,14 +46,12 @@ import {
VisualizeEmbeddableFactory,
VISUALIZE_EMBEDDABLE_TYPE,
} from './legacy_imports';
import { SavedVisualizations } from './np_ready/types';
import { UsageCollectionSetup } from '../../../../../plugins/usage_collection/public';
import { createSavedVisLoader } from './saved_visualizations/saved_visualizations';
export interface LegacyAngularInjectedDependencies {
legacyChrome: any;
editorTypes: any;
savedObjectRegistry: any;
savedVisualizations: SavedVisualizations;
}
export interface VisualizePluginStartDependencies {
@ -110,6 +108,12 @@ export class VisualizePlugin implements Plugin {
} = this.startDependencies;
const angularDependencies = await getAngularDependencies();
const savedVisualizations = createSavedVisLoader({
savedObjectsClient,
indexPatterns: data.indexPatterns,
chrome: contextCore.chrome,
overlays: contextCore.overlays,
});
const deps: VisualizeKibanaServices = {
...angularDependencies,
addBasePath: contextCore.http.basePath.prepend,
@ -122,6 +126,7 @@ export class VisualizePlugin implements Plugin {
localStorage: new Storage(localStorage),
navigation,
savedObjectsClient,
savedVisualizations,
savedQueryService: data.query.savedQueries,
share,
toastNotifications: contextCore.notifications.toasts,

View file

@ -16,15 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import { npStart } from 'ui/new_platform';
// @ts-ignore
import { uiModules } from 'ui/modules';
// @ts-ignore
import { savedObjectManagementRegistry } from '../../management/saved_object_registry';
import './saved_visualizations';
import { createSavedVisLoader } from './saved_visualizations';
SavedObjectRegistryProvider.register((savedVisualizations: any) => {
return savedVisualizations;
});
const services = {
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};
const savedObjectLoaderVisualize = createSavedVisLoader(services);
// Register this service with the saved object registry so it can be
// edited by the object editor.
@ -32,3 +39,5 @@ savedObjectManagementRegistry.register({
service: 'savedVisualizations',
title: 'visualizations',
});
uiModules.get('app/visualize').service('savedVisualizations', () => savedObjectLoaderVisualize);

View file

@ -16,26 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
import { npStart } from 'ui/new_platform';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { SavedObjectLoader } from 'ui/saved_objects';
import { SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { start as visualizations } from '../../../../visualizations/public/np_ready/public/legacy';
// @ts-ignore
import { findListItems } from './find_list_items';
import { createSavedVisClass } from './_saved_vis';
import { createVisualizeEditUrl } from '..';
const app = uiModules.get('app/visualize');
app.service('savedVisualizations', function() {
const savedObjectsClient = npStart.core.savedObjects.client;
const services = {
savedObjectsClient,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};
export function createSavedVisLoader(services: SavedObjectKibanaServices) {
const { savedObjectsClient } = services;
class SavedObjectLoaderVisualize extends SavedObjectLoader {
mapHitSource = (source: Record<string, any>, id: string) => {
const visTypes = visualizations.types;
@ -81,6 +73,5 @@ app.service('savedVisualizations', function() {
}
}
const SavedVis = createSavedVisClass(services);
return new SavedObjectLoaderVisualize(SavedVis, savedObjectsClient, npStart.core.chrome);
});
return new SavedObjectLoaderVisualize(SavedVis, savedObjectsClient, services.chrome);
}

View file

@ -23,7 +23,6 @@ import { i18n } from '@kbn/i18n';
import { capabilities } from 'ui/capabilities';
import { docTitle } from 'ui/doc_title';
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import { fatalError, toastNotifications } from 'ui/notify';
import { timezoneProvider } from 'ui/vis/lib/timezone';
import { timefilter } from 'ui/timefilter';
@ -36,16 +35,15 @@ require('ui/autoload/all');
// TODO: remove ui imports completely (move to plugins)
import 'ui/directives/input_focus';
import 'ui/directives/saved_object_finder';
import './directives/saved_object_finder';
import 'ui/directives/listen';
import 'ui/kbn_top_nav';
import 'ui/saved_objects/ui/saved_object_save_as_checkbox';
import '../../data/public/legacy';
import './services/saved_sheets';
import './services/_saved_sheet';
import './services/saved_sheet_register';
import rootTemplate from 'plugins/timelion/index.html';
import { createSavedVisLoader } from '../../kibana/public/visualize';
require('plugins/timelion/directives/cells/cells');
require('plugins/timelion/directives/fixed_element');
@ -130,8 +128,12 @@ app.controller('timelion', function(
timefilter.enableAutoRefreshSelector();
timefilter.enableTimeRangeSelector();
const savedVisualizations = Private(SavedObjectRegistryProvider).byLoaderPropertiesName
.visualizations;
const savedVisualizations = createSavedVisLoader({
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
});
const timezone = Private(timezoneProvider)();
const defaultExpression = '.es(*)';

View file

@ -23,7 +23,7 @@
<div class="kuiBarSection">
<p class="kuiText kuiSubduedText"
i18n-id="common.ui.savedObjectFinder.pageItemsFromHitCountDescription"
i18n-id="timelion.savedObjectFinder.pageItemsFromHitCountDescription"
i18n-default-message="{pageFirstItem}-{pageLastItem} of {hitCount}"
i18n-values="{pageFirstItem, pageLastItem, hitCount: finder.hitCount}"
></p>
@ -33,7 +33,7 @@
ng-if="onAddNew"
ng-click="onAddNew()"
data-test-subj="addNewSavedObjectLink"
i18n-id="common.ui.savedObjectFinder.addNewItemButtonLabel"
i18n-id="timelion.savedObjectFinder.addNewItemButtonLabel"
i18n-default-message="Add new {item}"
i18n-values="{item: finder.properties.noun}"
i18n-description="{item} can be a type of object in Kibana, like 'visualization', 'dashboard', etc"
@ -43,7 +43,7 @@
class="kuiButton kuiButton--secondary"
ng-if="!useLocalManagement"
ng-click="finder.manageObjects(finder.properties.name)"
i18n-id="common.ui.savedObjectFinder.manageItemsButtonLabel"
i18n-id="timelion.savedObjectFinder.manageItemsButtonLabel"
i18n-default-message="Manage {items}"
i18n-values="{items: finder.properties.nouns}"
i18n-description="{items} can be a type of object in Kibana, like 'visualizations', 'dashboards', etc"
@ -64,11 +64,11 @@
aria-live="assertive"
>
<span class="euiScreenReaderOnly"
i18n-id="common.ui.savedObjectFinder.sortByButtonLabelScreenReaderOnly"
i18n-id="timelion.savedObjectFinder.sortByButtonLabelScreenReaderOnly"
i18n-default-message="Sort by"
></span>
<span
i18n-id="common.ui.savedObjectFinder.sortByButtonLabel"
i18n-id="timelion.savedObjectFinder.sortByButtonLabel"
i18n-default-message="Name"
></span>
<span
@ -77,12 +77,12 @@
>
<span class="euiScreenReaderOnly"
ng-if="finder.isAscending"
i18n-id="common.ui.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly"
i18n-id="timelion.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly"
i18n-default-message="ascending"
></span>
<span class="euiScreenReaderOnly"
ng-if="!finder.isAscending"
i18n-id="common.ui.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly"
i18n-id="timelion.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly"
i18n-default-message="descending"
></span>
</span>
@ -108,7 +108,7 @@
class="list-group-item list-group-no-results"
ng-if="finder.hits.length === 0"
>
<p i18n-id="common.ui.savedObjectFinder.noMatchesFoundDescription"
<p i18n-id="timelion.savedObjectFinder.noMatchesFoundDescription"
i18n-default-message="No matching {items} found."
i18n-values="{items: finder.properties.nouns}"
i18n-description="{items} can be a type of object in Kibana, like 'visualizations', 'dashboards', etc"

View file

@ -19,19 +19,16 @@
import _ from 'lodash';
import rison from 'rison-node';
import { keyMap } from '../utils/key_map';
import { SavedObjectRegistryProvider } from '../saved_objects/saved_object_registry';
import { uiModules } from '../modules';
import savedObjectFinderTemplate from './partials/saved_object_finder.html';
import './input_focus';
import './paginate';
import { keyMap } from 'ui/utils/key_map';
import { uiModules } from 'ui/modules';
import 'ui/directives/input_focus';
import 'ui/directives/paginate';
import savedObjectFinderTemplate from './saved_object_finder.html';
import { savedSheetLoader } from '../services/saved_sheets';
const module = uiModules.get('kibana');
module.directive('savedObjectFinder', function($location, kbnUrl, Private, config) {
const services = Private(SavedObjectRegistryProvider).byLoaderPropertiesName;
return {
restrict: 'E',
scope: {
@ -76,7 +73,7 @@ module.directive('savedObjectFinder', function($location, kbnUrl, Private, confi
// the list of hits, used to render display
self.hits = [];
self.service = services[$scope.type];
self.service = savedSheetLoader;
self.properties = self.service.loaderProperties;
filterResults();

View file

@ -16,9 +16,4 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import './saved_sheets';
SavedObjectRegistryProvider.register((savedSheets: any) => {
return savedSheets;
});

View file

@ -33,29 +33,28 @@ savedObjectManagementRegistry.register({
title: 'sheets',
});
const savedObjectsClient = npStart.core.savedObjects.client;
const services = {
savedObjectsClient,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};
const SavedSheet = createSavedSheetClass(services, npStart.core.uiSettings);
export const savedSheetLoader = new SavedObjectLoader(
SavedSheet,
savedObjectsClient,
npStart.core.chrome
);
savedSheetLoader.urlFor = id => `#/${encodeURIComponent(id)}`;
// Customize loader properties since adding an 's' on type doesn't work for type 'timelion-sheet'.
savedSheetLoader.loaderProperties = {
name: 'timelion-sheet',
noun: 'Saved Sheets',
nouns: 'saved sheets',
};
// This is the only thing that gets injected into controllers
module.service('savedSheets', function() {
const savedObjectsClient = npStart.core.savedObjects.client;
const services = {
savedObjectsClient,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};
const SavedSheet = createSavedSheetClass(services, npStart.core.uiSettings);
const savedSheetLoader = new SavedObjectLoader(
SavedSheet,
savedObjectsClient,
npStart.core.chrome
);
savedSheetLoader.urlFor = id => `#/${encodeURIComponent(id)}`;
// Customize loader properties since adding an 's' on type doesn't work for type 'timelion-sheet'.
savedSheetLoader.loaderProperties = {
name: 'timelion-sheet',
noun: 'Saved Sheets',
nouns: 'saved sheets',
};
return savedSheetLoader;
});
module.service('savedSheets', () => savedSheetLoader);

View file

@ -17,7 +17,6 @@
* under the License.
*/
export { SavedObjectRegistryProvider } from './saved_object_registry';
export { SavedObjectsClientProvider } from './saved_objects_client_provider';
export { SavedObjectLoader } from './saved_object_loader';
export { findObjectByTitle } from './helpers/find_object_by_title';

View file

@ -1,26 +0,0 @@
/*
* 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 { uiRegistry } from '../registry/_registry';
export const SavedObjectRegistryProvider = uiRegistry({
name: 'savedObjects',
index: ['loaderProperties.name'],
order: ['loaderProperties.name'],
});

View file

@ -472,14 +472,14 @@
"common.ui.notify.toaster.unavailableServerErrorMessage": "HTTP リクエストが接続に失敗しました。Kibana サーバーが実行されていて、ご使用のブラウザの接続が正常に動作していることを確認するか、システム管理者にお問い合わせください。",
"common.ui.paginateControls.pageSizeLabel": "ページサイズ",
"common.ui.paginateControls.scrollTopButtonLabel": "最上部に移動",
"common.ui.savedObjectFinder.addNewItemButtonLabel": "新規 {item} を追加",
"common.ui.savedObjectFinder.manageItemsButtonLabel": "{items} の管理",
"common.ui.savedObjectFinder.noMatchesFoundDescription": "一致する {items} が見つかりません。",
"common.ui.savedObjectFinder.pageItemsFromHitCountDescription": "{hitCount} 件中 {pageFirstItem}-{pageLastItem} 件目",
"common.ui.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly": "昇順",
"common.ui.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly": "降順",
"common.ui.savedObjectFinder.sortByButtonLabel": "名前",
"common.ui.savedObjectFinder.sortByButtonLabelScreenReaderOnly": "並べ替え基準",
"timelion.savedObjectFinder.addNewItemButtonLabel": "新規 {item} を追加",
"timelion.savedObjectFinder.manageItemsButtonLabel": "{items} の管理",
"timelion.savedObjectFinder.noMatchesFoundDescription": "一致する {items} が見つかりません。",
"timelion.savedObjectFinder.pageItemsFromHitCountDescription": "{hitCount} 件中 {pageFirstItem}-{pageLastItem} 件目",
"timelion.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly": "昇順",
"timelion.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly": "降順",
"timelion.savedObjectFinder.sortByButtonLabel": "名前",
"timelion.savedObjectFinder.sortByButtonLabelScreenReaderOnly": "並べ替え基準",
"common.ui.savedObjects.confirmModal.overwriteButtonLabel": "上書き",
"common.ui.savedObjects.confirmModal.overwriteConfirmationMessage": "{title} を上書きしてよろしいですか?",
"common.ui.savedObjects.confirmModal.overwriteTitle": "{name} を上書きしますか?",

View file

@ -472,14 +472,14 @@
"common.ui.notify.toaster.unavailableServerErrorMessage": "HTTP 请求无法连接。请检查 Kibana 服务器是否正在运行以及您的浏览器是否具有有效的连接,或请联系您的系统管理员。",
"common.ui.paginateControls.pageSizeLabel": "页面大小",
"common.ui.paginateControls.scrollTopButtonLabel": "滚动至顶部",
"common.ui.savedObjectFinder.addNewItemButtonLabel": "添加新的 {item}",
"common.ui.savedObjectFinder.manageItemsButtonLabel": "管理 {items}",
"common.ui.savedObjectFinder.noMatchesFoundDescription": "未找到任何匹配的 {items}。",
"common.ui.savedObjectFinder.pageItemsFromHitCountDescription": "{pageFirstItem}-{pageLastItem} 页,共 {hitCount} 页",
"common.ui.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly": "升序",
"common.ui.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly": "降序",
"common.ui.savedObjectFinder.sortByButtonLabel": "名称",
"common.ui.savedObjectFinder.sortByButtonLabelScreenReaderOnly": "排序依据",
"timelion.savedObjectFinder.addNewItemButtonLabel": "添加新的 {item}",
"timelion.savedObjectFinder.manageItemsButtonLabel": "管理 {items}",
"timelion.savedObjectFinder.noMatchesFoundDescription": "未找到任何匹配的 {items}。",
"timelion.savedObjectFinder.pageItemsFromHitCountDescription": "{pageFirstItem}-{pageLastItem} 页,共 {hitCount} 页",
"timelion.savedObjectFinder.sortByButtonLabeAscendingScreenReaderOnly": "升序",
"timelion.savedObjectFinder.sortByButtonLabeDescendingScreenReaderOnly": "降序",
"timelion.savedObjectFinder.sortByButtonLabel": "名称",
"timelion.savedObjectFinder.sortByButtonLabelScreenReaderOnly": "排序依据",
"common.ui.savedObjects.confirmModal.overwriteButtonLabel": "覆盖",
"common.ui.savedObjects.confirmModal.overwriteConfirmationMessage": "确定要覆盖 “{title}”?",
"common.ui.savedObjects.confirmModal.overwriteTitle": "覆盖“{name}”?",