= minGeohashPixels) {
+ zoomPrecision[zoom] = precision;
+ } else {
+ break;
+ }
+ }
+ }
+ return zoomPrecision;
+}
+
+export function getPrecision(val: string) {
+ let precision = parseInt(val, 10);
+ const maxPrecision = getMaxPrecision();
+
+ if (Number.isNaN(precision)) {
+ precision = DEFAULT_PRECISION;
+ }
+
+ if (precision > maxPrecision) {
+ return maxPrecision;
+ }
+
+ return precision;
+}
diff --git a/src/legacy/ui/public/vis/map/service_settings.d.ts b/src/plugins/maps_legacy/public/map/service_settings.d.ts
similarity index 97%
rename from src/legacy/ui/public/vis/map/service_settings.d.ts
rename to src/plugins/maps_legacy/public/map/service_settings.d.ts
index 6766000861e47..e265accaeb8fd 100644
--- a/src/legacy/ui/public/vis/map/service_settings.d.ts
+++ b/src/plugins/maps_legacy/public/map/service_settings.d.ts
@@ -44,7 +44,7 @@ export interface VectorLayer extends FileLayer {
isEMS: boolean;
}
-export interface ServiceSettings {
+export interface IServiceSettings {
getEMSHotLink(layer: FileLayer): Promise;
getTMSServices(): Promise;
getFileLayers(): Promise;
diff --git a/src/plugins/maps_legacy/public/map/service_settings.js b/src/plugins/maps_legacy/public/map/service_settings.js
new file mode 100644
index 0000000000000..11c853d39e107
--- /dev/null
+++ b/src/plugins/maps_legacy/public/map/service_settings.js
@@ -0,0 +1,254 @@
+/*
+ * 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 MarkdownIt from 'markdown-it';
+import { EMSClient } from '@elastic/ems-client';
+import { i18n } from '@kbn/i18n';
+import { getInjectedVarFunc } from '../kibana_services';
+import { ORIGIN } from '../common/origin';
+
+const TMS_IN_YML_ID = 'TMS in config/kibana.yml';
+
+export class ServiceSettings {
+ constructor() {
+ const getInjectedVar = getInjectedVarFunc();
+ this.mapConfig = getInjectedVar('mapConfig');
+ this.tilemapsConfig = getInjectedVar('tilemapsConfig');
+ const kbnVersion = getInjectedVar('version');
+
+ this._showZoomMessage = true;
+ this._emsClient = new EMSClient({
+ language: i18n.getLocale(),
+ appVersion: kbnVersion,
+ appName: 'kibana',
+ fileApiUrl: this.mapConfig.emsFileApiUrl,
+ tileApiUrl: this.mapConfig.emsTileApiUrl,
+ landingPageUrl: this.mapConfig.emsLandingPageUrl,
+ // Wrap to avoid errors passing window fetch
+ fetchFunction: function(...args) {
+ return fetch(...args);
+ },
+ });
+ this.getTMSOptions();
+ }
+
+ getTMSOptions() {
+ const markdownIt = new MarkdownIt({
+ html: false,
+ linkify: true,
+ });
+
+ // TMS attribution
+ const attributionFromConfig = _.escape(
+ markdownIt.render(this.tilemapsConfig.deprecated.config.options.attribution || '')
+ );
+ // TMS Options
+ this.tmsOptionsFromConfig = _.assign({}, this.tilemapsConfig.deprecated.config.options, {
+ attribution: attributionFromConfig,
+ });
+ }
+
+ shouldShowZoomMessage({ origin }) {
+ return origin === ORIGIN.EMS && this._showZoomMessage;
+ }
+
+ disableZoomMessage() {
+ this._showZoomMessage = false;
+ }
+
+ __debugStubManifestCalls(manifestRetrieval) {
+ const oldGetManifest = this._emsClient.getManifest;
+ this._emsClient.getManifest = manifestRetrieval;
+ return {
+ removeStub: () => {
+ delete this._emsClient.getManifest;
+ //not strictly necessary since this is prototype method
+ if (this._emsClient.getManifest !== oldGetManifest) {
+ this._emsClient.getManifest = oldGetManifest;
+ }
+ },
+ };
+ }
+
+ async getFileLayers() {
+ if (!this.mapConfig.includeElasticMapsService) {
+ return [];
+ }
+
+ const fileLayers = await this._emsClient.getFileLayers();
+ return fileLayers.map(fileLayer => {
+ //backfill to older settings
+ const format = fileLayer.getDefaultFormatType();
+ const meta = fileLayer.getDefaultFormatMeta();
+
+ return {
+ name: fileLayer.getDisplayName(),
+ origin: fileLayer.getOrigin(),
+ id: fileLayer.getId(),
+ created_at: fileLayer.getCreatedAt(),
+ attribution: fileLayer.getHTMLAttribution(),
+ fields: fileLayer.getFieldsInLanguage(),
+ format: format, //legacy: format and meta are split up
+ meta: meta, //legacy, format and meta are split up
+ };
+ });
+ }
+
+ /**
+ * Returns all the services published by EMS (if configures)
+ * It also includes the service configured in tilemap (override)
+ */
+ async getTMSServices() {
+ let allServices = [];
+ if (this.tilemapsConfig.deprecated.isOverridden) {
+ //use tilemap.* settings from yml
+ const tmsService = _.cloneDeep(this.tmsOptionsFromConfig);
+ tmsService.id = TMS_IN_YML_ID;
+ tmsService.origin = ORIGIN.KIBANA_YML;
+ allServices.push(tmsService);
+ }
+
+ if (this.mapConfig.includeElasticMapsService) {
+ const servicesFromManifest = await this._emsClient.getTMSServices();
+ const strippedServiceFromManifest = await Promise.all(
+ servicesFromManifest
+ .filter(tmsService => tmsService.getId() === this.mapConfig.emsTileLayerId.bright)
+ .map(async tmsService => {
+ //shim for compatibility
+ return {
+ origin: tmsService.getOrigin(),
+ id: tmsService.getId(),
+ minZoom: await tmsService.getMinZoom(),
+ maxZoom: await tmsService.getMaxZoom(),
+ attribution: tmsService.getHTMLAttribution(),
+ };
+ })
+ );
+ allServices = allServices.concat(strippedServiceFromManifest);
+ }
+
+ return allServices;
+ }
+
+ /**
+ * Add optional query-parameters to all requests
+ *
+ * @param additionalQueryParams
+ */
+ addQueryParams(additionalQueryParams) {
+ this._emsClient.addQueryParams(additionalQueryParams);
+ }
+
+ async getEMSHotLink(fileLayerConfig) {
+ const fileLayers = await this._emsClient.getFileLayers();
+ const layer = fileLayers.find(fileLayer => {
+ const hasIdByName = fileLayer.hasId(fileLayerConfig.name); //legacy
+ const hasIdById = fileLayer.hasId(fileLayerConfig.id);
+ return hasIdByName || hasIdById;
+ });
+ return layer ? layer.getEMSHotLink() : null;
+ }
+
+ async _getAttributesForEMSTMSLayer(isDesaturated, isDarkMode) {
+ const tmsServices = await this._emsClient.getTMSServices();
+ const emsTileLayerId = this.mapConfig.emsTileLayerId;
+ let serviceId;
+ if (isDarkMode) {
+ serviceId = emsTileLayerId.dark;
+ } else {
+ if (isDesaturated) {
+ serviceId = emsTileLayerId.desaturated;
+ } else {
+ serviceId = emsTileLayerId.bright;
+ }
+ }
+ const tmsService = tmsServices.find(service => {
+ return service.getId() === serviceId;
+ });
+ return {
+ url: await tmsService.getUrlTemplate(),
+ minZoom: await tmsService.getMinZoom(),
+ maxZoom: await tmsService.getMaxZoom(),
+ attribution: await tmsService.getHTMLAttribution(),
+ origin: ORIGIN.EMS,
+ };
+ }
+
+ async getAttributesForTMSLayer(tmsServiceConfig, isDesaturated, isDarkMode) {
+ if (tmsServiceConfig.origin === ORIGIN.EMS) {
+ return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
+ } else if (tmsServiceConfig.origin === ORIGIN.KIBANA_YML) {
+ const config = this.tilemapsConfig.deprecated.config;
+ const attrs = _.pick(config, ['url', 'minzoom', 'maxzoom', 'attribution']);
+ return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
+ } else {
+ //this is an older config. need to resolve this dynamically.
+ if (tmsServiceConfig.id === TMS_IN_YML_ID) {
+ const config = this.tilemapsConfig.deprecated.config;
+ const attrs = _.pick(config, ['url', 'minzoom', 'maxzoom', 'attribution']);
+ return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
+ } else {
+ //assume ems
+ return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
+ }
+ }
+ }
+
+ async _getFileUrlFromEMS(fileLayerConfig) {
+ const fileLayers = await this._emsClient.getFileLayers();
+ const layer = fileLayers.find(fileLayer => {
+ const hasIdByName = fileLayer.hasId(fileLayerConfig.name); //legacy
+ const hasIdById = fileLayer.hasId(fileLayerConfig.id);
+ return hasIdByName || hasIdById;
+ });
+
+ if (layer) {
+ return layer.getDefaultFormatUrl();
+ } else {
+ throw new Error(`File ${fileLayerConfig.name} not recognized`);
+ }
+ }
+
+ async getUrlForRegionLayer(fileLayerConfig) {
+ let url;
+ if (fileLayerConfig.origin === ORIGIN.EMS) {
+ url = this._getFileUrlFromEMS(fileLayerConfig);
+ } else if (fileLayerConfig.layerId && fileLayerConfig.layerId.startsWith(`${ORIGIN.EMS}.`)) {
+ //fallback for older saved objects
+ url = this._getFileUrlFromEMS(fileLayerConfig);
+ } else if (
+ fileLayerConfig.layerId &&
+ fileLayerConfig.layerId.startsWith(`${ORIGIN.KIBANA_YML}.`)
+ ) {
+ //fallback for older saved objects
+ url = fileLayerConfig.url;
+ } else {
+ //generic fallback
+ url = fileLayerConfig.url;
+ }
+ return url;
+ }
+
+ async getJsonForRegionLayer(fileLayerConfig) {
+ const url = await this.getUrlForRegionLayer(fileLayerConfig);
+ const response = await fetch(url);
+ return await response.json();
+ }
+}
diff --git a/src/legacy/ui/public/vis/map/zoom_to_precision.ts b/src/plugins/maps_legacy/public/map/zoom_to_precision.ts
similarity index 100%
rename from src/legacy/ui/public/vis/map/zoom_to_precision.ts
rename to src/plugins/maps_legacy/public/map/zoom_to_precision.ts
diff --git a/src/plugins/maps_legacy/public/plugin.ts b/src/plugins/maps_legacy/public/plugin.ts
new file mode 100644
index 0000000000000..751be65e1dbf6
--- /dev/null
+++ b/src/plugins/maps_legacy/public/plugin.ts
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+// @ts-ignore
+import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
+// @ts-ignore
+import { setToasts, setUiSettings, setInjectedVarFunc } from './kibana_services';
+// @ts-ignore
+import { ServiceSettings } from './map/service_settings';
+// @ts-ignore
+import { getPrecision, getZoomPrecision } from './map/precision';
+import { MapsLegacyPluginSetup, MapsLegacyPluginStart } from './index';
+
+/**
+ * These are the interfaces with your public contracts. You should export these
+ * for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces.
+ * @public
+ */
+
+// eslint-disable-next-line @typescript-eslint/no-empty-interface
+export interface MapsLegacySetupDependencies {}
+// eslint-disable-next-line @typescript-eslint/no-empty-interface
+export interface MapsLegacyStartDependencies {}
+
+export class MapsLegacyPlugin implements Plugin {
+ constructor() {}
+
+ public setup(core: CoreSetup, plugins: MapsLegacySetupDependencies) {
+ setToasts(core.notifications.toasts);
+ setUiSettings(core.uiSettings);
+ setInjectedVarFunc(core.injectedMetadata.getInjectedVar);
+
+ return {
+ serviceSettings: new ServiceSettings(),
+ getZoomPrecision,
+ getPrecision,
+ };
+ }
+
+ public start(core: CoreStart, plugins: MapsLegacyStartDependencies) {}
+}
diff --git a/src/plugins/saved_objects_management/common/index.ts b/src/plugins/saved_objects_management/common/index.ts
new file mode 100644
index 0000000000000..67c3ae6d934ab
--- /dev/null
+++ b/src/plugins/saved_objects_management/common/index.ts
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+export { SavedObjectRelation, SavedObjectWithMetadata, SavedObjectMetadata } from './types';
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/types.ts b/src/plugins/saved_objects_management/common/types.ts
similarity index 74%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/types.ts
rename to src/plugins/saved_objects_management/common/types.ts
index 6a89142bc9798..be52d8e6486e2 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/types.ts
+++ b/src/plugins/saved_objects_management/common/types.ts
@@ -17,8 +17,12 @@
* under the License.
*/
-import { SavedObject, SavedObjectReference } from 'src/core/public';
+import { SavedObject } from 'src/core/types';
+/**
+ * The metadata injected into a {@link SavedObject | saved object} when returning
+ * {@link SavedObjectWithMetadata | enhanced objects} from the plugin API endpoints.
+ */
export interface SavedObjectMetadata {
icon?: string;
title?: string;
@@ -26,31 +30,19 @@ export interface SavedObjectMetadata {
inAppUrl?: { path: string; uiCapabilitiesPath: string };
}
+/**
+ * A {@link SavedObject | saved object} enhanced with meta properties used by the client-side plugin.
+ */
export type SavedObjectWithMetadata = SavedObject & {
meta: SavedObjectMetadata;
};
+/**
+ * Represents a relation between two {@link SavedObject | saved object}
+ */
export interface SavedObjectRelation {
id: string;
type: string;
relationship: 'child' | 'parent';
meta: SavedObjectMetadata;
}
-
-export interface ObjectField {
- type: FieldType;
- name: string;
- value: any;
-}
-
-export type FieldType = 'text' | 'number' | 'boolean' | 'array' | 'json';
-
-export interface FieldState {
- value?: any;
- invalid?: boolean;
-}
-
-export interface SubmittedFormData {
- attributes: any;
- references: SavedObjectReference[];
-}
diff --git a/src/plugins/saved_objects_management/kibana.json b/src/plugins/saved_objects_management/kibana.json
index e1f14b0e3c59d..22135ce4558ae 100644
--- a/src/plugins/saved_objects_management/kibana.json
+++ b/src/plugins/saved_objects_management/kibana.json
@@ -3,5 +3,6 @@
"version": "kibana",
"server": true,
"ui": true,
- "requiredPlugins": ["home"]
+ "requiredPlugins": ["home", "management", "data"],
+ "optionalPlugins": ["dashboard", "visualizations", "discover"]
}
diff --git a/src/plugins/saved_objects_management/public/index.ts b/src/plugins/saved_objects_management/public/index.ts
index 7fb2f137d7d84..b20b320bc6645 100644
--- a/src/plugins/saved_objects_management/public/index.ts
+++ b/src/plugins/saved_objects_management/public/index.ts
@@ -22,10 +22,14 @@ import { SavedObjectsManagementPlugin } from './plugin';
export { SavedObjectsManagementPluginSetup, SavedObjectsManagementPluginStart } from './plugin';
export {
- ISavedObjectsManagementActionRegistry,
+ SavedObjectsManagementActionServiceSetup,
+ SavedObjectsManagementActionServiceStart,
SavedObjectsManagementAction,
SavedObjectsManagementRecord,
+ ISavedObjectsManagementServiceRegistry,
+ SavedObjectsManagementServiceRegistryEntry,
} from './services';
+export { SavedObjectRelation, SavedObjectWithMetadata, SavedObjectMetadata } from './types';
export function plugin(initializerContext: PluginInitializerContext) {
return new SavedObjectsManagementPlugin();
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/case_conversion.test.ts b/src/plugins/saved_objects_management/public/lib/case_conversion.test.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/case_conversion.test.ts
rename to src/plugins/saved_objects_management/public/lib/case_conversion.test.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/case_conversion.ts b/src/plugins/saved_objects_management/public/lib/case_conversion.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/case_conversion.ts
rename to src/plugins/saved_objects_management/public/lib/case_conversion.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/create_field_list.test.ts b/src/plugins/saved_objects_management/public/lib/create_field_list.test.ts
similarity index 96%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/create_field_list.test.ts
rename to src/plugins/saved_objects_management/public/lib/create_field_list.test.ts
index 345716f91ea88..e7d6754ac4d05 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/create_field_list.test.ts
+++ b/src/plugins/saved_objects_management/public/lib/create_field_list.test.ts
@@ -17,8 +17,8 @@
* under the License.
*/
-import { SimpleSavedObject, SavedObjectReference } from '../../../../../../../../core/public';
-import { savedObjectsServiceMock } from '../../../../../../../../core/public/mocks';
+import { SimpleSavedObject, SavedObjectReference } from '../../../../core/public';
+import { savedObjectsServiceMock } from '../../../../core/public/mocks';
import { createFieldList } from './create_field_list';
const savedObjectClientMock = savedObjectsServiceMock.createStartContract().client;
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/create_field_list.ts b/src/plugins/saved_objects_management/public/lib/create_field_list.ts
similarity index 92%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/create_field_list.ts
rename to src/plugins/saved_objects_management/public/lib/create_field_list.ts
index 88a1184d5d70f..5d87c11a87198 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/create_field_list.ts
+++ b/src/plugins/saved_objects_management/public/lib/create_field_list.ts
@@ -18,10 +18,10 @@
*/
import { forOwn, indexBy, isNumber, isBoolean, isPlainObject, isString } from 'lodash';
-import { SimpleSavedObject } from '../../../../../../../../core/public';
-import { castEsToKbnFieldTypeName } from '../../../../../../../../plugins/data/public';
-import { ObjectField } from '../types';
-import { SavedObjectLoader } from '../../../../../../../../plugins/saved_objects/public';
+import { SimpleSavedObject } from '../../../../core/public';
+import { castEsToKbnFieldTypeName } from '../../../data/public';
+import { ObjectField } from '../management_section/types';
+import { SavedObjectLoader } from '../../../saved_objects/public';
const maxRecursiveIterations = 20;
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/extract_export_details.test.ts b/src/plugins/saved_objects_management/public/lib/extract_export_details.test.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/extract_export_details.test.ts
rename to src/plugins/saved_objects_management/public/lib/extract_export_details.test.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/extract_export_details.ts b/src/plugins/saved_objects_management/public/lib/extract_export_details.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/extract_export_details.ts
rename to src/plugins/saved_objects_management/public/lib/extract_export_details.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/fetch_export_by_type_and_search.ts b/src/plugins/saved_objects_management/public/lib/fetch_export_by_type_and_search.ts
similarity index 89%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/fetch_export_by_type_and_search.ts
rename to src/plugins/saved_objects_management/public/lib/fetch_export_by_type_and_search.ts
index d3e527b9f96b7..e0f005fab2a3b 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/fetch_export_by_type_and_search.ts
+++ b/src/plugins/saved_objects_management/public/lib/fetch_export_by_type_and_search.ts
@@ -17,16 +17,15 @@
* under the License.
*/
-import { kfetch } from 'ui/kfetch';
+import { HttpStart } from 'src/core/public';
export async function fetchExportByTypeAndSearch(
+ http: HttpStart,
types: string[],
search: string | undefined,
includeReferencesDeep: boolean = false
): Promise {
- return await kfetch({
- method: 'POST',
- pathname: '/api/saved_objects/_export',
+ return http.post('/api/saved_objects/_export', {
body: JSON.stringify({
type: types,
search,
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/fetch_export_objects.ts b/src/plugins/saved_objects_management/public/lib/fetch_export_objects.ts
similarity index 89%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/fetch_export_objects.ts
rename to src/plugins/saved_objects_management/public/lib/fetch_export_objects.ts
index 744f8ef38af47..745d3758371a3 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/fetch_export_objects.ts
+++ b/src/plugins/saved_objects_management/public/lib/fetch_export_objects.ts
@@ -17,15 +17,14 @@
* under the License.
*/
-import { kfetch } from 'ui/kfetch';
+import { HttpStart } from 'src/core/public';
export async function fetchExportObjects(
+ http: HttpStart,
objects: any[],
includeReferencesDeep: boolean = false
): Promise {
- return await kfetch({
- method: 'POST',
- pathname: '/api/saved_objects/_export',
+ return http.post('/api/saved_objects/_export', {
body: JSON.stringify({
objects,
includeReferencesDeep,
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/find_objects.ts b/src/plugins/saved_objects_management/public/lib/find_objects.ts
similarity index 57%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/find_objects.ts
rename to src/plugins/saved_objects_management/public/lib/find_objects.ts
index 24e08f0524f62..5a77d3ae2f663 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/find_objects.ts
+++ b/src/plugins/saved_objects_management/public/lib/find_objects.ts
@@ -17,16 +17,27 @@
* under the License.
*/
-import { kfetch } from 'ui/kfetch';
-import { SavedObjectsFindOptions } from 'src/core/public';
+import { HttpStart, SavedObjectsFindOptions } from 'src/core/public';
import { keysToCamelCaseShallow } from './case_conversion';
+import { SavedObjectWithMetadata } from '../types';
-export async function findObjects(findOptions: SavedObjectsFindOptions) {
- const response = await kfetch({
- method: 'GET',
- pathname: '/api/kibana/management/saved_objects/_find',
- query: findOptions as Record,
- });
+interface SavedObjectsFindResponse {
+ total: number;
+ page: number;
+ perPage: number;
+ savedObjects: SavedObjectWithMetadata[];
+}
+
+export async function findObjects(
+ http: HttpStart,
+ findOptions: SavedObjectsFindOptions
+): Promise {
+ const response = await http.get>(
+ '/api/kibana/management/saved_objects/_find',
+ {
+ query: findOptions as Record,
+ }
+ );
- return keysToCamelCaseShallow(response);
+ return keysToCamelCaseShallow(response) as SavedObjectsFindResponse;
}
diff --git a/test/functional/config.edge.js b/src/plugins/saved_objects_management/public/lib/get_allowed_types.ts
similarity index 72%
rename from test/functional/config.edge.js
rename to src/plugins/saved_objects_management/public/lib/get_allowed_types.ts
index ed68b41e8c89a..7d952ebf2ca14 100644
--- a/test/functional/config.edge.js
+++ b/src/plugins/saved_objects_management/public/lib/get_allowed_types.ts
@@ -17,18 +17,15 @@
* under the License.
*/
-export default async function({ readConfigFile }) {
- const defaultConfig = await readConfigFile(require.resolve('./config'));
+import { HttpStart } from 'src/core/public';
- return {
- ...defaultConfig.getAll(),
-
- browser: {
- type: 'msedge',
- },
+interface GetAllowedTypesResponse {
+ types: string[];
+}
- junit: {
- reportName: 'MS Chromium Edge UI Functional Tests',
- },
- };
+export async function getAllowedTypes(http: HttpStart) {
+ const response = await http.get(
+ '/api/kibana/management/saved_objects/_allowed_types'
+ );
+ return response.types;
}
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_default_title.ts b/src/plugins/saved_objects_management/public/lib/get_default_title.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_default_title.ts
rename to src/plugins/saved_objects_management/public/lib/get_default_title.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_relationships.test.ts b/src/plugins/saved_objects_management/public/lib/get_relationships.test.ts
similarity index 67%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_relationships.test.ts
rename to src/plugins/saved_objects_management/public/lib/get_relationships.test.ts
index b45b51b4de293..d79447378dde5 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_relationships.test.ts
+++ b/src/plugins/saved_objects_management/public/lib/get_relationships.test.ts
@@ -17,44 +17,43 @@
* under the License.
*/
+import { httpServiceMock } from '../../../../core/public/mocks';
import { getRelationships } from './get_relationships';
describe('getRelationships', () => {
- it('should make an http request', async () => {
- const $http = jest.fn() as any;
- const basePath = 'test';
+ let httpMock: ReturnType;
- await getRelationships('dashboard', '1', ['search', 'index-pattern'], $http, basePath);
- expect($http.mock.calls.length).toBe(1);
+ beforeEach(() => {
+ httpMock = httpServiceMock.createSetupContract();
+ });
+
+ it('should make an http request', async () => {
+ await getRelationships(httpMock, 'dashboard', '1', ['search', 'index-pattern']);
+ expect(httpMock.get).toHaveBeenCalledTimes(1);
});
it('should handle successful responses', async () => {
- const $http = jest.fn().mockImplementation(() => ({ data: [1, 2] })) as any;
- const basePath = 'test';
-
- const response = await getRelationships(
- 'dashboard',
- '1',
- ['search', 'index-pattern'],
- $http,
- basePath
- );
+ httpMock.get.mockResolvedValue([1, 2]);
+
+ const response = await getRelationships(httpMock, 'dashboard', '1', [
+ 'search',
+ 'index-pattern',
+ ]);
expect(response).toEqual([1, 2]);
});
it('should handle errors', async () => {
- const $http = jest.fn().mockImplementation(() => {
+ httpMock.get.mockImplementation(() => {
const err = new Error();
(err as any).data = {
error: 'Test error',
statusCode: 500,
};
throw err;
- }) as any;
- const basePath = 'test';
+ });
await expect(
- getRelationships('dashboard', '1', ['search', 'index-pattern'], $http, basePath)
+ getRelationships(httpMock, 'dashboard', '1', ['search', 'index-pattern'])
).rejects.toThrowErrorMatchingInlineSnapshot(`"Test error"`);
});
});
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_relationships.ts b/src/plugins/saved_objects_management/public/lib/get_relationships.ts
similarity index 67%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_relationships.ts
rename to src/plugins/saved_objects_management/public/lib/get_relationships.ts
index 07bdf2db68fa2..bf2e651aa6593 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_relationships.ts
+++ b/src/plugins/saved_objects_management/public/lib/get_relationships.ts
@@ -17,36 +17,30 @@
* under the License.
*/
-import { IHttpService } from 'angular';
+import { HttpStart } from 'src/core/public';
import { get } from 'lodash';
import { SavedObjectRelation } from '../types';
export async function getRelationships(
+ http: HttpStart,
type: string,
id: string,
- savedObjectTypes: string[],
- $http: IHttpService,
- basePath: string
+ savedObjectTypes: string[]
): Promise {
- const url = `${basePath}/api/kibana/management/saved_objects/relationships/${encodeURIComponent(
+ const url = `/api/kibana/management/saved_objects/relationships/${encodeURIComponent(
type
)}/${encodeURIComponent(id)}`;
- const options = {
- method: 'GET',
- url,
- params: {
- savedObjectTypes,
- },
- };
-
try {
- const response = await $http(options);
- return response?.data;
- } catch (resp) {
- const respBody = get(resp, 'data', {}) as any;
- const err = new Error(respBody.message || respBody.error || `${resp.status} Response`);
+ return await http.get(url, {
+ query: {
+ savedObjectTypes,
+ },
+ });
+ } catch (respError) {
+ const respBody = get(respError, 'data', {}) as any;
+ const err = new Error(respBody.message || respBody.error || `${respError.status} Response`);
- (err as any).statusCode = respBody.statusCode || resp.status;
+ (err as any).statusCode = respBody.statusCode || respError.status;
(err as any).body = respBody;
throw err;
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_saved_object_counts.ts b/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts
similarity index 72%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_saved_object_counts.ts
rename to src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts
index d4dda1190bc43..dcf59142e73e3 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_saved_object_counts.ts
+++ b/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts
@@ -17,18 +17,15 @@
* under the License.
*/
-import { IHttpService } from 'angular';
-import chrome from 'ui/chrome';
+import { HttpStart } from 'src/core/public';
-const apiBase = chrome.addBasePath('/api/kibana/management/saved_objects/scroll');
export async function getSavedObjectCounts(
- $http: IHttpService,
+ http: HttpStart,
typesToInclude: string[],
- searchString: string
+ searchString?: string
): Promise> {
- const results = await $http.post>(`${apiBase}/counts`, {
- typesToInclude,
- searchString,
- });
- return results.data;
+ return await http.post>(
+ `/api/kibana/management/saved_objects/scroll/counts`,
+ { body: JSON.stringify({ typesToInclude, searchString }) }
+ );
}
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_saved_object_label.ts b/src/plugins/saved_objects_management/public/lib/get_saved_object_label.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/get_saved_object_label.ts
rename to src/plugins/saved_objects_management/public/lib/get_saved_object_label.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/import_file.ts b/src/plugins/saved_objects_management/public/lib/import_file.ts
similarity index 75%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/import_file.ts
rename to src/plugins/saved_objects_management/public/lib/import_file.ts
index 9bd5fbeed3a4c..96263452253ba 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/import_file.ts
+++ b/src/plugins/saved_objects_management/public/lib/import_file.ts
@@ -17,14 +17,18 @@
* under the License.
*/
-import { kfetch } from 'ui/kfetch';
+import { HttpStart, SavedObjectsImportError } from 'src/core/public';
-export async function importFile(file: Blob, overwriteAll: boolean = false) {
+interface ImportResponse {
+ success: boolean;
+ successCount: number;
+ errors?: SavedObjectsImportError[];
+}
+
+export async function importFile(http: HttpStart, file: File, overwriteAll: boolean = false) {
const formData = new FormData();
formData.append('file', file);
- return await kfetch({
- method: 'POST',
- pathname: '/api/saved_objects/_import',
+ return await http.post('/api/saved_objects/_import', {
body: formData,
headers: {
// Important to be undefined, it forces proper headers to be set for FormData
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/import_legacy_file.test.ts b/src/plugins/saved_objects_management/public/lib/import_legacy_file.test.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/import_legacy_file.test.ts
rename to src/plugins/saved_objects_management/public/lib/import_legacy_file.test.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/import_legacy_file.ts b/src/plugins/saved_objects_management/public/lib/import_legacy_file.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/import_legacy_file.ts
rename to src/plugins/saved_objects_management/public/lib/import_legacy_file.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/in_app_url.test.ts b/src/plugins/saved_objects_management/public/lib/in_app_url.test.ts
similarity index 98%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/in_app_url.test.ts
rename to src/plugins/saved_objects_management/public/lib/in_app_url.test.ts
index c0d6716391a1f..09e08e6ec333b 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/in_app_url.test.ts
+++ b/src/plugins/saved_objects_management/public/lib/in_app_url.test.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { Capabilities } from '../../../../../../../../core/public';
+import { Capabilities } from '../../../../core/public';
import { canViewInApp } from './in_app_url';
const createCapabilities = (sections: Record): Capabilities => {
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/in_app_url.ts b/src/plugins/saved_objects_management/public/lib/in_app_url.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/in_app_url.ts
rename to src/plugins/saved_objects_management/public/lib/in_app_url.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/index.ts b/src/plugins/saved_objects_management/public/lib/index.ts
similarity index 94%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/index.ts
rename to src/plugins/saved_objects_management/public/lib/index.ts
index ecdfa6549a54e..7021744095651 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/index.ts
+++ b/src/plugins/saved_objects_management/public/lib/index.ts
@@ -43,3 +43,5 @@ export {
export { getDefaultTitle } from './get_default_title';
export { findObjects } from './find_objects';
export { extractExportDetails, SavedObjectsExportResultDetails } from './extract_export_details';
+export { createFieldList } from './create_field_list';
+export { getAllowedTypes } from './get_allowed_types';
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/log_legacy_import.ts b/src/plugins/saved_objects_management/public/lib/log_legacy_import.ts
similarity index 81%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/log_legacy_import.ts
rename to src/plugins/saved_objects_management/public/lib/log_legacy_import.ts
index 9bbafe3e69c98..9ec3c85b91c22 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/log_legacy_import.ts
+++ b/src/plugins/saved_objects_management/public/lib/log_legacy_import.ts
@@ -17,11 +17,8 @@
* under the License.
*/
-import { kfetch } from 'ui/kfetch';
+import { HttpStart } from 'src/core/public';
-export async function logLegacyImport() {
- return await kfetch({
- method: 'POST',
- pathname: '/api/saved_objects/_log_legacy_import',
- });
+export async function logLegacyImport(http: HttpStart) {
+ return http.post('/api/saved_objects/_log_legacy_import');
}
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/numeric.ts b/src/plugins/saved_objects_management/public/lib/numeric.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/numeric.ts
rename to src/plugins/saved_objects_management/public/lib/numeric.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/parse_query.test.ts b/src/plugins/saved_objects_management/public/lib/parse_query.test.ts
similarity index 92%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/parse_query.test.ts
rename to src/plugins/saved_objects_management/public/lib/parse_query.test.ts
index 77b34eccd9c6f..f62234eaf4e94 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/parse_query.test.ts
+++ b/src/plugins/saved_objects_management/public/lib/parse_query.test.ts
@@ -25,6 +25,6 @@ describe('getQueryText', () => {
getTermClauses: () => [{ value: 'foo' }, { value: 'bar' }],
getFieldClauses: () => [{ value: 'lala' }, { value: 'lolo' }],
};
- expect(parseQuery({ ast })).toEqual({ queryText: 'foo bar', visibleTypes: 'lala' });
+ expect(parseQuery({ ast } as any)).toEqual({ queryText: 'foo bar', visibleTypes: 'lala' });
});
});
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/parse_query.ts b/src/plugins/saved_objects_management/public/lib/parse_query.ts
similarity index 77%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/parse_query.ts
rename to src/plugins/saved_objects_management/public/lib/parse_query.ts
index 9b33deedafd95..f5b7b69ea049c 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/parse_query.ts
+++ b/src/plugins/saved_objects_management/public/lib/parse_query.ts
@@ -17,9 +17,16 @@
* under the License.
*/
-export function parseQuery(query: any) {
- let queryText;
- let visibleTypes;
+import { Query } from '@elastic/eui';
+
+interface ParsedQuery {
+ queryText?: string;
+ visibleTypes?: string[];
+}
+
+export function parseQuery(query: Query): ParsedQuery {
+ let queryText: string | undefined;
+ let visibleTypes: string[] | undefined;
if (query) {
if (query.ast.getTermClauses().length) {
@@ -29,7 +36,7 @@ export function parseQuery(query: any) {
.join(' ');
}
if (query.ast.getFieldClauses('type')) {
- visibleTypes = query.ast.getFieldClauses('type')[0].value;
+ visibleTypes = query.ast.getFieldClauses('type')[0].value as string[];
}
}
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/process_import_response.test.ts b/src/plugins/saved_objects_management/public/lib/process_import_response.test.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/process_import_response.test.ts
rename to src/plugins/saved_objects_management/public/lib/process_import_response.test.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/process_import_response.ts b/src/plugins/saved_objects_management/public/lib/process_import_response.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/process_import_response.ts
rename to src/plugins/saved_objects_management/public/lib/process_import_response.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_import_errors.test.ts b/src/plugins/saved_objects_management/public/lib/resolve_import_errors.test.ts
similarity index 90%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_import_errors.test.ts
rename to src/plugins/saved_objects_management/public/lib/resolve_import_errors.test.ts
index b94b0a9d1291f..86eebad7ae787 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_import_errors.test.ts
+++ b/src/plugins/saved_objects_management/public/lib/resolve_import_errors.test.ts
@@ -17,14 +17,10 @@
* under the License.
*/
-jest.mock('ui/kfetch', () => ({ kfetch: jest.fn() }));
-
import { SavedObjectsImportUnknownError } from 'src/core/public';
-import { kfetch } from 'ui/kfetch';
+import { httpServiceMock } from '../../../../core/public/mocks';
import { resolveImportErrors } from './resolve_import_errors';
-const kfetchMock = kfetch as jest.Mock;
-
function getFormData(form: Map) {
const formData: Record = {};
for (const [key, val] of form.entries()) {
@@ -39,13 +35,20 @@ function getFormData(form: Map) {
describe('resolveImportErrors', () => {
const getConflictResolutions = jest.fn();
+ let httpMock: ReturnType;
beforeEach(() => {
+ httpMock = httpServiceMock.createSetupContract();
jest.resetAllMocks();
});
+ const extractBodyFromCall = (index: number): Map => {
+ return (httpMock.post.mock.calls[index] as any)[1].body;
+ };
+
test('works with empty import failures', async () => {
const result = await resolveImportErrors({
+ http: httpMock,
getConflictResolutions,
state: {
importCount: 0,
@@ -62,6 +65,7 @@ Object {
test(`doesn't retry if only unknown failures are passed in`, async () => {
const result = await resolveImportErrors({
+ http: httpMock,
getConflictResolutions,
state: {
importCount: 0,
@@ -98,7 +102,7 @@ Object {
});
test('resolves conflicts', async () => {
- kfetchMock.mockResolvedValueOnce({
+ httpMock.post.mockResolvedValueOnce({
success: true,
successCount: 1,
});
@@ -107,6 +111,7 @@ Object {
'a:2': false,
});
const result = await resolveImportErrors({
+ http: httpMock,
getConflictResolutions,
state: {
importCount: 0,
@@ -139,7 +144,8 @@ Object {
"status": "success",
}
`);
- const formData = getFormData(kfetchMock.mock.calls[0][0].body);
+
+ const formData = getFormData(extractBodyFromCall(0));
expect(formData).toMatchInlineSnapshot(`
Object {
"file": "undefined",
@@ -156,12 +162,13 @@ Object {
});
test('resolves missing references', async () => {
- kfetchMock.mockResolvedValueOnce({
+ httpMock.post.mockResolvedValueOnce({
success: true,
successCount: 2,
});
getConflictResolutions.mockResolvedValueOnce({});
const result = await resolveImportErrors({
+ http: httpMock,
getConflictResolutions,
state: {
importCount: 0,
@@ -203,7 +210,7 @@ Object {
"status": "success",
}
`);
- const formData = getFormData(kfetchMock.mock.calls[0][0].body);
+ const formData = getFormData(extractBodyFromCall(0));
expect(formData).toMatchInlineSnapshot(`
Object {
"file": "undefined",
@@ -232,6 +239,7 @@ Object {
test(`doesn't resolve missing references if newIndexPatternId isn't defined`, async () => {
getConflictResolutions.mockResolvedValueOnce({});
const result = await resolveImportErrors({
+ http: httpMock,
getConflictResolutions,
state: {
importCount: 0,
@@ -276,7 +284,7 @@ Object {
});
test('handles missing references then conflicts on the same errored objects', async () => {
- kfetchMock.mockResolvedValueOnce({
+ httpMock.post.mockResolvedValueOnce({
success: false,
successCount: 0,
errors: [
@@ -289,7 +297,7 @@ Object {
},
],
});
- kfetchMock.mockResolvedValueOnce({
+ httpMock.post.mockResolvedValueOnce({
success: true,
successCount: 1,
});
@@ -298,6 +306,7 @@ Object {
'a:1': true,
});
const result = await resolveImportErrors({
+ http: httpMock,
getConflictResolutions,
state: {
importCount: 0,
@@ -334,7 +343,7 @@ Object {
"status": "success",
}
`);
- const formData1 = getFormData(kfetchMock.mock.calls[0][0].body);
+ const formData1 = getFormData(extractBodyFromCall(0));
expect(formData1).toMatchInlineSnapshot(`
Object {
"file": "undefined",
@@ -354,7 +363,7 @@ Object {
],
}
`);
- const formData2 = getFormData(kfetchMock.mock.calls[1][0].body);
+ const formData2 = getFormData(extractBodyFromCall(1));
expect(formData2).toMatchInlineSnapshot(`
Object {
"file": "undefined",
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_import_errors.ts b/src/plugins/saved_objects_management/public/lib/resolve_import_errors.ts
similarity index 95%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_import_errors.ts
rename to src/plugins/saved_objects_management/public/lib/resolve_import_errors.ts
index dcc282402147d..0aea7114bad1c 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_import_errors.ts
+++ b/src/plugins/saved_objects_management/public/lib/resolve_import_errors.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { kfetch } from 'ui/kfetch';
+import { HttpStart } from 'src/core/public';
import { FailedImport } from './process_import_response';
interface RetryObject {
@@ -27,13 +27,11 @@ interface RetryObject {
replaceReferences?: any[];
}
-async function callResolveImportErrorsApi(file: File, retries: any) {
+async function callResolveImportErrorsApi(http: HttpStart, file: File, retries: any) {
const formData = new FormData();
formData.append('file', file);
formData.append('retries', JSON.stringify(retries));
- return await kfetch({
- method: 'POST',
- pathname: '/api/saved_objects/_resolve_import_errors',
+ return http.post('/api/saved_objects/_resolve_import_errors', {
headers: {
// Important to be undefined, it forces proper headers to be set for FormData
'Content-Type': undefined,
@@ -100,9 +98,11 @@ function mapImportFailureToRetryObject({
}
export async function resolveImportErrors({
+ http,
getConflictResolutions,
state,
}: {
+ http: HttpStart;
getConflictResolutions: (objects: any[]) => Promise>;
state: { importCount: number; failedImports?: FailedImport[] } & Record;
}) {
@@ -170,7 +170,7 @@ export async function resolveImportErrors({
}
// Call API
- const response = await callResolveImportErrorsApi(file, retries);
+ const response = await callResolveImportErrorsApi(http, file, retries);
successImportCount += response.successCount;
importFailures = [];
for (const { error, ...obj } of response.errors || []) {
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_saved_objects.test.ts b/src/plugins/saved_objects_management/public/lib/resolve_saved_objects.test.ts
similarity index 98%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_saved_objects.test.ts
rename to src/plugins/saved_objects_management/public/lib/resolve_saved_objects.test.ts
index dc6d2643145ff..23c2b75169555 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_saved_objects.test.ts
+++ b/src/plugins/saved_objects_management/public/lib/resolve_saved_objects.test.ts
@@ -23,11 +23,8 @@ import {
saveObjects,
saveObject,
} from './resolve_saved_objects';
-import {
- SavedObject,
- SavedObjectLoader,
-} from '../../../../../../../../plugins/saved_objects/public';
-import { IndexPatternsContract } from '../../../../../../../../plugins/data/public';
+import { SavedObject, SavedObjectLoader } from '../../../saved_objects/public';
+import { IndexPatternsContract } from '../../../data/public';
class SavedObjectNotFound extends Error {
constructor(options: Record) {
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_saved_objects.ts b/src/plugins/saved_objects_management/public/lib/resolve_saved_objects.ts
similarity index 94%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_saved_objects.ts
rename to src/plugins/saved_objects_management/public/lib/resolve_saved_objects.ts
index d9473367f7502..15e03ed39d88c 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/lib/resolve_saved_objects.ts
+++ b/src/plugins/saved_objects_management/public/lib/resolve_saved_objects.ts
@@ -20,15 +20,8 @@
import { i18n } from '@kbn/i18n';
import { cloneDeep } from 'lodash';
import { OverlayStart, SavedObjectReference } from 'src/core/public';
-import {
- SavedObject,
- SavedObjectLoader,
-} from '../../../../../../../../plugins/saved_objects/public';
-import {
- IndexPatternsContract,
- IIndexPattern,
- createSearchSource,
-} from '../../../../../../../../plugins/data/public';
+import { SavedObject, SavedObjectLoader } from '../../../saved_objects/public';
+import { IndexPatternsContract, IIndexPattern, createSearchSource } from '../../../data/public';
type SavedObjectsRawDoc = Record;
@@ -55,7 +48,7 @@ function addJsonFieldToIndexPattern(
target[fieldName] = JSON.parse(sourceString);
} catch (error) {
throw new Error(
- i18n.translate('kbn.management.objects.parsingFieldErrorMessage', {
+ i18n.translate('savedObjectsManagement.parsingFieldErrorMessage', {
defaultMessage:
'Error encountered parsing {fieldName} for index pattern {indexName}: {errorMessage}',
values: {
@@ -103,18 +96,21 @@ async function importIndexPattern(
if (!newId) {
// We can override and we want to prompt for confirmation
const isConfirmed = await openConfirm(
- i18n.translate('kbn.management.indexPattern.confirmOverwriteLabel', {
+ i18n.translate('savedObjectsManagement.indexPattern.confirmOverwriteLabel', {
values: { title },
defaultMessage: "Are you sure you want to overwrite '{title}'?",
}),
{
- title: i18n.translate('kbn.management.indexPattern.confirmOverwriteTitle', {
+ title: i18n.translate('savedObjectsManagement.indexPattern.confirmOverwriteTitle', {
defaultMessage: 'Overwrite {type}?',
values: { type },
}),
- confirmButtonText: i18n.translate('kbn.management.indexPattern.confirmOverwriteButton', {
- defaultMessage: 'Overwrite',
- }),
+ confirmButtonText: i18n.translate(
+ 'savedObjectsManagement.indexPattern.confirmOverwriteButton',
+ {
+ defaultMessage: 'Overwrite',
+ }
+ ),
}
);
diff --git a/src/legacy/core_plugins/vis_type_vega/public/shim/index.ts b/src/plugins/saved_objects_management/public/management_section/index.ts
similarity index 93%
rename from src/legacy/core_plugins/vis_type_vega/public/shim/index.ts
rename to src/plugins/saved_objects_management/public/management_section/index.ts
index cfc7b62ff4f86..1bccb2102f3b4 100644
--- a/src/legacy/core_plugins/vis_type_vega/public/shim/index.ts
+++ b/src/plugins/saved_objects_management/public/management_section/index.ts
@@ -17,4 +17,4 @@
* under the License.
*/
-export * from './legacy_dependencies_plugin';
+export { mountManagementSection } from './mount_section';
diff --git a/src/plugins/saved_objects_management/public/management_section/mount_section.tsx b/src/plugins/saved_objects_management/public/management_section/mount_section.tsx
new file mode 100644
index 0000000000000..6f03f97079bb6
--- /dev/null
+++ b/src/plugins/saved_objects_management/public/management_section/mount_section.tsx
@@ -0,0 +1,211 @@
+/*
+ * 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 React, { useEffect } from 'react';
+import ReactDOM from 'react-dom';
+import { HashRouter, Switch, Route, useParams, useLocation } from 'react-router-dom';
+import { parse } from 'query-string';
+import { get } from 'lodash';
+import { i18n } from '@kbn/i18n';
+import { I18nProvider } from '@kbn/i18n/react';
+import { CoreSetup, CoreStart, ChromeBreadcrumb, Capabilities } from 'src/core/public';
+import { ManagementAppMountParams } from '../../../management/public';
+import { DataPublicPluginStart } from '../../../data/public';
+import { StartDependencies, SavedObjectsManagementPluginStart } from '../plugin';
+import {
+ ISavedObjectsManagementServiceRegistry,
+ SavedObjectsManagementActionServiceStart,
+} from '../services';
+import { SavedObjectsTable } from './objects_table';
+import { SavedObjectEdition } from './object_view';
+import { getAllowedTypes } from './../lib';
+
+interface MountParams {
+ core: CoreSetup;
+ serviceRegistry: ISavedObjectsManagementServiceRegistry;
+ mountParams: ManagementAppMountParams;
+}
+
+let allowedObjectTypes: string[] | undefined;
+
+export const mountManagementSection = async ({
+ core,
+ mountParams,
+ serviceRegistry,
+}: MountParams) => {
+ const [coreStart, { data }, pluginStart] = await core.getStartServices();
+ const { element, basePath, setBreadcrumbs } = mountParams;
+ if (allowedObjectTypes === undefined) {
+ allowedObjectTypes = await getAllowedTypes(coreStart.http);
+ }
+
+ const capabilities = coreStart.application.capabilities;
+
+ ReactDOM.render(
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ,
+ element
+ );
+
+ return () => {
+ ReactDOM.unmountComponentAtNode(element);
+ };
+};
+
+const RedirectToHomeIfUnauthorized: React.FunctionComponent<{
+ capabilities: Capabilities;
+}> = ({ children, capabilities }) => {
+ const allowed = capabilities?.management?.kibana?.objects ?? false;
+ if (!allowed) {
+ window.location.hash = '/home';
+ return null;
+ }
+ return children! as React.ReactElement;
+};
+
+const SavedObjectsEditionPage = ({
+ coreStart,
+ serviceRegistry,
+ setBreadcrumbs,
+}: {
+ coreStart: CoreStart;
+ serviceRegistry: ISavedObjectsManagementServiceRegistry;
+ setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
+}) => {
+ const { service: serviceName, id } = useParams<{ service: string; id: string }>();
+ const capabilities = coreStart.application.capabilities;
+
+ const { search } = useLocation();
+ const query = parse(search);
+ const service = serviceRegistry.get(serviceName);
+
+ useEffect(() => {
+ setBreadcrumbs([
+ {
+ text: i18n.translate('savedObjectsManagement.breadcrumb.index', {
+ defaultMessage: 'Saved objects',
+ }),
+ href: '#/management/kibana/objects',
+ },
+ {
+ text: i18n.translate('savedObjectsManagement.breadcrumb.edit', {
+ defaultMessage: 'Edit {savedObjectType}',
+ values: { savedObjectType: service?.service.type ?? 'object' },
+ }),
+ },
+ ]);
+ }, [setBreadcrumbs, service]);
+
+ return (
+
+ );
+};
+
+const SavedObjectsTablePage = ({
+ coreStart,
+ dataStart,
+ allowedTypes,
+ serviceRegistry,
+ actionRegistry,
+ setBreadcrumbs,
+}: {
+ coreStart: CoreStart;
+ dataStart: DataPublicPluginStart;
+ allowedTypes: string[];
+ serviceRegistry: ISavedObjectsManagementServiceRegistry;
+ actionRegistry: SavedObjectsManagementActionServiceStart;
+ setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
+}) => {
+ const capabilities = coreStart.application.capabilities;
+ const itemsPerPage = coreStart.uiSettings.get('savedObjects:perPage', 50);
+
+ useEffect(() => {
+ setBreadcrumbs([
+ {
+ text: i18n.translate('savedObjectsManagement.breadcrumb.index', {
+ defaultMessage: 'Saved objects',
+ }),
+ href: '#/management/kibana/objects',
+ },
+ ]);
+ }, [setBreadcrumbs]);
+
+ return (
+ {
+ const { editUrl } = savedObject.meta;
+ if (editUrl) {
+ // previously, kbnUrl.change(object.meta.editUrl); was used.
+ // using direct access to location.hash seems the only option for now,
+ // as using react-router-dom will prefix the url with the router's basename
+ // which should be ignored there.
+ window.location.hash = editUrl;
+ }
+ }}
+ canGoInApp={savedObject => {
+ const { inAppUrl } = savedObject.meta;
+ return inAppUrl ? get(capabilities, inAppUrl.uiCapabilitiesPath) : false;
+ }}
+ />
+ );
+};
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/__snapshots__/header.test.tsx.snap b/src/plugins/saved_objects_management/public/management_section/object_view/components/__snapshots__/header.test.tsx.snap
similarity index 96%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/__snapshots__/header.test.tsx.snap
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/__snapshots__/header.test.tsx.snap
index 7e1f7ea12b014..d56776c2be9d7 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/__snapshots__/header.test.tsx.snap
+++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/__snapshots__/header.test.tsx.snap
@@ -23,7 +23,7 @@ exports[`Intro component renders correctly 1`] = `
>
}
@@ -37,7 +37,7 @@ exports[`Intro component renders correctly 1`] = `
>
Proceed with caution!
@@ -53,7 +53,7 @@ exports[`Intro component renders correctly 1`] = `
Modifying objects is for advanced users only. Object properties are not validated and invalid objects could cause errors, data loss, or worse. Unless someone with intimate knowledge of the code told you to be in here, you probably shouldn’t be.
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/__snapshots__/not_found_errors.test.tsx.snap b/src/plugins/saved_objects_management/public/management_section/object_view/components/__snapshots__/not_found_errors.test.tsx.snap
similarity index 89%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/__snapshots__/not_found_errors.test.tsx.snap
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/__snapshots__/not_found_errors.test.tsx.snap
index ac565a000813e..d5372fd5b18d9 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/__snapshots__/not_found_errors.test.tsx.snap
+++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/__snapshots__/not_found_errors.test.tsx.snap
@@ -10,7 +10,7 @@ exports[`NotFoundErrors component renders correctly for index-pattern type 1`] =
title={
}
@@ -39,7 +39,7 @@ exports[`NotFoundErrors component renders correctly for index-pattern type 1`] =
>
There is a problem with this saved object
@@ -55,7 +55,7 @@ exports[`NotFoundErrors component renders correctly for index-pattern type 1`] =
The index pattern associated with this object no longer exists.
@@ -64,7 +64,7 @@ exports[`NotFoundErrors component renders correctly for index-pattern type 1`] =
If you know what this error means, go ahead and fix it — otherwise click the delete button above.
@@ -87,7 +87,7 @@ exports[`NotFoundErrors component renders correctly for index-pattern-field type
title={
}
@@ -116,7 +116,7 @@ exports[`NotFoundErrors component renders correctly for index-pattern-field type
>
There is a problem with this saved object
@@ -132,7 +132,7 @@ exports[`NotFoundErrors component renders correctly for index-pattern-field type
A field associated with this object no longer exists in the index pattern.
@@ -141,7 +141,7 @@ exports[`NotFoundErrors component renders correctly for index-pattern-field type
If you know what this error means, go ahead and fix it — otherwise click the delete button above.
@@ -164,7 +164,7 @@ exports[`NotFoundErrors component renders correctly for search type 1`] = `
title={
}
@@ -193,7 +193,7 @@ exports[`NotFoundErrors component renders correctly for search type 1`] = `
>
There is a problem with this saved object
@@ -209,7 +209,7 @@ exports[`NotFoundErrors component renders correctly for search type 1`] = `
The saved search associated with this object no longer exists.
@@ -218,7 +218,7 @@ exports[`NotFoundErrors component renders correctly for search type 1`] = `
If you know what this error means, go ahead and fix it — otherwise click the delete button above.
@@ -241,7 +241,7 @@ exports[`NotFoundErrors component renders correctly for unknown type 1`] = `
title={
}
@@ -270,7 +270,7 @@ exports[`NotFoundErrors component renders correctly for unknown type 1`] = `
>
There is a problem with this saved object
@@ -287,7 +287,7 @@ exports[`NotFoundErrors component renders correctly for unknown type 1`] = `
If you know what this error means, go ahead and fix it — otherwise click the delete button above.
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/field.test.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/field.test.tsx
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/field.test.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/field.test.tsx
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/field.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/field.tsx
similarity index 97%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/field.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/field.tsx
index 1ed0b57e400b8..1b69eb4240d68 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/field.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/field.tsx
@@ -104,9 +104,9 @@ export class Field extends PureComponent {
id={this.fieldId}
label={
!!currentValue ? (
-
+
) : (
-
+
)
}
checked={!!currentValue}
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/form.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/form.tsx
similarity index 89%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/form.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/form.tsx
index 7270d41eef529..04be7ee3ce207 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/form.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/form.tsx
@@ -29,15 +29,11 @@ import {
import { cloneDeep, set } from 'lodash';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
-import {
- SimpleSavedObject,
- SavedObjectsClientContract,
-} from '../../../../../../../../../core/public';
-
-import { SavedObjectLoader } from '../../../../../../../../../plugins/saved_objects/public';
+import { SimpleSavedObject, SavedObjectsClientContract } from '../../../../../../core/public';
+import { SavedObjectLoader } from '../../../../../saved_objects/public';
import { Field } from './field';
import { ObjectField, FieldState, SubmittedFormData } from '../../types';
-import { createFieldList } from '../../lib/create_field_list';
+import { createFieldList } from '../../../lib';
interface FormProps {
object: SimpleSavedObject;
@@ -96,7 +92,7 @@ export class Form extends Component {
{
data-test-subj="savedObjectEditSave"
>
@@ -117,14 +113,14 @@ export class Form extends Component {
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/header.test.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/header.test.tsx
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/header.test.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/header.test.tsx
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/header.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/header.tsx
similarity index 92%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/header.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/header.tsx
index 641493e0cbaa8..305d953c4990b 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/header.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/header.tsx
@@ -52,7 +52,7 @@ export const Header = ({
{canEdit ? (
@@ -60,7 +60,7 @@ export const Header = ({
) : (
@@ -79,7 +79,7 @@ export const Header = ({
data-test-subj="savedObjectEditViewInApp"
>
@@ -96,7 +96,7 @@ export const Header = ({
data-test-subj="savedObjectEditDelete"
>
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/index.ts b/src/plugins/saved_objects_management/public/management_section/object_view/components/index.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/index.ts
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/index.ts
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/intro.test.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/intro.test.tsx
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/intro.test.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/intro.test.tsx
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/intro.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/intro.tsx
similarity index 92%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/intro.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/intro.tsx
index 098ad71345d49..920a5fcbcb02e 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/intro.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/intro.tsx
@@ -26,7 +26,7 @@ export const Intro = () => {
}
@@ -35,7 +35,7 @@ export const Intro = () => {
>
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/not_found_errors.test.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/not_found_errors.test.tsx
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/not_found_errors.test.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/not_found_errors.test.tsx
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/not_found_errors.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/not_found_errors.tsx
similarity index 87%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/not_found_errors.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/components/not_found_errors.tsx
index c3d18855f6c9a..1a63f7eaf4819 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/object_view/not_found_errors.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/not_found_errors.tsx
@@ -31,21 +31,21 @@ export const NotFoundErrors = ({ type }: NotFoundErrors) => {
case 'search':
return (
);
case 'index-pattern':
return (
);
case 'index-pattern-field':
return (
);
@@ -58,7 +58,7 @@ export const NotFoundErrors = ({ type }: NotFoundErrors) => {
}
@@ -68,7 +68,7 @@ export const NotFoundErrors = ({ type }: NotFoundErrors) => {
{getMessage()}
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/index.js b/src/plugins/saved_objects_management/public/management_section/object_view/index.ts
similarity index 93%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/index.js
rename to src/plugins/saved_objects_management/public/management_section/object_view/index.ts
index cdeebdbf7b63a..a823923536d31 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/index.js
+++ b/src/plugins/saved_objects_management/public/management_section/object_view/index.ts
@@ -17,4 +17,4 @@
* under the License.
*/
-export { Flyout } from './flyout';
+export { SavedObjectEdition } from './saved_object_view';
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/saved_object_view.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.tsx
similarity index 89%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/saved_object_view.tsx
rename to src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.tsx
index 4984fe3e6d6b8..f714970a5cac3 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/saved_object_view.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.tsx
@@ -26,16 +26,16 @@ import {
OverlayStart,
NotificationsStart,
SimpleSavedObject,
-} from '../../../../../../../core/public';
-import { ISavedObjectsManagementRegistry } from '../../saved_object_registry';
-import { Header, NotFoundErrors, Intro, Form } from './components/object_view';
-import { canViewInApp } from './lib/in_app_url';
-import { SubmittedFormData } from './types';
+} from '../../../../../core/public';
+import { ISavedObjectsManagementServiceRegistry } from '../../services';
+import { Header, NotFoundErrors, Intro, Form } from './components';
+import { canViewInApp } from '../../lib';
+import { SubmittedFormData } from '../types';
interface SavedObjectEditionProps {
id: string;
serviceName: string;
- serviceRegistry: ISavedObjectsManagementRegistry;
+ serviceRegistry: ISavedObjectsManagementServiceRegistry;
capabilities: Capabilities;
overlays: OverlayStart;
notifications: NotificationsStart;
@@ -135,17 +135,17 @@ export class SavedObjectEdition extends Component<
const { type, object } = this.state;
const confirmed = await overlays.openConfirm(
- i18n.translate('kbn.management.objects.confirmModalOptions.modalDescription', {
+ i18n.translate('savedObjectsManagement.deleteConfirm.modalDescription', {
defaultMessage: 'This action permanently removes the object from Kibana.',
}),
{
confirmButtonText: i18n.translate(
- 'kbn.management.objects.confirmModalOptions.deleteButtonLabel',
+ 'savedObjectsManagement.deleteConfirm.modalDeleteButtonLabel',
{
defaultMessage: 'Delete',
}
),
- title: i18n.translate('kbn.management.objects.confirmModalOptions.modalTitle', {
+ title: i18n.translate('savedObjectsManagement.deleteConfirm.modalTitle', {
defaultMessage: `Delete '{title}'?`,
values: {
title: object?.attributes?.title || 'saved Kibana object',
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap
similarity index 73%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap
rename to src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap
index 2c0a5d8f6b8f1..fe64df6ff51d1 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap
+++ b/src/plugins/saved_objects_management/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap
@@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`ObjectsTable delete should show a confirm modal 1`] = `
+exports[`SavedObjectsTable delete should show a confirm modal 1`] = `
}
confirmButtonText={
}
@@ -23,7 +23,7 @@ exports[`ObjectsTable delete should show a confirm modal 1`] = `
title={
}
@@ -31,7 +31,7 @@ exports[`ObjectsTable delete should show a confirm modal 1`] = `
@@ -58,12 +58,10 @@ exports[`ObjectsTable delete should show a confirm modal 1`] = `
Array [
Object {
"id": "1",
- "title": "Title 1",
"type": "index-pattern",
},
Object {
"id": "3",
- "title": "Title 2",
"type": "dashboard",
},
]
@@ -76,7 +74,7 @@ exports[`ObjectsTable delete should show a confirm modal 1`] = `
`;
-exports[`ObjectsTable export should allow the user to choose when exporting all 1`] = `
+exports[`SavedObjectsTable export should allow the user to choose when exporting all 1`] = `
@@ -84,7 +82,7 @@ exports[`ObjectsTable export should allow the user to choose when exporting all
}
@@ -149,7 +147,7 @@ exports[`ObjectsTable export should allow the user to choose when exporting all
label={
}
@@ -173,7 +171,7 @@ exports[`ObjectsTable export should allow the user to choose when exporting all
>
@@ -187,7 +185,7 @@ exports[`ObjectsTable export should allow the user to choose when exporting all
>
@@ -199,23 +197,87 @@ exports[`ObjectsTable export should allow the user to choose when exporting all
`;
-exports[`ObjectsTable import should show the flyout 1`] = `
+exports[`SavedObjectsTable import should show the flyout 1`] = `
`;
-exports[`ObjectsTable relationships should show the flyout 1`] = `
+exports[`SavedObjectsTable relationships should show the flyout 1`] = `
`;
-exports[`ObjectsTable should render normally 1`] = `
+exports[`SavedObjectsTable should render normally 1`] = `
@@ -251,7 +313,23 @@ exports[`ObjectsTable should render normally 1`] = `
size="xs"
/>
@@ -36,7 +36,7 @@ exports[`Flyout conflicts should allow conflict resolution 1`] = `
title={
}
@@ -44,7 +44,7 @@ exports[`Flyout conflicts should allow conflict resolution 1`] = `
,
@@ -131,7 +131,7 @@ exports[`Flyout conflicts should allow conflict resolution 1`] = `
>
@@ -148,7 +148,7 @@ exports[`Flyout conflicts should allow conflict resolution 1`] = `
>
@@ -164,6 +164,30 @@ exports[`Flyout conflicts should allow conflict resolution 2`] = `
Array [
Object {
"getConflictResolutions": [Function],
+ "http": Object {
+ "addLoadingCountSource": [MockFunction],
+ "anonymousPaths": Object {
+ "isAnonymous": [MockFunction],
+ "register": [MockFunction],
+ },
+ "basePath": BasePath {
+ "basePath": "",
+ "get": [Function],
+ "prepend": [Function],
+ "remove": [Function],
+ "serverBasePath": "",
+ },
+ "delete": [MockFunction],
+ "fetch": [MockFunction],
+ "get": [MockFunction],
+ "getLoadingCount$": [MockFunction],
+ "head": [MockFunction],
+ "intercept": [MockFunction],
+ "options": [MockFunction],
+ "patch": [MockFunction],
+ "post": [MockFunction],
+ "put": [MockFunction],
+ },
"state": Object {
"conflictedIndexPatterns": undefined,
"conflictedSavedObjectsLinkedToSavedSearches": undefined,
@@ -243,7 +267,7 @@ exports[`Flyout conflicts should handle errors 1`] = `
title={
}
@@ -251,7 +275,7 @@ exports[`Flyout conflicts should handle errors 1`] = `
}
@@ -280,7 +304,7 @@ exports[`Flyout errors should display unsupported type errors properly 1`] = `
@@ -331,7 +355,7 @@ exports[`Flyout legacy conflicts should allow conflict resolution 1`] = `
title={
}
@@ -339,7 +363,7 @@ exports[`Flyout legacy conflicts should allow conflict resolution 1`] = `
@@ -356,7 +380,7 @@ exports[`Flyout legacy conflicts should allow conflict resolution 1`] = `
title={
}
@@ -364,7 +388,7 @@ exports[`Flyout legacy conflicts should allow conflict resolution 1`] = `
,
@@ -462,7 +486,7 @@ exports[`Flyout legacy conflicts should allow conflict resolution 1`] = `
>
@@ -479,7 +503,7 @@ exports[`Flyout legacy conflicts should allow conflict resolution 1`] = `
>
@@ -498,7 +522,7 @@ Array [
title={
}
@@ -506,7 +530,7 @@ Array [
@@ -518,7 +542,7 @@ Array [
title={
}
@@ -526,7 +550,7 @@ Array [
,
@@ -548,7 +572,7 @@ Array [
title={
}
@@ -578,7 +602,7 @@ exports[`Flyout should render import step 1`] = `
@@ -595,7 +619,7 @@ exports[`Flyout should render import step 1`] = `
label={
}
@@ -607,7 +631,7 @@ exports[`Flyout should render import step 1`] = `
initialPromptText={
}
@@ -628,7 +652,7 @@ exports[`Flyout should render import step 1`] = `
label={
}
@@ -651,7 +675,7 @@ exports[`Flyout should render import step 1`] = `
>
@@ -668,7 +692,7 @@ exports[`Flyout should render import step 1`] = `
>
diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/header/__jest__/__snapshots__/header.test.js.snap b/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/header.test.tsx.snap
similarity index 88%
rename from src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/header/__jest__/__snapshots__/header.test.js.snap
rename to src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/header.test.tsx.snap
index 51bd51a5e2e58..642a5030e4ec0 100644
--- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/header/__jest__/__snapshots__/header.test.js.snap
+++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/__snapshots__/header.test.tsx.snap
@@ -13,7 +13,7 @@ exports[`Header should render normally 1`] = `
@@ -38,7 +38,7 @@ exports[`Header should render normally 1`] = `
>