Skip to content

Commit df8ea9c

Browse files
authored
fixed image download issue (#38)
1 parent f988bba commit df8ea9c

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

ui/src/components/Feedback/DownloadProgress/DownloadProgress.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export const DownloadProgress = ({ callback, imageName }: DownloadProgressProps)
3030
.reduce((partialSum, [, value]) => partialSum + statusValues.get(value), 0) / statusMap.size;
3131

3232
useEffect(() => {
33+
setIsDone(false);
34+
setStatusMap(new Map());
3335
ddClient.docker.cli.exec('pull', [imageName], {
3436
stream: {
3537
onOutput(data): void {
@@ -61,7 +63,7 @@ export const DownloadProgress = ({ callback, imageName }: DownloadProgressProps)
6163
splitOutputLines: true,
6264
},
6365
});
64-
}, []);
66+
}, [imageName]);
6567

6668
const percentageValue = Number.isNaN(percentage) ? 0 : percentage;
6769
return (

ui/src/components/Header/Controller.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { ReactElement, useEffect, useState } from 'react';
22
import { Chip, ButtonGroup, Select, MenuItem, FormControl, Box, Badge, Tooltip } from '@mui/material';
33
import { PlayArrow, Stop } from '@mui/icons-material';
4-
import {
4+
import {
55
isALocalStackContainer,
66
removeTagFromImage,
77
useDDClient,
@@ -91,13 +91,20 @@ export const Controller = (): ReactElement => {
9191
const isPro = runConfigs.find(config => config.name === runningConfig)
9292
.vars.some(item => item.variable === 'LOCALSTACK_API_KEY');
9393

94-
const imageToUse = isPro ? PRO_IMAGE : IMAGE;
95-
const haveLocally = images.some(image => removeTagFromImage(image) === imageToUse);
96-
97-
if (!haveLocally) {
98-
setDownloadProps({ open: true, image: imageToUse });
94+
const haveCommunity = images.some(image => removeTagFromImage(image) === IMAGE);
95+
if (!haveCommunity) {
96+
setDownloadProps({ open: true, image: IMAGE });
9997
return;
10098
}
99+
100+
if (isPro) {
101+
const havePro = images.some(image => removeTagFromImage(image) === PRO_IMAGE);
102+
if (!havePro) {
103+
setDownloadProps({ open: true, image: PRO_IMAGE });
104+
return;
105+
}
106+
}
107+
101108
const args = await normalizeArguments();
102109

103110
setIsStarting(true);

ui/src/services/util/containers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function removeRepoFromImage(repoTag: string) {
1111
}
1212

1313
export function removeTagFromImage(image: DockerImage){
14-
return image.RepoTags[0].split(':').slice(0, -1).join(':');
14+
return image.RepoTags?.at(0).split(':').slice(0, -1).join(':');
1515
}
1616

1717
export const isALocalStackContainer = (container: DockerContainer) =>

0 commit comments

Comments
 (0)