Skip to content

Commit

Permalink
[Security Solutions][Endpoint] Change search bar placeholder and make…
Browse files Browse the repository at this point in the history
… it dynamic by props (#100047)

* Change search bar placeholder and make it dynamic by props

* Adds placeholder on test

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dasansol92 and kibanamachine authored May 14, 2021
1 parent 8240b57 commit fd7c3b6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Search bar', () => {
});

const getElement = (defaultValue: string = '') => (
<SearchBar defaultValue={defaultValue} onSearch={onSearchMock} />
<SearchBar defaultValue={defaultValue} onSearch={onSearchMock} placeholder={'placeholder'} />
);

it('should have a default value', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import { i18n } from '@kbn/i18n';

export interface SearchBarProps {
defaultValue?: string;
placeholder: string;
onSearch(value: string): void;
}

export const SearchBar = memo<SearchBarProps>(({ defaultValue = '', onSearch }) => {
export const SearchBar = memo<SearchBarProps>(({ defaultValue = '', onSearch, placeholder }) => {
const [query, setQuery] = useState<string>(defaultValue);

const handleOnChangeSearchField = useCallback(
Expand All @@ -28,12 +29,7 @@ export const SearchBar = memo<SearchBarProps>(({ defaultValue = '', onSearch })
<EuiFlexItem>
<EuiFieldSearch
defaultValue={query}
placeholder={i18n.translate(
'xpack.securitySolution.trustedapps.list.search.placeholder',
{
defaultMessage: 'Search',
}
)}
placeholder={placeholder}
onChange={handleOnChangeSearchField}
onSearch={onSearch}
isClearable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,10 @@ export const CREATE_TRUSTED_APP_ERROR: { [K in string]: string } = {
{ defaultMessage: 'An invalid Signature was entered. Please enter in a valid Signature.' }
),
};

export const SEARCH_TRUSTED_APP_PLACEHOLDER = i18n.translate(
'xpack.securitySolution.trustedapps.list.search.placeholder',
{
defaultMessage: 'Search on the fields below: name, description, value',
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { TrustedAppDeletionDialog } from './trusted_app_deletion_dialog';
import { TrustedAppsNotifications } from './trusted_apps_notifications';
import { TrustedAppsListPageRouteState } from '../../../../../common/endpoint/types';
import { useNavigateToAppEventHandler } from '../../../../common/hooks/endpoint/use_navigate_to_app_event_handler';
import { ABOUT_TRUSTED_APPS } from './translations';
import { ABOUT_TRUSTED_APPS, SEARCH_TRUSTED_APP_PLACEHOLDER } from './translations';
import { EmptyState } from './components/empty_state';
import { SearchBar } from './components/search_bar';

Expand Down Expand Up @@ -96,7 +96,11 @@ export const TrustedAppsPage = memo(() => {
/>
)}

<SearchBar defaultValue={location.filter} onSearch={handleOnSearch} />
<SearchBar
defaultValue={location.filter}
onSearch={handleOnSearch}
placeholder={SEARCH_TRUSTED_APP_PLACEHOLDER}
/>
{doEntriesExist ? (
<EuiFlexGroup
direction="column"
Expand Down

0 comments on commit fd7c3b6

Please sign in to comment.