diff --git a/src/plugins/timelion/server/plugin.ts b/src/plugins/timelion/server/plugin.ts index 3e4cd5467dd44..f63ef6f53ad79 100644 --- a/src/plugins/timelion/server/plugin.ts +++ b/src/plugins/timelion/server/plugin.ts @@ -17,13 +17,42 @@ * under the License. */ -import { CoreSetup, Plugin, PluginInitializerContext } from 'src/core/server'; +import { CoreSetup, CoreStart, Plugin, PluginInitializerContext, Logger } from 'src/core/server'; import { i18n } from '@kbn/i18n'; import { schema } from '@kbn/config-schema'; import { TimelionConfigType } from './config'; +import { timelionSheetSavedObjectType } from './saved_objects'; + +/** + * Timelion plugin was deprecated since 7.0, the Timelion app will be removed in 8.0. + * To continue using your Timelion worksheets, migrate them to a dashboard. + * + * @link https://www.elastic.co/guide/en/kibana/master/timelion.html#timelion-deprecation + **/ +const showWarningMessageIfTimelionSteetWasFound = (core: CoreStart, logger: Logger) => { + const { savedObjects } = core; + const savedObjectsClient = savedObjects.createInternalRepository(); + + savedObjectsClient + .find({ + type: 'timelion-sheet', + perPage: 1, + }) + .then( + ({ total }) => + total && + logger.warn( + 'Timelion plugin was deprecated since 7.0, the Timelion app will be removed in 8.0.' + ) + ); +}; export class TimelionPlugin implements Plugin { - constructor(context: PluginInitializerContext) {} + private logger: Logger; + + constructor(context: PluginInitializerContext) { + this.logger = context.logger.get(); + } public setup(core: CoreSetup) { core.capabilities.registerProvider(() => ({ @@ -31,30 +60,7 @@ export class TimelionPlugin implements Plugin { save: true, }, })); - core.savedObjects.registerType({ - name: 'timelion-sheet', - hidden: false, - namespaceType: 'single', - mappings: { - properties: { - description: { type: 'text' }, - hits: { type: 'integer' }, - kibanaSavedObjectMeta: { - properties: { - searchSourceJSON: { type: 'text' }, - }, - }, - timelion_chart_height: { type: 'integer' }, - timelion_columns: { type: 'integer' }, - timelion_interval: { type: 'keyword' }, - timelion_other_interval: { type: 'keyword' }, - timelion_rows: { type: 'integer' }, - timelion_sheet: { type: 'text' }, - title: { type: 'text' }, - version: { type: 'integer' }, - }, - }, - }); + core.savedObjects.registerType(timelionSheetSavedObjectType); core.uiSettings.register({ 'timelion:showTutorial': { @@ -92,6 +98,8 @@ export class TimelionPlugin implements Plugin { }, }); } - start() {} + start(core: CoreStart) { + showWarningMessageIfTimelionSteetWasFound(core, this.logger); + } stop() {} } diff --git a/src/plugins/timelion/server/saved_objects/index.ts b/src/plugins/timelion/server/saved_objects/index.ts new file mode 100644 index 0000000000000..102dc25811019 --- /dev/null +++ b/src/plugins/timelion/server/saved_objects/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 { timelionSheetSavedObjectType } from './timelion_sheet'; diff --git a/src/plugins/timelion/server/saved_objects/timelion_sheet.ts b/src/plugins/timelion/server/saved_objects/timelion_sheet.ts new file mode 100644 index 0000000000000..6a46217c3e61b --- /dev/null +++ b/src/plugins/timelion/server/saved_objects/timelion_sheet.ts @@ -0,0 +1,45 @@ +/* + * 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 { SavedObjectsType } from 'kibana/server'; + +export const timelionSheetSavedObjectType: SavedObjectsType = { + name: 'timelion-sheet', + hidden: false, + namespaceType: 'single', + mappings: { + properties: { + description: { type: 'text' }, + hits: { type: 'integer' }, + kibanaSavedObjectMeta: { + properties: { + searchSourceJSON: { type: 'text' }, + }, + }, + timelion_chart_height: { type: 'integer' }, + timelion_columns: { type: 'integer' }, + timelion_interval: { type: 'keyword' }, + timelion_other_interval: { type: 'keyword' }, + timelion_rows: { type: 'integer' }, + timelion_sheet: { type: 'text' }, + title: { type: 'text' }, + version: { type: 'integer' }, + }, + }, +};