Skip to content

Commit 273faa4

Browse files
Merge branch '7.x' into ua/deep_linking_to_external_apps_with_last_checkpoint
2 parents 5bbda84 + 403ac3d commit 273faa4

369 files changed

Lines changed: 5406 additions & 2315 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[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)
4+
5+
## ChromeStart.hasHeaderBanner$() method
6+
7+
Get an observable of the current header banner presence state.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
hasHeaderBanner$(): Observable<boolean>;
13+
```
14+
<b>Returns:</b>
15+
16+
`Observable<boolean>`
17+

docs/development/core/public/kibana-plugin-core-public.chromestart.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ core.chrome.setHelpExtension(elem => {
5757
| [getHelpExtension$()](./kibana-plugin-core-public.chromestart.gethelpextension_.md) | Get an observable of the current custom help conttent |
5858
| [getIsNavDrawerLocked$()](./kibana-plugin-core-public.chromestart.getisnavdrawerlocked_.md) | Get an observable of the current locked state of the nav drawer. |
5959
| [getIsVisible$()](./kibana-plugin-core-public.chromestart.getisvisible_.md) | Get an observable of the current visibility state of the chrome. |
60+
| [hasHeaderBanner$()](./kibana-plugin-core-public.chromestart.hasheaderbanner_.md) | Get an observable of the current header banner presence state. |
6061
| [setBadge(badge)](./kibana-plugin-core-public.chromestart.setbadge.md) | Override the current badge |
6162
| [setBreadcrumbs(newBreadcrumbs)](./kibana-plugin-core-public.chromestart.setbreadcrumbs.md) | Override the current set of breadcrumbs |
6263
| [setBreadcrumbsAppendExtension(breadcrumbsAppendExtension)](./kibana-plugin-core-public.chromestart.setbreadcrumbsappendextension.md) | Mount an element next to the last breadcrumb |

docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ readonly links: {
1212
readonly apm: {
1313
readonly kibanaSettings: string;
1414
readonly supportedServiceMaps: string;
15+
readonly customLinks: string;
16+
readonly droppedTransactionSpans: string;
17+
readonly upgrading: string;
18+
readonly metaData: string;
1519
};
1620
readonly canvas: {
1721
readonly guide: string;

docs/development/core/public/kibana-plugin-core-public.doclinksstart.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
"react-moment-proptypes": "^1.7.0",
350350
"react-monaco-editor": "^0.41.2",
351351
"react-popper-tooltip": "^2.10.1",
352-
"react-query": "^3.21.0",
352+
"react-query": "^3.21.1",
353353
"react-redux": "^7.2.0",
354354
"react-resizable": "^1.7.5",
355355
"react-resize-detector": "^4.2.0",

packages/kbn-optimizer/limits.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pageLoadAssetSize:
3434
indexPatternManagement: 28222
3535
indexPatternEditor: 40000
3636
infra: 184320
37-
fleet: 465774
37+
fleet: 250000
3838
ingestPipelines: 58003
3939
inputControlVis: 172675
4040
inspector: 148711

packages/kbn-securitysolution-io-ts-list-types/src/typescript_types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export interface UseExceptionListsProps {
4040
http: HttpStart;
4141
namespaceTypes: NamespaceType[];
4242
notifications: NotificationsStart;
43-
pagination?: Pagination;
43+
initialPagination?: Pagination;
4444
showTrustedApps: boolean;
4545
showEventFilters: boolean;
4646
}

packages/kbn-securitysolution-list-hooks/src/use_exception_lists/index.ts

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Side Public License, v 1.
77
*/
88

9-
import { useEffect, useMemo, useRef, useState } from 'react';
9+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
1010
import type {
1111
ExceptionListSchema,
1212
UseExceptionListsProps,
@@ -17,7 +17,19 @@ import { fetchExceptionLists } from '@kbn/securitysolution-list-api';
1717
import { getFilters } from '@kbn/securitysolution-list-utils';
1818

1919
export type Func = () => void;
20-
export type ReturnExceptionLists = [boolean, ExceptionListSchema[], Pagination, Func | null];
20+
export type ReturnExceptionLists = [
21+
loading: boolean,
22+
exceptionLists: ExceptionListSchema[],
23+
pagination: Pagination,
24+
setPagination: React.Dispatch<React.SetStateAction<Pagination>>,
25+
fetchLists: Func | null
26+
];
27+
28+
const DEFAULT_PAGINATION = {
29+
page: 1,
30+
perPage: 20,
31+
total: 0,
32+
};
2133

2234
/**
2335
* Hook for fetching ExceptionLists
@@ -29,27 +41,23 @@ export type ReturnExceptionLists = [boolean, ExceptionListSchema[], Pagination,
2941
* @param notifications kibana service for displaying toasters
3042
* @param showTrustedApps boolean - include/exclude trusted app lists
3143
* @param showEventFilters boolean - include/exclude event filters lists
32-
* @param pagination
44+
* @param initialPagination
3345
*
3446
*/
3547
export const useExceptionLists = ({
3648
errorMessage,
3749
http,
38-
pagination = {
39-
page: 1,
40-
perPage: 20,
41-
total: 0,
42-
},
50+
initialPagination = DEFAULT_PAGINATION,
4351
filterOptions = {},
4452
namespaceTypes,
4553
notifications,
4654
showTrustedApps = false,
4755
showEventFilters = false,
4856
}: UseExceptionListsProps): ReturnExceptionLists => {
4957
const [exceptionLists, setExceptionLists] = useState<ExceptionListSchema[]>([]);
50-
const [paginationInfo, setPagination] = useState<Pagination>(pagination);
58+
const [pagination, setPagination] = useState<Pagination>(initialPagination);
5159
const [loading, setLoading] = useState(true);
52-
const fetchExceptionListsRef = useRef<Func | null>(null);
60+
const abortCtrlRef = useRef<AbortController>();
5361

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

61-
useEffect(() => {
62-
let isSubscribed = true;
63-
const abortCtrl = new AbortController();
69+
const fetchData = useCallback(async (): Promise<void> => {
70+
try {
71+
setLoading(true);
6472

65-
const fetchData = async (): Promise<void> => {
66-
try {
67-
setLoading(true);
73+
abortCtrlRef.current = new AbortController();
6874

69-
const { page, per_page: perPage, total, data } = await fetchExceptionLists({
70-
filters,
71-
http,
72-
namespaceTypes: namespaceTypesAsString,
73-
pagination: {
74-
page: pagination.page,
75-
perPage: pagination.perPage,
76-
},
77-
signal: abortCtrl.signal,
78-
});
75+
const { page, per_page: perPage, total, data } = await fetchExceptionLists({
76+
filters,
77+
http,
78+
namespaceTypes: namespaceTypesAsString,
79+
pagination: {
80+
page: pagination.page,
81+
perPage: pagination.perPage,
82+
},
83+
signal: abortCtrlRef.current.signal,
84+
});
7985

80-
if (isSubscribed) {
81-
setPagination({
82-
page,
83-
perPage,
84-
total,
85-
});
86-
setExceptionLists(data);
87-
setLoading(false);
88-
}
89-
} catch (error) {
90-
if (isSubscribed) {
91-
notifications.toasts.addError(error, {
92-
title: errorMessage,
93-
});
94-
setExceptionLists([]);
95-
setPagination({
96-
page: 1,
97-
perPage: 20,
98-
total: 0,
99-
});
100-
setLoading(false);
101-
}
86+
setPagination({
87+
page,
88+
perPage,
89+
total,
90+
});
91+
setExceptionLists(data);
92+
setLoading(false);
93+
} catch (error) {
94+
if (error.name !== 'AbortError') {
95+
notifications.toasts.addError(error, {
96+
title: errorMessage,
97+
});
98+
setExceptionLists([]);
99+
setPagination(DEFAULT_PAGINATION);
100+
setLoading(false);
102101
}
103-
};
104-
105-
fetchData();
106-
107-
fetchExceptionListsRef.current = fetchData;
108-
return (): void => {
109-
isSubscribed = false;
110-
abortCtrl.abort();
111-
};
102+
}
112103
}, [
113104
errorMessage,
114-
notifications,
115-
pagination.page,
116-
pagination.perPage,
117105
filters,
118-
namespaceTypesAsString,
119106
http,
107+
namespaceTypesAsString,
108+
notifications.toasts,
109+
pagination.page,
110+
pagination.perPage,
120111
]);
121112

122-
return [loading, exceptionLists, paginationInfo, fetchExceptionListsRef.current];
113+
useEffect(() => {
114+
fetchData();
115+
116+
return (): void => {
117+
abortCtrlRef.current?.abort();
118+
};
119+
}, [fetchData]);
120+
121+
return [loading, exceptionLists, pagination, setPagination, fetchData];
123122
};

src/core/public/chrome/chrome_service.mock.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const createStartContractMock = () => {
5555
getCustomNavLink$: jest.fn(),
5656
setCustomNavLink: jest.fn(),
5757
setHeaderBanner: jest.fn(),
58+
hasHeaderBanner$: jest.fn(),
5859
getBodyClasses$: jest.fn(),
5960
};
6061
startContract.navLinks.getAll.mockReturnValue([]);
@@ -66,6 +67,7 @@ const createStartContractMock = () => {
6667
startContract.getHelpExtension$.mockReturnValue(new BehaviorSubject(undefined));
6768
startContract.getIsNavDrawerLocked$.mockReturnValue(new BehaviorSubject(false));
6869
startContract.getBodyClasses$.mockReturnValue(new BehaviorSubject([]));
70+
startContract.hasHeaderBanner$.mockReturnValue(new BehaviorSubject(false));
6971
return startContract;
7072
};
7173

src/core/public/chrome/chrome_service.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,19 @@ describe('start', () => {
390390
});
391391
});
392392

393+
describe('header banner', () => {
394+
it('updates/emits the state of the header banner', async () => {
395+
const { chrome, service } = await start();
396+
const promise = chrome.hasHeaderBanner$().pipe(toArray()).toPromise();
397+
398+
chrome.setHeaderBanner({ content: () => () => undefined });
399+
chrome.setHeaderBanner(undefined);
400+
service.stop();
401+
402+
await expect(promise).resolves.toEqual([false, true, false]);
403+
});
404+
});
405+
393406
describe('erase chrome fields', () => {
394407
it('while switching an app', async () => {
395408
const startDeps = defaultStartDeps([new FakeApp('alpha')]);

0 commit comments

Comments
 (0)