Skip to content
Snippets Groups Projects
Commit fed6fa0b authored by Jose Manuel Serrano Amaut's avatar Jose Manuel Serrano Amaut
Browse files

[REF]: Hide size formatted if not set or false

parent 56fa5724
No related branches found
No related tags found
No related merge requests found
...@@ -147,9 +147,7 @@ const FileCard: React.FC<FileCardProps> = (props: FileCardProps) => { ...@@ -147,9 +147,7 @@ const FileCard: React.FC<FileCardProps> = (props: FileCardProps) => {
videoUrl videoUrl
); );
//The size formatted and rounded in 2 decimals //The size formatted and rounded in 2 decimals
const sizeFormatted: string = localSize const sizeFormatted: string | undefined = fileSizeFormater(localSize);
? fileSizeFormater(localSize)
: "0 KB";
//alwaysActive //alwaysActive
const [showInfo, setShowInfo] = React.useState<boolean>(false); const [showInfo, setShowInfo] = React.useState<boolean>(false);
......
...@@ -8,6 +8,6 @@ export type FileMosaicInfoLayerProps = { ...@@ -8,6 +8,6 @@ export type FileMosaicInfoLayerProps = {
onCloseInfo?:Function; onCloseInfo?:Function;
localName: string; localName: string;
sizeFormatted: string; sizeFormatted?: string;
localType?: string; localType?: string;
} }
\ No newline at end of file
...@@ -14,7 +14,8 @@ const FileMosaicMainLayer: React.FC<FileMosaicMainLayerProps> = ( ...@@ -14,7 +14,8 @@ const FileMosaicMainLayer: React.FC<FileMosaicMainLayerProps> = (
props: FileMosaicMainLayerProps props: FileMosaicMainLayerProps
) => { ) => {
const { const {
darkMode,deleteIcon, darkMode,
deleteIcon,
downloadIcon, downloadIcon,
imageIcon, imageIcon,
infoIcon, infoIcon,
...@@ -52,7 +53,9 @@ const FileMosaicMainLayer: React.FC<FileMosaicMainLayerProps> = ( ...@@ -52,7 +53,9 @@ const FileMosaicMainLayer: React.FC<FileMosaicMainLayerProps> = (
uploadStatus={uploadStatus} uploadStatus={uploadStatus}
localization={localization} localization={localization}
/> />
{isActive && <FileMosaicSize sizeFormatted={sizeFormatted} />} {isActive && sizeFormatted && (
<FileMosaicSize sizeFormatted={sizeFormatted} />
)}
</div> </div>
<div className="file-mosaic-footer-right"> <div className="file-mosaic-footer-right">
{isActive && ( {isActive && (
......
...@@ -10,7 +10,7 @@ export interface FileMosaicMainLayerProps { ...@@ -10,7 +10,7 @@ export interface FileMosaicMainLayerProps {
uploadStatus?: UPLOADSTATUS; uploadStatus?: UPLOADSTATUS;
localization?: Localization; localization?: Localization;
sizeFormatted: string; sizeFormatted?: string;
imageIcon: boolean; imageIcon: boolean;
onSee: ((imageSource: string | undefined) => void) | undefined; onSee: ((imageSource: string | undefined) => void) | undefined;
......
...@@ -65,10 +65,9 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => { ...@@ -65,10 +65,9 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => {
onDoubleClick, onDoubleClick,
onClick, onClick,
onRightClick, onRightClick,
smartImgFit="orientation", smartImgFit = "orientation",
} = props; } = props;
//localizers //localizers
//ref for anchor download element //ref for anchor download element
const downloadRef = React.useRef<HTMLAnchorElement>(null); const downloadRef = React.useRef<HTMLAnchorElement>(null);
...@@ -116,10 +115,7 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => { ...@@ -116,10 +115,7 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => {
); );
//The size formatted and rounded in 2 decimals //The size formatted and rounded in 2 decimals
const sizeFormatted: string = localSize const sizeFormatted: string| undefined = fileSizeFormater(localSize);
? fileSizeFormater(localSize)
: "0 KB";
//alwaysActive //alwaysActive
const [showInfo, setShowInfo] = React.useState<boolean>(false); const [showInfo, setShowInfo] = React.useState<boolean>(false);
...@@ -210,7 +206,6 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => { ...@@ -210,7 +206,6 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => {
onAbort?.(id); onAbort?.(id);
}; };
if (isReady) if (isReady)
return ( return (
<div <div
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
* Gives a XX.XX format in Bytes KB, MB, GB or TB * Gives a XX.XX format in Bytes KB, MB, GB or TB
* @param fileSize file size to give format in Bytes * @param fileSize file size to give format in Bytes
*/ */
export const fileSizeFormater = (fileSize?: number): string => { export const fileSizeFormater = (fileSize?: number | false): string| undefined => {
let result = ""; let result = "";
if (!fileSize) { if (!fileSize) {
return 0 + " Bytes"; return undefined;
} }
if (fileSize < 1024) { if (fileSize < 1024) {
result = fileSize + " Bytes" result = fileSize + " Bytes"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment