Skip to content

Commit

Permalink
TODO: fix Type 'Block[][]' is not assignable to type 'BlocksPool'.
Browse files Browse the repository at this point in the history
  Index signature for type 'string' is missing in type 'Block[][]'.
  • Loading branch information
amandaguan-ag committed Aug 8, 2024
1 parent 3c79de6 commit af0c7b3
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions pkg/ui/react-app/src/thanos/pages/blocks/Blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useQueryParams, withDefault, NumberParam, StringParam, BooleanParam } f
import { withStatusIndicator } from '../../../components/withStatusIndicator';
import { useFetch } from '../../../hooks/useFetch';
import PathPrefixProps from '../../../types/PathPrefixProps';
import { Block } from './block';
import { Block, BlocksPool } from './block';
import { SourceView } from './SourceView';
import { BlockDetails } from './BlockDetails';
import { BlockSearchInput } from './BlockSearchInput';
Expand Down Expand Up @@ -216,16 +216,34 @@ export const PlanBlocksContent: FC<{ data: BlockListProps } & PathPrefixProps> =
);
}

const blocksPool = useMemo(() => {
const pool: BlocksPool = {};
blocks.forEach(block => {
const key = `Plan-${block.ulid}`;
if (!pool[key]) {
pool[key] = [];
}
pool[key].push([block]);
});
return pool;
}, [blocks]);

return (
<div>
<ul>
{blocks.map((block) => (
<li key={block.ulid}>
ULID: {block.ulid} (PathPrefix: {pathPrefix}){" "}
{/* Display pathPrefix for context */}
</li>
<div className={styles.container}>
<div className={styles.grid}>
{Object.keys(blocksPool).map(key => (
<SourceView
key={key}
data={blocksPool[key]}
title={`Plan View - ${key}`}
selectBlock={() => { }} // No-op function if selection is not applicable
gridMinTime={blocksPool[key].reduce((min: number, b: { minTime: number; }[]) => Math.min(min, b[0].minTime), Infinity)}
gridMaxTime={blocksPool[key].reduce((max: number, b: { maxTime: number; }[]) => Math.max(max, b[0].maxTime), -Infinity)}
blockSearch=""
compactionLevel={0}
/>
))}
</ul>
</div>
</div>
);
};
Expand Down

0 comments on commit af0c7b3

Please sign in to comment.