Add more typings & refactor code accordingly

Change-type: patch
Signed-off-by: Lorenzo Alberto Maria Ambrosi <lorenzothunder.ambrosi@gmail.com>
This commit is contained in:
Lorenzo Alberto Maria Ambrosi
2020-09-03 15:46:18 +02:00
parent eeab351636
commit b76366a514
14 changed files with 140 additions and 233 deletions

View File

@@ -254,6 +254,7 @@ export interface SourceMetadata extends sourceDestination.Metadata {
SourceType: Source;
drive?: DrivelistDrive;
extension?: string;
archiveExtension?: string;
}
interface SourceSelectorProps {
@@ -262,8 +263,8 @@ interface SourceSelectorProps {
interface SourceSelectorState {
hasImage: boolean;
imageName: string;
imageSize: number;
imageName?: string;
imageSize?: number;
warning: { message: string; title: string | null } | null;
showImageDetails: boolean;
showURLSelector: boolean;
@@ -543,7 +544,7 @@ export class SourceSelector extends React.Component<
const imagePath = image.path || image.displayName || '';
const imageBasename = path.basename(imagePath);
const imageName = image.name || '';
const imageSize = image.size || 0;
const imageSize = image.size;
const imageLogo = image.logo || '';
return (
@@ -585,7 +586,9 @@ export class SourceSelector extends React.Component<
Remove
</ChangeButton>
)}
<DetailsText>{prettyBytes(imageSize)}</DetailsText>
{!_.isNil(imageSize) && (
<DetailsText>{prettyBytes(imageSize)}</DetailsText>
)}
</>
) : (
<>