mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-22 16:18:31 +00:00
pass search props
This commit is contained in:
parent
36102865c5
commit
75ad1f4b02
@ -10,9 +10,16 @@ import { useEffect, useState } from 'react'
|
|||||||
import HeaderBtns from './HeaderBtns'
|
import HeaderBtns from './HeaderBtns'
|
||||||
|
|
||||||
const LogsPage = () => {
|
const LogsPage = () => {
|
||||||
|
const [highLightSearched, setHighLightSearched] = useState(false)
|
||||||
|
const [searchInput, setSearchInput] = useState('');
|
||||||
const [timestamps, setTimestamps] = useState(false)
|
const [timestamps, setTimestamps] = useState(false)
|
||||||
const [windowWidth, setWindowWidth] = useState(window.innerWidth)
|
const [windowWidth, setWindowWidth] = useState(window.innerWidth)
|
||||||
const [dropdownMenuItem, setDropdownMenuItem] = useState('Validator')
|
const [dropdownMenuItem, setDropdownMenuItem] = useState('Validator')
|
||||||
|
|
||||||
|
const triggerSearch = (isTriggered: boolean) => {
|
||||||
|
setHighLightSearched(isTriggered)
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleResize = () => {
|
const handleResize = () => {
|
||||||
setWindowWidth(+window.innerWidth)
|
setWindowWidth(+window.innerWidth)
|
||||||
@ -46,6 +53,11 @@ const LogsPage = () => {
|
|||||||
setDropdownMenuItem={setDropdownMenuItem}
|
setDropdownMenuItem={setDropdownMenuItem}
|
||||||
setTimestamps={setTimestamps}
|
setTimestamps={setTimestamps}
|
||||||
timestamps={timestamps}
|
timestamps={timestamps}
|
||||||
|
searchInput={searchInput}
|
||||||
|
setSearchInput={setSearchInput}
|
||||||
|
triggerSearch={triggerSearch}
|
||||||
|
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</XStack>
|
</XStack>
|
||||||
<Stack style={{ width: '100%', alignItems: 'center' }}>
|
<Stack style={{ width: '100%', alignItems: 'center' }}>
|
||||||
@ -53,6 +65,9 @@ const LogsPage = () => {
|
|||||||
windowWidth={windowWidth}
|
windowWidth={windowWidth}
|
||||||
dropdownMenuItem={dropdownMenuItem}
|
dropdownMenuItem={dropdownMenuItem}
|
||||||
timestamps={timestamps}
|
timestamps={timestamps}
|
||||||
|
searchInput={searchInput}
|
||||||
|
setSearchInput={setSearchInput}
|
||||||
|
highLightSearched={highLightSearched}
|
||||||
/>
|
/>
|
||||||
<Stack
|
<Stack
|
||||||
space="$4"
|
space="$4"
|
||||||
|
@ -16,6 +16,9 @@ type LogsTerminalProps = {
|
|||||||
windowWidth: number
|
windowWidth: number
|
||||||
dropdownMenuItem: string
|
dropdownMenuItem: string
|
||||||
timestamps: boolean
|
timestamps: boolean
|
||||||
|
searchInput: string
|
||||||
|
setSearchInput: (searchInput: string) => void
|
||||||
|
highLightSearched: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchMoreData = () => {
|
const fetchMoreData = () => {
|
||||||
@ -30,15 +33,19 @@ const fetchMoreData = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const LogsTerminal = ({ windowWidth, timestamps }: LogsTerminalProps) => {
|
const LogsTerminal = ({
|
||||||
|
windowWidth,
|
||||||
|
timestamps,
|
||||||
|
searchInput,
|
||||||
|
setSearchInput,
|
||||||
|
highLightSearched,
|
||||||
|
}: LogsTerminalProps) => {
|
||||||
const [data, setData] = useState<DataType[]>([])
|
const [data, setData] = useState<DataType[]>([])
|
||||||
const [loadedIndexes, setLoadedIndexes] = useState<{ [key: number]: boolean }>({})
|
const [loadedIndexes, setLoadedIndexes] = useState<{ [key: number]: boolean }>({})
|
||||||
const listRef = useRef<List | null>(null)
|
const listRef = useRef<List | null>(null)
|
||||||
|
|
||||||
const [shouldAutoScroll, setShouldAutoScroll] = useState(true)
|
const [shouldAutoScroll, setShouldAutoScroll] = useState(true)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shouldAutoScroll) {
|
if (shouldAutoScroll) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -123,11 +130,22 @@ const LogsTerminal = ({ windowWidth, timestamps }: LogsTerminalProps) => {
|
|||||||
border: '1px solid #E7EAEE',
|
border: '1px solid #E7EAEE',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{({ index, style }) => (
|
{({ index, style }) => {
|
||||||
|
const highlight =
|
||||||
|
searchInput && data[index].description.split(' ').includes(searchInput)
|
||||||
|
// now we only check for the existing text at the moment
|
||||||
|
// I have to move this statemant in the terminalRow component
|
||||||
|
return (
|
||||||
<Stack style={style}>
|
<Stack style={style}>
|
||||||
<TerminalRow data={data[index]} index={index} timestamps={timestamps} />
|
<TerminalRow
|
||||||
|
data={data[index]}
|
||||||
|
index={index}
|
||||||
|
timestamps={timestamps}
|
||||||
|
highlight={highlight}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)
|
||||||
|
}}
|
||||||
</List>
|
</List>
|
||||||
)}
|
)}
|
||||||
</InfiniteLoader>
|
</InfiniteLoader>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user