-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Candace Park <56409205+parkiino@users.noreply.github.com>
- Loading branch information
Showing
13 changed files
with
536 additions
and
19 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
.../plugins/security_solution/public/management/pages/endpoint_hosts/models/index_pattern.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { all } from 'deepmerge'; | ||
import { IIndexPattern } from '../../../../../../../../src/plugins/data/common'; | ||
import { Immutable } from '../../../../../common/endpoint/types'; | ||
|
||
export function clone(value: IIndexPattern | Immutable<IIndexPattern>): IIndexPattern { | ||
return all([value]) as IIndexPattern; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...s/security_solution/public/management/pages/endpoint_hosts/view/components/search_bar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { memo, useCallback, useMemo } from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { encode, RisonValue } from 'rison-node'; | ||
import styled from 'styled-components'; | ||
import { Query, SearchBar, TimeHistory } from '../../../../../../../../../src/plugins/data/public'; | ||
import { Storage } from '../../../../../../../../../src/plugins/kibana_utils/public'; | ||
import { urlFromQueryParams } from '../url_from_query_params'; | ||
import { useEndpointSelector } from '../hooks'; | ||
import * as selectors from '../../store/selectors'; | ||
import { clone } from '../../models/index_pattern'; | ||
|
||
const AdminQueryBar = styled.div` | ||
.globalQueryBar { | ||
padding: 0; | ||
} | ||
`; | ||
|
||
export const AdminSearchBar = memo(() => { | ||
const history = useHistory(); | ||
const queryParams = useEndpointSelector(selectors.uiQueryParams); | ||
const searchBarIndexPatterns = useEndpointSelector(selectors.patterns); | ||
const searchBarQuery = useEndpointSelector(selectors.searchBarQuery); | ||
const clonedIndexPatterns = useMemo( | ||
() => searchBarIndexPatterns.map((pattern) => clone(pattern)), | ||
[searchBarIndexPatterns] | ||
); | ||
|
||
const onQuerySubmit = useCallback( | ||
(params: { query?: Query }) => { | ||
history.push( | ||
urlFromQueryParams({ | ||
...queryParams, | ||
admin_query: encode((params.query as unknown) as RisonValue), | ||
}) | ||
); | ||
}, | ||
[history, queryParams] | ||
); | ||
|
||
const timeHistory = useMemo(() => new TimeHistory(new Storage(localStorage)), []); | ||
|
||
return ( | ||
<div> | ||
{searchBarIndexPatterns && searchBarIndexPatterns.length > 0 && ( | ||
<AdminQueryBar> | ||
<SearchBar | ||
dataTestSubj="adminSearchBar" | ||
query={searchBarQuery} | ||
indexPatterns={clonedIndexPatterns} | ||
timeHistory={timeHistory} | ||
onQuerySubmit={onQuerySubmit} | ||
isLoading={false} | ||
showFilterBar={false} | ||
showDatePicker={false} | ||
showQueryBar={true} | ||
showQueryInput={true} | ||
/> | ||
</AdminQueryBar> | ||
)} | ||
</div> | ||
); | ||
}); | ||
|
||
AdminSearchBar.displayName = 'AdminSearchBar'; |
Oops, something went wrong.