Skip to content

Commit

Permalink
Add Timelion deprecation warning to the migration assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Aug 21, 2020
1 parent 7376e4c commit 03c64c6
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 27 deletions.
62 changes: 35 additions & 27 deletions src/plugins/timelion/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,50 @@
* 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<TimelionConfigType>) {}
private logger: Logger;

constructor(context: PluginInitializerContext<TimelionConfigType>) {
this.logger = context.logger.get();
}

public setup(core: CoreSetup) {
core.capabilities.registerProvider(() => ({
timelion: {
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': {
Expand Down Expand Up @@ -92,6 +98,8 @@ export class TimelionPlugin implements Plugin {
},
});
}
start() {}
start(core: CoreStart) {
showWarningMessageIfTimelionSteetWasFound(core, this.logger);
}
stop() {}
}
20 changes: 20 additions & 0 deletions src/plugins/timelion/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
@@ -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';
45 changes: 45 additions & 0 deletions src/plugins/timelion/server/saved_objects/timelion_sheet.ts
Original file line number Diff line number Diff line change
@@ -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' },
},
},
};

0 comments on commit 03c64c6

Please sign in to comment.