Skip to content

Commit

Permalink
fix: images table did not load intermittently (#1804)
Browse files Browse the repository at this point in the history
Signed-off-by: Remington Breeze <[email protected]>
  • Loading branch information
rbreeze authored Apr 18, 2024
1 parent 7ccc959 commit fb7abbf
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ui/src/features/project/pipelines/images.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Switch, Tooltip } from 'antd';
import classNames from 'classnames';
import { useContext, useMemo, useState } from 'react';
import { useContext, useEffect, useMemo, useState } from 'react';
import { generatePath, useNavigate } from 'react-router-dom';

import { paths } from '@ui/config/paths';
Expand Down Expand Up @@ -122,12 +122,19 @@ export const Images = ({ projectName, stages }: { projectName: string; stages: S
}, [stages]);

const [imageURL, setImageURL] = useState(images.keys().next().value as string);
const image = imageURL && images.get(imageURL);
const [showHistory, setShowHistory] = useLocalStorage(`${projectName}-show-history`, false);

useEffect(() => {
setImageURL(images.keys().next().value as string);
}, [images]);

const curImage = useMemo(() => {
return images.get(imageURL);
}, [imageURL]);

return (
<>
{image ? (
{curImage ? (
<>
<div className='mb-4 flex items-center'>
<Switch onChange={(val) => setShowHistory(val)} checked={showHistory} />
Expand All @@ -143,7 +150,7 @@ export const Images = ({ projectName, stages }: { projectName: string; stages: S
}))}
/>
</div>
{Array.from(image.entries())
{Array.from(curImage.entries())
.sort((a, b) => b[0].localeCompare(a[0], undefined, { numeric: true }))
.map(([tag, tagStages]) => (
<ImageTagRow
Expand Down

0 comments on commit fb7abbf

Please sign in to comment.