mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
* changes in files of the expr in alerts, service and targets, Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * update prettier corrections Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * update prettier corrections Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * correction suggested fixes PR Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * Update Snap AlertContents.test.tsx and update recommendations in the code Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * Update web/ui/react-app/src/components/SearchBar.tsx exactly, thanks :) Co-authored-by: Julius Volz <julius.volz@gmail.com> Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * Revert "Update web/ui/react-app/src/components/SearchBar.tsx " This reverts commit 679c763a02f65297e3f761db372a0928550f288c. Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * update SearchBar component Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * eslint-disable update SearchBar testing failed Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * correction part in eslint-disable Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * fully corrected suggestion with search expression in url Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> * implementation in handleSearchChange with useCallBack Signed-off-by: AndreSPy1 <elsenorcito@gmail.com> Co-authored-by: Julius Volz <julius.volz@gmail.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import React, { ChangeEvent, FC, useEffect } from 'react';
|
|
import { Input, InputGroup, InputGroupAddon, InputGroupText } from 'reactstrap';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
import { faSearch } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
export interface SearchBarProps {
|
|
handleChange: (e: string) => void;
|
|
placeholder: string;
|
|
defaultValue: string;
|
|
}
|
|
|
|
const SearchBar: FC<SearchBarProps> = ({ handleChange, placeholder, defaultValue }) => {
|
|
let filterTimeout: NodeJS.Timeout;
|
|
|
|
const handleSearchChange = (e: ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => {
|
|
clearTimeout(filterTimeout);
|
|
filterTimeout = setTimeout(() => {
|
|
handleChange(e.target.value);
|
|
}, 300);
|
|
};
|
|
|
|
useEffect(() => {
|
|
handleChange(defaultValue);
|
|
}, [defaultValue, handleChange]);
|
|
|
|
return (
|
|
<InputGroup>
|
|
<InputGroupAddon addonType="prepend">
|
|
<InputGroupText>{<FontAwesomeIcon icon={faSearch} />}</InputGroupText>
|
|
</InputGroupAddon>
|
|
<Input autoFocus onChange={handleSearchChange} placeholder={placeholder} defaultValue={defaultValue} />
|
|
</InputGroup>
|
|
);
|
|
};
|
|
|
|
export default SearchBar;
|