mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding find counters
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
de33f52a30
commit
cfb6c3c4c0
@ -1,6 +1,7 @@
|
|||||||
.PodLogsSearch {
|
.PodLogsSearch {
|
||||||
.SearchInput {
|
.SearchInput {
|
||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
|
width: 150px;
|
||||||
|
|
||||||
label {
|
label {
|
||||||
background: none;
|
background: none;
|
||||||
@ -8,5 +9,9 @@
|
|||||||
border-radius: $radius;
|
border-radius: $radius;
|
||||||
box-shadow: 0 0 0 1px $halfGray;
|
box-shadow: 0 0 0 1px $halfGray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.find-count {
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17,8 +17,13 @@ export interface PodLogSearchProps {
|
|||||||
|
|
||||||
export const PodLogSearch = observer((props: PodLogSearchProps) => {
|
export const PodLogSearch = observer((props: PodLogSearchProps) => {
|
||||||
const { logs, onSearch, toPrevOverlay, toNextOverlay } = props;
|
const { logs, onSearch, toPrevOverlay, toNextOverlay } = props;
|
||||||
const { setNextOverlayActive, setPrevOverlayActive, searchQuery, occurrences } = searchStore;
|
const { setNextOverlayActive, setPrevOverlayActive, searchQuery, occurrences, activeFind, totalFinds } = searchStore;
|
||||||
const jumpDisabled = !searchQuery || !occurrences.length;
|
const jumpDisabled = !searchQuery || !occurrences.length;
|
||||||
|
const findCounts = (
|
||||||
|
<div className="find-count">
|
||||||
|
{activeFind}/{totalFinds}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
const setSearch = (query: string) => {
|
const setSearch = (query: string) => {
|
||||||
searchStore.onSearch(logs, query);
|
searchStore.onSearch(logs, query);
|
||||||
@ -40,9 +45,9 @@ export const PodLogSearch = observer((props: PodLogSearchProps) => {
|
|||||||
<SearchInput
|
<SearchInput
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={setSearch}
|
onChange={setSearch}
|
||||||
updateUrl={false}
|
closeIcon={false}
|
||||||
|
contentRight={totalFinds > 0 && findCounts}
|
||||||
/>
|
/>
|
||||||
{/* <span>{activeOverlay} / {totalOverlays}</span> */}
|
|
||||||
<Icon
|
<Icon
|
||||||
material="keyboard_arrow_up"
|
material="keyboard_arrow_up"
|
||||||
tooltip={_i18n._(t`Previous`)}
|
tooltip={_i18n._(t`Previous`)}
|
||||||
@ -55,6 +60,11 @@ export const PodLogSearch = observer((props: PodLogSearchProps) => {
|
|||||||
onClick={onNextOverlay}
|
onClick={onNextOverlay}
|
||||||
disabled={jumpDisabled}
|
disabled={jumpDisabled}
|
||||||
/>
|
/>
|
||||||
|
<Icon
|
||||||
|
material="close"
|
||||||
|
tooltip={_i18n._(t`Clear`)}
|
||||||
|
onClick={() => setSearch("")}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -87,6 +87,14 @@ export class SearchStore {
|
|||||||
return this.occurrences[this.activeOverlayIndex];
|
return this.occurrences[this.activeOverlayIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed get activeFind(): number {
|
||||||
|
return this.activeOverlayIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@computed get totalFinds(): number {
|
||||||
|
return this.occurrences.length;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if overlay is active (to highlight it with orange background usually)
|
* Checks if overlay is active (to highlight it with orange background usually)
|
||||||
* @param line Index of the line where overlay is located
|
* @param line Index of the line where overlay is located
|
||||||
@ -110,6 +118,7 @@ export class SearchStore {
|
|||||||
reset() {
|
reset() {
|
||||||
this.searchQuery = "";
|
this.searchQuery = "";
|
||||||
this.activeOverlayIndex = -1;
|
this.activeOverlayIndex = -1;
|
||||||
|
this.occurrences = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user