mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 23:15:43 +01:00
Show size for empty files, but not for directories
This commit is contained in:
@@ -6,9 +6,9 @@ type Props = {
|
||||
};
|
||||
|
||||
class FileSize extends React.Component<Props> {
|
||||
static format(bytes) {
|
||||
static format(bytes: number) {
|
||||
if (!bytes) {
|
||||
return "";
|
||||
return "0 B";
|
||||
}
|
||||
|
||||
const units = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import FileSize from "./FileSize";
|
||||
|
||||
it("should format bytes", () => {
|
||||
expect(FileSize.format(160)).toBe("160.00 B");
|
||||
expect(FileSize.format(0)).toBe("0 B");
|
||||
expect(FileSize.format(160)).toBe("160 B");
|
||||
expect(FileSize.format(6304)).toBe("6.16 K");
|
||||
expect(FileSize.format(28792588)).toBe("27.46 M");
|
||||
expect(FileSize.format(1369510189)).toBe("1.28 G");
|
||||
|
||||
@@ -62,13 +62,13 @@ class FileTreeLeaf extends React.Component<Props> {
|
||||
render() {
|
||||
const { file, classes } = this.props;
|
||||
|
||||
const fileSize = file.directory ? "" : <FileSize bytes={file.length} />;
|
||||
|
||||
return (
|
||||
<tr>
|
||||
<td className={classes.iconColumn}>{this.createFileIcon(file)}</td>
|
||||
<td>{this.createFileName(file)}</td>
|
||||
<td>
|
||||
<FileSize bytes={file.length} />
|
||||
</td>
|
||||
<td>{fileSize}</td>
|
||||
<td>
|
||||
<DateFromNow date={file.lastModified} />
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user