1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/dock/pod-log-search.tsx
Alex Andreev 7ac13f5004 Using Prev/Next icons for search
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
2020-10-21 14:49:41 +03:00

60 lines
1.6 KiB
TypeScript

import "./pod-log-search.scss";
import React from "react";
import { observer } from "mobx-react";
import { SearchInput } from "../input";
import { searchStore } from "./search.store";
import { Icon } from "../icon";
import { _i18n } from "../../i18n";
import { t } from "@lingui/macro";
export interface PodLogSearchProps {
onSearch: (query: string) => void
toPrevOverlay: () => void
toNextOverlay: () => void
logs: string[]
}
export const PodLogSearch = observer((props: PodLogSearchProps) => {
const { logs, onSearch, toPrevOverlay, toNextOverlay } = props;
const { setNextOverlayActive, setPrevOverlayActive, searchQuery, occurrences } = searchStore;
const jumpDisabled = !searchQuery || !occurrences.length;
const setSearch = (query: string) => {
searchStore.onSearch(logs, query);
onSearch(query);
};
const onPrevOverlay = () => {
setPrevOverlayActive();
toPrevOverlay();
}
const onNextOverlay = () => {
setNextOverlayActive();
toNextOverlay();
}
return (
<div className="PodLogsSearch flex box grow justify-flex-end gaps align-center">
<SearchInput
value={searchQuery}
onChange={setSearch}
updateUrl={false}
/>
{/* <span>{activeOverlay} / {totalOverlays}</span> */}
<Icon
material="keyboard_arrow_up"
tooltip={_i18n._(t`Previous`)}
onClick={onPrevOverlay}
disabled={jumpDisabled}
/>
<Icon
material="keyboard_arrow_down"
tooltip={_i18n._(t`Next`)}
onClick={onNextOverlay}
disabled={jumpDisabled}
/>
</div>
);
});