Skip to content

Commit

Permalink
Merge branch '7.x' into ua/deep_linking_to_external_apps_with_last_ch…
Browse files Browse the repository at this point in the history
…eckpoint
  • Loading branch information
kibanamachine authored Sep 7, 2021
2 parents 5bbda84 + 403ac3d commit 273faa4
Show file tree
Hide file tree
Showing 369 changed files with 5,406 additions and 2,315 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [ChromeStart](./kibana-plugin-core-public.chromestart.md) &gt; [hasHeaderBanner$](./kibana-plugin-core-public.chromestart.hasheaderbanner_.md)

## ChromeStart.hasHeaderBanner$() method

Get an observable of the current header banner presence state.

<b>Signature:</b>

```typescript
hasHeaderBanner$(): Observable<boolean>;
```
<b>Returns:</b>

`Observable<boolean>`

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ core.chrome.setHelpExtension(elem => {
| [getHelpExtension$()](./kibana-plugin-core-public.chromestart.gethelpextension_.md) | Get an observable of the current custom help conttent |
| [getIsNavDrawerLocked$()](./kibana-plugin-core-public.chromestart.getisnavdrawerlocked_.md) | Get an observable of the current locked state of the nav drawer. |
| [getIsVisible$()](./kibana-plugin-core-public.chromestart.getisvisible_.md) | Get an observable of the current visibility state of the chrome. |
| [hasHeaderBanner$()](./kibana-plugin-core-public.chromestart.hasheaderbanner_.md) | Get an observable of the current header banner presence state. |
| [setBadge(badge)](./kibana-plugin-core-public.chromestart.setbadge.md) | Override the current badge |
| [setBreadcrumbs(newBreadcrumbs)](./kibana-plugin-core-public.chromestart.setbreadcrumbs.md) | Override the current set of breadcrumbs |
| [setBreadcrumbsAppendExtension(breadcrumbsAppendExtension)](./kibana-plugin-core-public.chromestart.setbreadcrumbsappendextension.md) | Mount an element next to the last breadcrumb |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ readonly links: {
readonly apm: {
readonly kibanaSettings: string;
readonly supportedServiceMaps: string;
readonly customLinks: string;
readonly droppedTransactionSpans: string;
readonly upgrading: string;
readonly metaData: string;
};
readonly canvas: {
readonly guide: string;
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
"react-moment-proptypes": "^1.7.0",
"react-monaco-editor": "^0.41.2",
"react-popper-tooltip": "^2.10.1",
"react-query": "^3.21.0",
"react-query": "^3.21.1",
"react-redux": "^7.2.0",
"react-resizable": "^1.7.5",
"react-resize-detector": "^4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pageLoadAssetSize:
indexPatternManagement: 28222
indexPatternEditor: 40000
infra: 184320
fleet: 465774
fleet: 250000
ingestPipelines: 58003
inputControlVis: 172675
inspector: 148711
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface UseExceptionListsProps {
http: HttpStart;
namespaceTypes: NamespaceType[];
notifications: NotificationsStart;
pagination?: Pagination;
initialPagination?: Pagination;
showTrustedApps: boolean;
showEventFilters: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { useEffect, useMemo, useRef, useState } from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import type {
ExceptionListSchema,
UseExceptionListsProps,
Expand All @@ -17,7 +17,19 @@ import { fetchExceptionLists } from '@kbn/securitysolution-list-api';
import { getFilters } from '@kbn/securitysolution-list-utils';

export type Func = () => void;
export type ReturnExceptionLists = [boolean, ExceptionListSchema[], Pagination, Func | null];
export type ReturnExceptionLists = [
loading: boolean,
exceptionLists: ExceptionListSchema[],
pagination: Pagination,
setPagination: React.Dispatch<React.SetStateAction<Pagination>>,
fetchLists: Func | null
];

const DEFAULT_PAGINATION = {
page: 1,
perPage: 20,
total: 0,
};

/**
* Hook for fetching ExceptionLists
Expand All @@ -29,27 +41,23 @@ export type ReturnExceptionLists = [boolean, ExceptionListSchema[], Pagination,
* @param notifications kibana service for displaying toasters
* @param showTrustedApps boolean - include/exclude trusted app lists
* @param showEventFilters boolean - include/exclude event filters lists
* @param pagination
* @param initialPagination
*
*/
export const useExceptionLists = ({
errorMessage,
http,
pagination = {
page: 1,
perPage: 20,
total: 0,
},
initialPagination = DEFAULT_PAGINATION,
filterOptions = {},
namespaceTypes,
notifications,
showTrustedApps = false,
showEventFilters = false,
}: UseExceptionListsProps): ReturnExceptionLists => {
const [exceptionLists, setExceptionLists] = useState<ExceptionListSchema[]>([]);
const [paginationInfo, setPagination] = useState<Pagination>(pagination);
const [pagination, setPagination] = useState<Pagination>(initialPagination);
const [loading, setLoading] = useState(true);
const fetchExceptionListsRef = useRef<Func | null>(null);
const abortCtrlRef = useRef<AbortController>();

const namespaceTypesAsString = useMemo(() => namespaceTypes.join(','), [namespaceTypes]);
const filters = useMemo(
Expand All @@ -58,66 +66,57 @@ export const useExceptionLists = ({
[namespaceTypes, filterOptions, showTrustedApps, showEventFilters]
);

useEffect(() => {
let isSubscribed = true;
const abortCtrl = new AbortController();
const fetchData = useCallback(async (): Promise<void> => {
try {
setLoading(true);

const fetchData = async (): Promise<void> => {
try {
setLoading(true);
abortCtrlRef.current = new AbortController();

const { page, per_page: perPage, total, data } = await fetchExceptionLists({
filters,
http,
namespaceTypes: namespaceTypesAsString,
pagination: {
page: pagination.page,
perPage: pagination.perPage,
},
signal: abortCtrl.signal,
});
const { page, per_page: perPage, total, data } = await fetchExceptionLists({
filters,
http,
namespaceTypes: namespaceTypesAsString,
pagination: {
page: pagination.page,
perPage: pagination.perPage,
},
signal: abortCtrlRef.current.signal,
});

if (isSubscribed) {
setPagination({
page,
perPage,
total,
});
setExceptionLists(data);
setLoading(false);
}
} catch (error) {
if (isSubscribed) {
notifications.toasts.addError(error, {
title: errorMessage,
});
setExceptionLists([]);
setPagination({
page: 1,
perPage: 20,
total: 0,
});
setLoading(false);
}
setPagination({
page,
perPage,
total,
});
setExceptionLists(data);
setLoading(false);
} catch (error) {
if (error.name !== 'AbortError') {
notifications.toasts.addError(error, {
title: errorMessage,
});
setExceptionLists([]);
setPagination(DEFAULT_PAGINATION);
setLoading(false);
}
};

fetchData();

fetchExceptionListsRef.current = fetchData;
return (): void => {
isSubscribed = false;
abortCtrl.abort();
};
}
}, [
errorMessage,
notifications,
pagination.page,
pagination.perPage,
filters,
namespaceTypesAsString,
http,
namespaceTypesAsString,
notifications.toasts,
pagination.page,
pagination.perPage,
]);

return [loading, exceptionLists, paginationInfo, fetchExceptionListsRef.current];
useEffect(() => {
fetchData();

return (): void => {
abortCtrlRef.current?.abort();
};
}, [fetchData]);

return [loading, exceptionLists, pagination, setPagination, fetchData];
};
2 changes: 2 additions & 0 deletions src/core/public/chrome/chrome_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const createStartContractMock = () => {
getCustomNavLink$: jest.fn(),
setCustomNavLink: jest.fn(),
setHeaderBanner: jest.fn(),
hasHeaderBanner$: jest.fn(),
getBodyClasses$: jest.fn(),
};
startContract.navLinks.getAll.mockReturnValue([]);
Expand All @@ -66,6 +67,7 @@ const createStartContractMock = () => {
startContract.getHelpExtension$.mockReturnValue(new BehaviorSubject(undefined));
startContract.getIsNavDrawerLocked$.mockReturnValue(new BehaviorSubject(false));
startContract.getBodyClasses$.mockReturnValue(new BehaviorSubject([]));
startContract.hasHeaderBanner$.mockReturnValue(new BehaviorSubject(false));
return startContract;
};

Expand Down
13 changes: 13 additions & 0 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,19 @@ describe('start', () => {
});
});

describe('header banner', () => {
it('updates/emits the state of the header banner', async () => {
const { chrome, service } = await start();
const promise = chrome.hasHeaderBanner$().pipe(toArray()).toPromise();

chrome.setHeaderBanner({ content: () => () => undefined });
chrome.setHeaderBanner(undefined);
service.stop();

await expect(promise).resolves.toEqual([false, true, false]);
});
});

describe('erase chrome fields', () => {
it('while switching an app', async () => {
const startDeps = defaultStartDeps([new FakeApp('alpha')]);
Expand Down
7 changes: 7 additions & 0 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ export class ChromeService {
headerBanner$.next(headerBanner);
},

hasHeaderBanner$: () => {
return headerBanner$.pipe(
takeUntil(this.stop$),
map((banner) => Boolean(banner))
);
},

getBodyClasses$: () => bodyClasses$.pipe(takeUntil(this.stop$)),
};
}
Expand Down
5 changes: 5 additions & 0 deletions src/core/public/chrome/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ export interface ChromeStart {
* @remarks Using `undefined` when invoking this API will remove the banner.
*/
setHeaderBanner(headerBanner?: ChromeUserBanner): void;

/**
* Get an observable of the current header banner presence state.
*/
hasHeaderBanner$(): Observable<boolean>;
}

/** @internal */
Expand Down
9 changes: 9 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class DocLinksService {
const KIBANA_DOCS = `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/`;
const FLEET_DOCS = `${ELASTIC_WEBSITE_URL}guide/en/fleet/${DOC_LINK_VERSION}/`;
const PLUGIN_DOCS = `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/plugins/${DOC_LINK_VERSION}/`;
const APM_DOCS = `${ELASTIC_WEBSITE_URL}guide/en/apm/`;

return deepFreeze({
DOC_LINK_VERSION,
Expand All @@ -33,6 +34,10 @@ export class DocLinksService {
apm: {
kibanaSettings: `${KIBANA_DOCS}apm-settings-in-kibana.html`,
supportedServiceMaps: `${KIBANA_DOCS}service-maps.html#service-maps-supported`,
customLinks: `${KIBANA_DOCS}custom-links.html`,
droppedTransactionSpans: `${APM_DOCS}get-started/${DOC_LINK_VERSION}/transaction-spans.html#dropped-spans`,
upgrading: `${APM_DOCS}server/${DOC_LINK_VERSION}/upgrading.html`,
metaData: `${APM_DOCS}get-started/${DOC_LINK_VERSION}/metadata.html`,
},
canvas: {
guide: `${KIBANA_DOCS}canvas.html`,
Expand Down Expand Up @@ -460,6 +465,10 @@ export interface DocLinksStart {
readonly apm: {
readonly kibanaSettings: string;
readonly supportedServiceMaps: string;
readonly customLinks: string;
readonly droppedTransactionSpans: string;
readonly upgrading: string;
readonly metaData: string;
};
readonly canvas: {
readonly guide: string;
Expand Down
5 changes: 5 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ export interface ChromeStart {
getHelpExtension$(): Observable<ChromeHelpExtension | undefined>;
getIsNavDrawerLocked$(): Observable<boolean>;
getIsVisible$(): Observable<boolean>;
hasHeaderBanner$(): Observable<boolean>;
navControls: ChromeNavControls;
navLinks: ChromeNavLinks;
recentlyAccessed: ChromeRecentlyAccessed;
Expand Down Expand Up @@ -477,6 +478,10 @@ export interface DocLinksStart {
readonly apm: {
readonly kibanaSettings: string;
readonly supportedServiceMaps: string;
readonly customLinks: string;
readonly droppedTransactionSpans: string;
readonly upgrading: string;
readonly metaData: string;
};
readonly canvas: {
readonly guide: string;
Expand Down
1 change: 1 addition & 0 deletions src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const storybookAliases = {
expression_repeat_image: 'src/plugins/expression_repeat_image/.storybook',
expression_reveal_image: 'src/plugins/expression_reveal_image/.storybook',
expression_shape: 'src/plugins/expression_shape/.storybook',
expression_tagcloud: 'src/plugins/chart_expressions/expression_tagcloud/.storybook',
infra: 'x-pack/plugins/infra/.storybook',
security_solution: 'x-pack/plugins/security_solution/.storybook',
ui_actions_enhanced: 'x-pack/plugins/ui_actions_enhanced/.storybook',
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/apm_oss/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { schema, TypeOf } from '@kbn/config-schema';
import { ConfigDeprecationProvider, PluginInitializerContext } from '../../../core/server';
import { APMOSSPlugin } from './plugin';

const deprecations: ConfigDeprecationProvider = ({ unused }) => [unused('fleetMode')];
const deprecations: ConfigDeprecationProvider = ({ unused }) => [
unused('fleetMode'),
unused('indexPattern'),
];

export const config = {
schema: schema.object({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { defaultConfig } from '@kbn/storybook';
import webpackMerge from 'webpack-merge';
import { resolve } from 'path';

const mockConfig = {
resolve: {
alias: {
'../format_service': resolve(__dirname, '../public/__mocks__/format_service.ts'),
},
},
};

module.exports = {
...defaultConfig,
webpackFinal: (config) => webpackMerge(config, mockConfig),
};
Loading

0 comments on commit 273faa4

Please sign in to comment.