mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [[Obs] fixing news feed by using dynamic kibana version (#150053)](https://github.com/elastic/kibana/pull/150053) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Cauê Marcondes","email":"55978943+cauemarcondes@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-02-02T17:12:36Z","message":"[Obs] fixing news feed by using dynamic kibana version (#150053)\n\ncloses https://github.com/elastic/kibana/issues/149986\r\n\r\n<img width=\"2551\" alt=\"Screenshot 2023-02-01 at 9 03 40 AM\"\r\nsrc=\"https://user-images.githubusercontent.com/55978943/216064385-30cc4604-39d1-40bf-a6b8-0632ca8e27fd.png\">\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"7b842280b8a6bbf540db27480a40ae899779aa79","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v8.7.0","v8.6.2"],"number":150053,"url":"https://github.com/elastic/kibana/pull/150053","mergeCommit":{"message":"[Obs] fixing news feed by using dynamic kibana version (#150053)\n\ncloses https://github.com/elastic/kibana/issues/149986\r\n\r\n<img width=\"2551\" alt=\"Screenshot 2023-02-01 at 9 03 40 AM\"\r\nsrc=\"https://user-images.githubusercontent.com/55978943/216064385-30cc4604-39d1-40bf-a6b8-0632ca8e27fd.png\">\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"7b842280b8a6bbf540db27480a40ae899779aa79"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/150053","number":150053,"mergeCommit":{"message":"[Obs] fixing news feed by using dynamic kibana version (#150053)\n\ncloses https://github.com/elastic/kibana/issues/149986\r\n\r\n<img width=\"2551\" alt=\"Screenshot 2023-02-01 at 9 03 40 AM\"\r\nsrc=\"https://user-images.githubusercontent.com/55978943/216064385-30cc4604-39d1-40bf-a6b8-0632ca8e27fd.png\">\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"7b842280b8a6bbf540db27480a40ae899779aa79"}},{"branch":"8.6","label":"v8.6.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
a751fd5f47
commit
bf585d188e
7 changed files with 40 additions and 6 deletions
|
@ -91,6 +91,7 @@ describe('renderApp', () => {
|
|||
},
|
||||
reportUiCounter: jest.fn(),
|
||||
},
|
||||
kibanaVersion: '8.7.0',
|
||||
});
|
||||
unmount();
|
||||
}).not.toThrowError();
|
||||
|
|
|
@ -53,6 +53,7 @@ export const renderApp = ({
|
|||
ObservabilityPageTemplate,
|
||||
usageCollection,
|
||||
isDev,
|
||||
kibanaVersion,
|
||||
}: {
|
||||
core: CoreStart;
|
||||
config: ConfigSchema;
|
||||
|
@ -62,6 +63,7 @@ export const renderApp = ({
|
|||
ObservabilityPageTemplate: React.ComponentType<LazyObservabilityPageTemplateProps>;
|
||||
usageCollection: UsageCollectionSetup;
|
||||
isDev?: boolean;
|
||||
kibanaVersion: string;
|
||||
}) => {
|
||||
const { element, history, theme$ } = appMountParameters;
|
||||
const i18nCore = core.i18n;
|
||||
|
@ -83,7 +85,13 @@ export const renderApp = ({
|
|||
<ApplicationUsageTrackingProvider>
|
||||
<KibanaThemeProvider theme$={theme$}>
|
||||
<KibanaContextProvider
|
||||
services={{ ...core, ...plugins, storage: new Storage(localStorage), isDev }}
|
||||
services={{
|
||||
...core,
|
||||
...plugins,
|
||||
storage: new Storage(localStorage),
|
||||
isDev,
|
||||
kibanaVersion,
|
||||
}}
|
||||
>
|
||||
<PluginContext.Provider
|
||||
value={{
|
||||
|
|
|
@ -46,4 +46,5 @@ export interface ObservabilityAppServices {
|
|||
uiSettings: IUiSettingsClient;
|
||||
unifiedSearch: UnifiedSearchPublicPluginStart;
|
||||
isDev?: boolean;
|
||||
kibanaVersion: string;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ export function OverviewPage() {
|
|||
http,
|
||||
application: { capabilities },
|
||||
triggersActionsUi: { alertsTableConfigurationRegistry, getAlertsStateTable: AlertsStateTable },
|
||||
kibanaVersion,
|
||||
} = useKibana<ObservabilityAppServices>().services;
|
||||
|
||||
const { ObservabilityPageTemplate } = usePluginContext();
|
||||
|
@ -84,7 +85,10 @@ export function OverviewPage() {
|
|||
})
|
||||
);
|
||||
|
||||
const { data: newsFeed } = useFetcher(() => getNewsFeed({ http }), [http]);
|
||||
const { data: newsFeed } = useFetcher(
|
||||
() => getNewsFeed({ http, kibanaVersion }),
|
||||
[http, kibanaVersion]
|
||||
);
|
||||
|
||||
const { hasAnyData, isAllRequestsComplete } = useHasData();
|
||||
const refetch = useRef<() => void>();
|
||||
|
|
|
@ -162,6 +162,7 @@ export class Plugin
|
|||
const category = DEFAULT_APP_CATEGORIES.observability;
|
||||
const euiIconType = 'logoObservability';
|
||||
const config = this.initContext.config.get();
|
||||
const kibanaVersion = this.initContext.env.packageInfo.version;
|
||||
|
||||
createCallObservabilityApi(coreSetup.http);
|
||||
|
||||
|
@ -185,6 +186,7 @@ export class Plugin
|
|||
ObservabilityPageTemplate: navigation.PageTemplate,
|
||||
usageCollection: pluginsSetup.usageCollection,
|
||||
isDev: this.initContext.env.mode.dev,
|
||||
kibanaVersion,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('getNewsFeed', () => {
|
|||
},
|
||||
} as unknown as HttpSetup;
|
||||
|
||||
const newsFeed = await getNewsFeed({ http });
|
||||
const newsFeed = await getNewsFeed({ http, kibanaVersion: '8.7.0' });
|
||||
expect(newsFeed.items).toEqual([]);
|
||||
});
|
||||
it('Returns array with the news feed', async () => {
|
||||
|
@ -92,7 +92,7 @@ describe('getNewsFeed', () => {
|
|||
},
|
||||
} as unknown as HttpSetup;
|
||||
|
||||
const newsFeed = await getNewsFeed({ http });
|
||||
const newsFeed = await getNewsFeed({ http, kibanaVersion: '8.7.0' });
|
||||
expect(newsFeed.items.length).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import type { HttpSetup } from '@kbn/core/public';
|
||||
import semverCoerce from 'semver/functions/coerce';
|
||||
|
||||
export interface NewsItem {
|
||||
title: { en: string };
|
||||
|
@ -17,10 +18,27 @@ export interface NewsItem {
|
|||
interface NewsFeed {
|
||||
items: NewsItem[];
|
||||
}
|
||||
/**
|
||||
* Removes the suffix that is sometimes appended to the Kibana version,
|
||||
* (e.g. `8.0.0-SNAPSHOT-rc1`), which is typically only seen in non-production
|
||||
* environments
|
||||
*/
|
||||
const removeSuffixFromVersion = (kibanaVersion?: string) =>
|
||||
semverCoerce(kibanaVersion)?.version ?? kibanaVersion;
|
||||
|
||||
export async function getNewsFeed({ http }: { http: HttpSetup }): Promise<NewsFeed> {
|
||||
export async function getNewsFeed({
|
||||
http,
|
||||
kibanaVersion,
|
||||
}: {
|
||||
http: HttpSetup;
|
||||
kibanaVersion: string;
|
||||
}): Promise<NewsFeed> {
|
||||
try {
|
||||
return await http.get('https://feeds.elastic.co/observability-solution/v8.0.0.json');
|
||||
return await http.get(
|
||||
`https://feeds.elastic.co/observability-solution/v${removeSuffixFromVersion(
|
||||
kibanaVersion
|
||||
)}.json`
|
||||
);
|
||||
} catch (e) {
|
||||
console.error('Error while fetching news feed', e);
|
||||
return { items: [] };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue