Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Newsfeed leftovers from the Legacy codebase #66084

Merged
merged 7 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/common/fixtures/plugins/newsfeed/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "newsfeed-fixtures",
"version": "kibana",
"server": true,
"ui": false
}
126 changes: 0 additions & 126 deletions test/common/fixtures/plugins/newsfeed/newsfeed_simulation.ts

This file was deleted.

7 changes: 0 additions & 7 deletions test/common/fixtures/plugins/newsfeed/package.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@
* under the License.
*/

import Hapi from 'hapi';
import { initPlugin as initNewsfeed } from './newsfeed_simulation';
import { NewsFeedSimulatorPlugin } from './plugin';

const NAME = 'newsfeed-FTS-external-service-simulators';

// eslint-disable-next-line import/no-default-export
export default function(kibana: any) {
return new kibana.Plugin({
name: NAME,
init: (server: Hapi.Server) => {
initNewsfeed(server, `/api/_${NAME}`);
},
});
export function plugin() {
return new NewsFeedSimulatorPlugin();
}
96 changes: 96 additions & 0 deletions test/common/fixtures/plugins/newsfeed/server/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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 { schema } from '@kbn/config-schema';
import { CoreSetup, Plugin } from 'kibana/server';

const PATH = '/api/_newsfeed-FTS-external-service-simulators';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PATH is used in this file only. let's inline the value


export class NewsFeedSimulatorPlugin implements Plugin {
public setup({ http }: CoreSetup) {
const router = http.createRouter();

router.get(
{
path: `${PATH}/kibana/v{version}.json`,
validate: { params: schema.object({ version: schema.string() }) },
options: { authRequired: false },
},
(context, req, res) => {
return res.ok({ body: this.mockNewsfeed(req.params.version) });
}
);

router.get(
{
path: `${PATH}/kibana/crash.json`,
validate: false,
options: { authRequired: false },
},
(context, req, res) => {
return res.internalError({ body: new Error('Internal server error') });
}
);
}

public start() {}

private mockNewsfeed(version: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is version used?

return {
items: [
{
title: { en: `You are functionally testing the newsfeed widget with fixtures!` },
description: { en: 'See test/common/fixtures/plugins/newsfeed/newsfeed_simulation' },
link_text: { en: 'Generic feed-viewer could go here' },
link_url: { en: 'https://feeds.elastic.co' },
languages: null,
badge: null,
image_url: null,
publish_on: '2019-06-21T00:00:00',
expire_on: '2040-01-31T00:00:00',
hash: '39ca7d409c7eb25f4c69a5a6a11309b2f5ced7ca3f9b3a0109517126e0fd91ca',
},
{
title: { en: 'Staging too!' },
description: { en: 'Hello world' },
link_text: { en: 'Generic feed-viewer could go here' },
link_url: { en: 'https://feeds-staging.elastic.co' },
languages: null,
badge: null,
image_url: null,
publish_on: '2019-06-21T00:00:00',
expire_on: '2040-01-31T00:00:00',
hash: 'db445c9443eb50ea2eb15f20edf89cf0f7dac2b058b11cafc2c8c288b6e4ce2a',
},
{
title: { en: 'This item is expired!' },
description: { en: 'This should not show up.' },
link_text: { en: 'Generic feed-viewer could go here' },
link_url: { en: 'https://feeds-staging.elastic.co' },
languages: null,
badge: null,
image_url: null,
publish_on: '2019-06-21T00:00:00',
expire_on: '2019-12-31T00:00:00',
hash: 'db445c9443eb50ea2eb15f20edf89cf0f7dac2b058b11cafc2c8c288b6e4ce2a',
},
],
};
}
}