1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { DetailsData } from "./details-data";
7 import { CollectionFile, CollectionDirectory, CollectionFileType } from 'models/collection-file';
8 import { getIcon } from 'components/file-tree/file-tree-item';
9 import { DetailsAttribute } from 'components/details-attribute/details-attribute';
10 import { formatFileSize } from 'common/formatters';
11 import { FileThumbnail } from 'components/file-tree/file-thumbnail';
12 import isImage from 'is-image';
14 export class FileDetails extends DetailsData<CollectionFile | CollectionDirectory> {
16 getIcon(className?: string) {
17 const Icon = getIcon(this.item.type);
18 return <Icon className={className} />;
21 getDetails({showPreview}) {
22 const { item } = this;
23 return item.type === CollectionFileType.FILE
25 <DetailsAttribute label='Size' value={formatFileSize(item.size)} />
27 isImage(item.url) && showPreview && <>
28 <DetailsAttribute label='Preview' />
29 <FileThumbnail file={item} />