-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task/DES-2924: Add metadata and move/copy/download buttons to preview…
… modal (#1334) * Add metadata and move/copy/download buttons to preview modal * formatting
- Loading branch information
Showing
8 changed files
with
200 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
client/modules/datafiles/src/DatafilesModal/PreviewModal/PreviewMetadata.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Collapse, Table, TableProps } from 'antd'; | ||
import React from 'react'; | ||
import styles from './PreviewModal.module.css'; | ||
import { TFileListing, useFileDetail } from '@client/hooks'; | ||
import { toBytes } from '../../FileListing/FileListing'; | ||
|
||
const tableColumns: TableProps['columns'] = [ | ||
{ dataIndex: 'key', render: (value) => <strong>{value}</strong>, width: 200 }, | ||
{ dataIndex: 'value' }, | ||
]; | ||
|
||
export const PreviewMetadata: React.FC<{ | ||
selectedFile: TFileListing; | ||
fileMeta: Record<string, string>; | ||
}> = ({ selectedFile, fileMeta }) => { | ||
const { data: fileListingMeta } = useFileDetail( | ||
'tapis', | ||
selectedFile.system, | ||
'private', | ||
selectedFile.path | ||
); | ||
|
||
const baseListingMeta = [ | ||
{ key: 'File Name', value: fileListingMeta?.name }, | ||
{ key: 'File Path', value: fileListingMeta?.path }, | ||
{ key: 'File Size', value: toBytes(fileListingMeta?.length) }, | ||
{ | ||
key: 'Last Modified', | ||
value: | ||
fileListingMeta?.lastModified && | ||
new Date(fileListingMeta.lastModified).toLocaleString(), | ||
}, | ||
]; | ||
|
||
const fullListingMeta = [ | ||
...baseListingMeta, | ||
...Object.keys(fileMeta).map((k) => ({ key: k, value: fileMeta[k] })), | ||
]; | ||
|
||
return ( | ||
<Collapse | ||
className={styles.metadataCollapse} | ||
expandIconPosition="end" | ||
items={[ | ||
{ | ||
label: ( | ||
<span style={{ fontStyle: 'italic', fontWeight: '600' }}> | ||
File Metadata | ||
</span> | ||
), | ||
children: ( | ||
<Table | ||
columns={tableColumns} | ||
dataSource={fullListingMeta} | ||
pagination={false} | ||
/> | ||
), | ||
}, | ||
]} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.