Skip to content

Commit

Permalink
Remove Newsfeed leftovers from the Legacy codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed May 11, 2020
1 parent e148eb4 commit 878dd21
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 234 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
# Pulse
/packages/kbn-analytics/ @elastic/pulse
/src/legacy/core_plugins/ui_metric/ @elastic/pulse
/src/plugins/newsfeed/ @elastic/pulse
/src/plugins/telemetry/ @elastic/pulse
/src/plugins/telemetry_collection_manager/ @elastic/pulse
/src/plugins/telemetry_management_section/ @elastic/pulse
Expand Down
71 changes: 0 additions & 71 deletions src/legacy/core_plugins/newsfeed/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/legacy/core_plugins/newsfeed/package.json

This file was deleted.

3 changes: 0 additions & 3 deletions src/legacy/core_plugins/newsfeed/public/index.scss

This file was deleted.

This file was deleted.

This file was deleted.

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

export const PLUGIN_ID = 'newsfeed';
export const DEFAULT_SERVICE_URLROOT = 'https://feeds.elastic.co';
export const DEV_SERVICE_URLROOT = 'https://feeds-staging.elastic.co';
export const DEFAULT_SERVICE_PATH = '/kibana/v{VERSION}.json';
export const NEWSFEED_FALLBACK_LANGUAGE = 'en';
export const NEWSFEED_LAST_FETCH_STORAGE_KEY = 'newsfeed.lastfetchtime';
export const NEWSFEED_HASH_SET_STORAGE_KEY = 'newsfeed.hashes';

export const NEWSFEED_DEFAULT_SERVICE_BASE_URL = 'https://feeds.elastic.co';
export const NEWSFEED_DEV_SERVICE_BASE_URL = 'https://feeds-staging.elastic.co';
export const NEWSFEED_DEFAULT_SERVICE_PATH = '/kibana/v{VERSION}.json';
2 changes: 1 addition & 1 deletion src/plugins/newsfeed/kibana.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "newsfeed",
"version": "kibana",
"server": false,
"server": true,
"ui": true
}
2 changes: 1 addition & 1 deletion src/plugins/newsfeed/public/components/flyout_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import {
EuiButtonEmpty,
EuiText,
EuiBadge,
EuiHeaderAlert,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiHeaderAlert } from '../../../../legacy/core_plugins/newsfeed/public/np_ready/components/header_alert/header_alert';
import { NewsfeedContext } from './newsfeed_header_nav_button';
import { NewsfeedItem } from '../../types';
import { NewsEmptyPrompt } from './empty_news';
Expand Down
39 changes: 20 additions & 19 deletions src/plugins/newsfeed/public/lib/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ import { interval, race } from 'rxjs';
import sinon, { stub } from 'sinon';
import moment from 'moment';
import { HttpSetup } from 'src/core/public';
import { NEWSFEED_HASH_SET_STORAGE_KEY, NEWSFEED_LAST_FETCH_STORAGE_KEY } from '../../constants';
import { ApiItem, NewsfeedItem, NewsfeedPluginInjectedConfig } from '../../types';
import {
NEWSFEED_HASH_SET_STORAGE_KEY,
NEWSFEED_LAST_FETCH_STORAGE_KEY,
} from '../../common/constants';
import { ApiItem, NewsfeedItem, NewsfeedPluginBrowserConfig } from '../../types';
import { NewsfeedApiDriver, getApi } from './api';

const localStorageGet = sinon.stub();
Expand Down Expand Up @@ -458,23 +461,21 @@ describe('getApi', () => {
}
return Promise.reject('wrong args!');
};
let configMock: NewsfeedPluginInjectedConfig;
let configMock: NewsfeedPluginBrowserConfig;

afterEach(() => {
jest.resetAllMocks();
});

beforeEach(() => {
configMock = {
newsfeed: {
service: {
urlRoot: 'http://fakenews.co',
pathTemplate: '/kibana-test/v{VERSION}.json',
},
defaultLanguage: 'en',
mainInterval: 86400000,
fetchInterval: 86400000,
service: {
urlRoot: 'http://fakenews.co',
pathTemplate: '/kibana-test/v{VERSION}.json',
},
defaultLanguage: 'en',
mainInterval: 86400000,
fetchInterval: 86400000,
};
httpMock = ({
fetch: mockHttpGet,
Expand All @@ -483,7 +484,7 @@ describe('getApi', () => {

it('creates a result', done => {
mockHttpGet.mockImplementationOnce(() => Promise.resolve({ items: [] }));
getApi(httpMock, configMock.newsfeed, '6.8.2').subscribe(result => {
getApi(httpMock, configMock, '6.8.2').subscribe(result => {
expect(result).toMatchInlineSnapshot(`
Object {
"error": null,
Expand Down Expand Up @@ -528,7 +529,7 @@ describe('getApi', () => {

mockHttpGet.mockImplementationOnce(getHttpMockWithItems(mockApiItems));

getApi(httpMock, configMock.newsfeed, '6.8.2').subscribe(result => {
getApi(httpMock, configMock, '6.8.2').subscribe(result => {
expect(result).toMatchInlineSnapshot(`
Object {
"error": null,
Expand Down Expand Up @@ -568,7 +569,7 @@ describe('getApi', () => {
},
];
mockHttpGet.mockImplementationOnce(getHttpMockWithItems(mockApiItems));
getApi(httpMock, configMock.newsfeed, '6.8.2').subscribe(result => {
getApi(httpMock, configMock, '6.8.2').subscribe(result => {
expect(result).toMatchInlineSnapshot(`
Object {
"error": null,
Expand All @@ -595,7 +596,7 @@ describe('getApi', () => {
it('forwards an error', done => {
mockHttpGet.mockImplementationOnce((arg1, arg2) => Promise.reject('sorry, try again later!'));

getApi(httpMock, configMock.newsfeed, '6.8.2').subscribe(result => {
getApi(httpMock, configMock, '6.8.2').subscribe(result => {
expect(result).toMatchInlineSnapshot(`
Object {
"error": "sorry, try again later!",
Expand Down Expand Up @@ -623,14 +624,14 @@ describe('getApi', () => {
];

it("retries until fetch doesn't error", done => {
configMock.newsfeed.mainInterval = 10; // fast retry for testing
configMock.mainInterval = 10; // fast retry for testing
mockHttpGet
.mockImplementationOnce(() => Promise.reject('Sorry, try again later!'))
.mockImplementationOnce(() => Promise.reject('Sorry, internal server error!'))
.mockImplementationOnce(() => Promise.reject("Sorry, it's too cold to go outside!"))
.mockImplementationOnce(getHttpMockWithItems(successItems));

getApi(httpMock, configMock.newsfeed, '6.8.2')
getApi(httpMock, configMock, '6.8.2')
.pipe(take(4), toArray())
.subscribe(result => {
expect(result).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -677,13 +678,13 @@ describe('getApi', () => {
});

it("doesn't retry if fetch succeeds", done => {
configMock.newsfeed.mainInterval = 10; // fast retry for testing
configMock.mainInterval = 10; // fast retry for testing
mockHttpGet.mockImplementation(getHttpMockWithItems(successItems));

const timeout$ = interval(1000); // lets us capture some results after a short time
let timesFetched = 0;

const get$ = getApi(httpMock, configMock.newsfeed, '6.8.2').pipe(
const get$ = getApi(httpMock, configMock, '6.8.2').pipe(
tap(() => {
timesFetched++;
})
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/newsfeed/public/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import {
NEWSFEED_FALLBACK_LANGUAGE,
NEWSFEED_LAST_FETCH_STORAGE_KEY,
NEWSFEED_HASH_SET_STORAGE_KEY,
} from '../../constants';
import { NewsfeedPluginInjectedConfig, ApiItem, NewsfeedItem, FetchResult } from '../../types';
} from '../../common/constants';
import { ApiItem, NewsfeedItem, FetchResult, NewsfeedPluginBrowserConfig } from '../../types';

type ApiConfig = NewsfeedPluginInjectedConfig['newsfeed']['service'];
type ApiConfig = NewsfeedPluginBrowserConfig['service'];

export class NewsfeedApiDriver {
private readonly loadedTime = moment().utc(); // the date is compared to time in UTC format coming from the service
Expand Down Expand Up @@ -167,7 +167,7 @@ export class NewsfeedApiDriver {
*/
export function getApi(
http: HttpSetup,
config: NewsfeedPluginInjectedConfig['newsfeed'],
config: NewsfeedPluginBrowserConfig,
kibanaVersion: string
): Rx.Observable<void | FetchResult> {
const userLanguage = i18n.getLocale() || config.defaultLanguage;
Expand Down
Loading

0 comments on commit 878dd21

Please sign in to comment.