Skip to content

Commit

Permalink
Add Timelion deprecation warning to server log (#75541)
Browse files Browse the repository at this point in the history
* Add Timelion deprecation warning to the migration assistant

Closes: #63014

* fix PR comments

* update message

* fix integration tests

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
alexwizp and elasticmachine authored Aug 24, 2020
1 parent 4dd0205 commit 2620882
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Platform assets', function () {
let root: Root;

beforeAll(async function () {
root = kbnTestServer.createRoot();
root = kbnTestServer.createRoot({ plugins: { initialize: false } });

await root.setup();
await root.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('http resources service', () => {
csp: {
rules: [defaultCspRules],
},
plugins: { initialize: false },
});
}, 30000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ describe('legacy service', () => {
describe('http server', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeEach(() => {
root = kbnTestServer.createRoot({ migrations: { skip: true } });
root = kbnTestServer.createRoot({
migrations: { skip: true },
plugins: { initialize: false },
});
}, 30000);

afterEach(async () => await root.shutdown());
Expand Down
1 change: 1 addition & 0 deletions src/core/server/legacy/integration_tests/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { LegacyLoggingConfig } from '../config/legacy_object_to_config_adapter';
function createRoot(legacyLoggingConfig: LegacyLoggingConfig = {}) {
return kbnTestServer.createRoot({
migrations: { skip: true }, // otherwise stuck in polling ES
plugins: { initialize: false },
logging: {
// legacy platform config
silent: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('SavedObjects /_migrate endpoint', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;

beforeEach(async () => {
root = kbnTestServer.createRoot({ migrations: { skip: true } });
root = kbnTestServer.createRoot({ migrations: { skip: true }, plugins: { initialize: false } });
await root.setup();
await root.start();
migratorInstanceMock.runMigrations.mockClear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ui settings service', () => {
describe('routes', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
root = kbnTestServer.createRoot();
root = kbnTestServer.createRoot({ plugins: { initialize: false } });

const { uiSettings } = await root.setup();
uiSettings.register({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import * as kbnTestServer from '../../../../test_utils/kbn_server';

let root;
beforeAll(async () => {
root = kbnTestServer.createRoot({ server: { maxPayloadBytes: 100 }, migrations: { skip: true } });
root = kbnTestServer.createRoot({
server: { maxPayloadBytes: 100 },
migrations: { skip: true },
plugins: { initialize: false },
});

await root.setup();
await root.start();
Expand Down
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';

/**
* 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 showWarningMessageIfTimelionSheetWasFound = (core: CoreStart, logger: Logger) => {
const { savedObjects } = core;
const savedObjectsClient = savedObjects.createInternalRepository();

savedObjectsClient
.find({
type: 'timelion-sheet',
perPage: 1,
})
.then(
({ total }) =>
total &&
logger.warn(
'Deprecated since 7.0, the Timelion app will be removed in 8.0. To continue using your Timelion worksheets, migrate them to a dashboard. See https://www.elastic.co/guide/en/kibana/master/timelion.html#timelion-deprecation.'
)
);
};

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) {
showWarningMessageIfTimelionSheetWasFound(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 2620882

Please sign in to comment.