Skip to content

Commit 01fc46f

Browse files
[Security Solution][Endpoint] Do not display searchbar in security-trusted apps if there are no items (#100853)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 9f19a64 commit 01fc46f

3 files changed

Lines changed: 44 additions & 29 deletions

File tree

x-pack/plugins/security_solution/public/management/components/search_bar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const SearchBar = memo<SearchBarProps>(({ defaultValue = '', onSearch, pl
2525
const handleOnSearch = useCallback(() => onSearch(query), [query, onSearch]);
2626

2727
return (
28-
<EuiFlexGroup direction="row" alignItems="center" gutterSize="l">
28+
<EuiFlexGroup data-test-subj="searchBar" direction="row" alignItems="center" gutterSize="l">
2929
<EuiFlexItem>
3030
<EuiFieldSearch
3131
defaultValue={defaultValue}

x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,15 @@ describe('When on the Trusted Apps Page', () => {
169169

170170
it('should display a Add Trusted App button', async () => {
171171
const { getByTestId } = await renderWithListData();
172-
const addButton = await getByTestId('trustedAppsListAddButton');
172+
const addButton = getByTestId('trustedAppsListAddButton');
173173
expect(addButton.textContent).toBe('Add Trusted Application');
174174
});
175175

176+
it('should display the searchbar', async () => {
177+
const renderResult = await renderWithListData();
178+
expect(await renderResult.findByTestId('searchBar')).not.toBeNull();
179+
});
180+
176181
describe('and the Grid view is being displayed', () => {
177182
describe('and the edit trusted app button is clicked', () => {
178183
let renderResult: ReturnType<AppContextTestRender['render']>;
@@ -555,7 +560,7 @@ describe('When on the Trusted Apps Page', () => {
555560
// to test the UI behaviours while the API call is in flight
556561
coreStart.http.post.mockImplementation(
557562
// @ts-ignore
558-
async (path: string, options: HttpFetchOptions) => {
563+
async (_, options: HttpFetchOptions) => {
559564
return new Promise((resolve, reject) => {
560565
httpPostBody = options.body as string;
561566
resolveHttpPost = resolve;
@@ -861,6 +866,14 @@ describe('When on the Trusted Apps Page', () => {
861866

862867
expect(await renderResult.findByTestId('trustedAppEmptyState')).not.toBeNull();
863868
});
869+
870+
it('should not display the searchbar', async () => {
871+
const renderResult = render();
872+
await act(async () => {
873+
await waitForAction('trustedAppsExistStateChanged');
874+
});
875+
expect(renderResult.queryByTestId('searchBar')).toBeNull();
876+
});
864877
});
865878

866879
describe('and the search is dispatched', () => {

x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,34 +96,36 @@ export const TrustedAppsPage = memo(() => {
9696
/>
9797
)}
9898

99-
<SearchBar
100-
defaultValue={location.filter}
101-
onSearch={handleOnSearch}
102-
placeholder={SEARCH_TRUSTED_APP_PLACEHOLDER}
103-
/>
10499
{doEntriesExist ? (
105-
<EuiFlexGroup
106-
direction="column"
107-
gutterSize="none"
108-
data-test-subj="trustedAppsListPageContent"
109-
>
110-
<EuiSpacer size="m" />
111-
<EuiFlexItem grow={false}>
112-
<ControlPanel
113-
totalItemCount={totalItemsCount}
114-
currentViewType={location.view_type}
115-
onViewTypeChange={handleViewTypeChange}
116-
/>
117-
100+
<>
101+
<SearchBar
102+
defaultValue={location.filter}
103+
onSearch={handleOnSearch}
104+
placeholder={SEARCH_TRUSTED_APP_PLACEHOLDER}
105+
/>
106+
<EuiFlexGroup
107+
direction="column"
108+
gutterSize="none"
109+
data-test-subj="trustedAppsListPageContent"
110+
>
118111
<EuiSpacer size="m" />
119-
</EuiFlexItem>
120-
<EuiFlexItem>
121-
<EuiHorizontalRule margin="none" />
122-
123-
{location.view_type === 'grid' && <TrustedAppsGrid />}
124-
{location.view_type === 'list' && <TrustedAppsList />}
125-
</EuiFlexItem>
126-
</EuiFlexGroup>
112+
<EuiFlexItem grow={false}>
113+
<ControlPanel
114+
totalItemCount={totalItemsCount}
115+
currentViewType={location.view_type}
116+
onViewTypeChange={handleViewTypeChange}
117+
/>
118+
119+
<EuiSpacer size="m" />
120+
</EuiFlexItem>
121+
<EuiFlexItem>
122+
<EuiHorizontalRule margin="none" />
123+
124+
{location.view_type === 'grid' && <TrustedAppsGrid />}
125+
{location.view_type === 'list' && <TrustedAppsList />}
126+
</EuiFlexItem>
127+
</EuiFlexGroup>
128+
</>
127129
) : (
128130
<EmptyState onAdd={handleAddButtonClick} isAddDisabled={showCreateFlyout} />
129131
)}

0 commit comments

Comments
 (0)