Skip to content

Commit

Permalink
Fix: Filter block rows in bucket UI according to searched block ID (#…
Browse files Browse the repository at this point in the history
…5102)

* added helper function to filter block rows

Signed-off-by: soumya <somu12.ss@gmail.com>

* updated store UI to show filtered block rows

Signed-off-by: soumya <somu12.ss@gmail.com>

* added unit tests for getFilteredBlockPools function

Signed-off-by: soumya <somu12.ss@gmail.com>
  • Loading branch information
tend2infinity committed Feb 13, 2022
1 parent 6eedf76 commit 2898724
Show file tree
Hide file tree
Showing 4 changed files with 441 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re

### Fixed

- [#5102](https://github.com/thanos-io/thanos/pull/5102) Fix: Filter block rows in bucket UI according to searched block ID
- [#5051](https://github.com/thanos-io/thanos/pull/5051) Prober: Remove spam of changing probe status.
- [#4918](https://github.com/thanos-io/thanos/pull/4918) Tracing: Fixing force tracing with Jaeger.
- [#4879](https://github.com/thanos-io/thanos/pull/4879) Bucket verify: Fixed bug causing wrong number of blocks to be checked.
Expand Down
34 changes: 21 additions & 13 deletions pkg/ui/react-app/src/thanos/pages/blocks/Blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SourceView } from './SourceView';
import { BlockDetails } from './BlockDetails';
import { BlockSearchInput } from './BlockSearchInput';
import { BlockFilterCompaction } from './BlockFilterCompaction';
import { sortBlocks } from './helpers';
import { sortBlocks, getBlockByUlid, getFilteredBlockPools } from './helpers';
import styles from './blocks.module.css';
import TimeRange from './TimeRange';
import Checkbox from '../../../components/Checkbox';
Expand Down Expand Up @@ -71,6 +71,8 @@ export const BlocksContent: FC<{ data: BlockListProps }> = ({ data }) => {
const [blockSearch, setBlockSearch] = useState<string>(blockSearchParam);

const blockPools = useMemo(() => sortBlocks(blocks, label, findOverlappingBlocks), [blocks, label, findOverlappingBlocks]);
const filteredBlocks = useMemo(() => getBlockByUlid(blocks, blockSearch), [blocks, blockSearch]);
const filteredBlockPools = useMemo(() => getFilteredBlockPools(blockPools, filteredBlocks), [filteredBlocks, blockPools]);

const setViewTime = (times: number[]): void => {
setQuery({
Expand Down Expand Up @@ -151,18 +153,24 @@ export const BlocksContent: FC<{ data: BlockListProps }> = ({ data }) => {
<div className={styles.container}>
<div className={styles.grid}>
<div className={styles.sources}>
{Object.keys(blockPools).map((pk) => (
<SourceView
key={pk}
data={blockPools[pk]}
title={pk}
selectBlock={selectBlock}
gridMinTime={viewMinTime}
gridMaxTime={viewMaxTime}
blockSearch={blockSearch}
compactionLevel={compactionLevel}
/>
))}
{Object.keys(filteredBlockPools).length > 0 ? (
Object.keys(filteredBlockPools).map((pk) => (
<SourceView
key={pk}
data={filteredBlockPools[pk]}
title={pk}
selectBlock={selectBlock}
gridMinTime={viewMinTime}
gridMaxTime={viewMaxTime}
blockSearch={blockSearch}
compactionLevel={compactionLevel}
/>
))
) : (
<div>
<h3>No Blocks Found!</h3>
</div>
)}
</div>
<TimeRange
gridMinTime={gridMinTime}
Expand Down

0 comments on commit 2898724

Please sign in to comment.