-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
杨国璇
authored and
杨国璇
committed
Aug 5, 2024
1 parent
cfacf6d
commit a6f9060
Showing
15 changed files
with
153 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,5 @@ | |
} | ||
|
||
.detail-container .empty-tip-text { | ||
color: #666 | ||
color: #666; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import SeafileMetadata from './metadata-view'; | ||
import MetadataStatusManagementDialog from './metadata-status-manage-dialog'; | ||
import MetadataTreeView from './metadata-tree-view'; | ||
import MetadataDetails from './metadata-details'; | ||
|
||
export { | ||
SeafileMetadata, | ||
MetadataStatusManagementDialog, | ||
MetadataTreeView, | ||
MetadataDetails, | ||
}; |
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,22 @@ | ||
import { PRIVATE_COLUMN_KEY } from '../metadata-view/_basic'; | ||
|
||
export const NOT_DISPLAY_COLUMN_KEYS = [ | ||
PRIVATE_COLUMN_KEY.ID, | ||
PRIVATE_COLUMN_KEY.CTIME, | ||
PRIVATE_COLUMN_KEY.MTIME, | ||
PRIVATE_COLUMN_KEY.CREATOR, | ||
PRIVATE_COLUMN_KEY.LAST_MODIFIER, | ||
PRIVATE_COLUMN_KEY.FILE_CREATOR, | ||
PRIVATE_COLUMN_KEY.FILE_CTIME, | ||
PRIVATE_COLUMN_KEY.FILE_MODIFIER, | ||
PRIVATE_COLUMN_KEY.FILE_MTIME, | ||
PRIVATE_COLUMN_KEY.PARENT_DIR, | ||
PRIVATE_COLUMN_KEY.FILE_NAME, | ||
PRIVATE_COLUMN_KEY.IS_DIR, | ||
PRIVATE_COLUMN_KEY.FILE_TYPE, | ||
PRIVATE_COLUMN_KEY.LOCATION, | ||
]; | ||
|
||
export { | ||
PRIVATE_COLUMN_KEY, | ||
}; |
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,56 @@ | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Utils } from '../../utils/utils'; | ||
import metadataAPI from '../api'; | ||
import Column from '../metadata-view/model/metadata/column'; | ||
import { normalizeFields, getCellValueByColumn } from './utils'; | ||
import toaster from '../../components/toast'; | ||
import DetailItem from '../../components/dirent-detail/detail-item'; | ||
|
||
const MetadataDetails = ({ repoID, filePath, direntType, direntDetail, emptyTip }) => { | ||
const [isLoading, setLoading] = useState(true); | ||
const [metadata, setMetadata] = useState({ record: {}, fields: [] }); | ||
const isEmptyFile = useMemo(() => { | ||
if (direntType === 'dir') return false; | ||
const direntDetailId = direntDetail?.id || ''; | ||
return direntDetailId === '0'.repeat(direntDetailId.length); | ||
}, [direntDetail, direntType]); | ||
|
||
useEffect(() => { | ||
setLoading(true); | ||
const dirName = Utils.getDirName(filePath); | ||
const fileName = Utils.getFileName(filePath); | ||
let parentDir = direntType === 'file' ? dirName : dirName.slice(0, dirName.length - fileName.length - 1); | ||
if (!parentDir.startsWith('/')) { | ||
parentDir = '/' + parentDir; | ||
} | ||
metadataAPI.getMetadataRecordInfo(repoID, parentDir, fileName).then(res => { | ||
const { results, metadata } = res.data; | ||
const record = Array.isArray(results) && results.length > 0 ? results[0] : {}; | ||
const fields = normalizeFields(metadata).map(field => new Column(field)); | ||
setMetadata({ record, fields }); | ||
setLoading(false); | ||
}).catch(error => { | ||
const errorMsg = Utils.getErrorMsg(error); | ||
toaster.danger(errorMsg); | ||
setLoading(false); | ||
}); | ||
}, [repoID, filePath, direntType]); | ||
|
||
if (isLoading) return null; | ||
const { fields, record } = metadata; | ||
if (!record._id) return null; | ||
return fields.map(field => { | ||
const value = getCellValueByColumn(record, field); | ||
return (<DetailItem key={field.key} field={field} value={value} emptyTip={emptyTip}/>); | ||
}); | ||
}; | ||
|
||
MetadataDetails.propTypes = { | ||
repoID: PropTypes.string, | ||
filePath: PropTypes.string, | ||
direntType: PropTypes.string, | ||
direntDetail: PropTypes.object, | ||
}; | ||
|
||
export default MetadataDetails; |
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,25 @@ | ||
import { getColumnType } from '../metadata-view/utils/column-utils'; | ||
import { getCellValueByColumn } from '../metadata-view/_basic'; | ||
import { NOT_DISPLAY_COLUMN_KEYS } from './constants'; | ||
|
||
export const normalizeFields = (fields) => { | ||
if (!Array.isArray(fields) || fields.length === 0) return []; | ||
const validFields = fields.map((field) => { | ||
const { type, key, ...params } = field; | ||
return { | ||
...params, | ||
key, | ||
type: getColumnType(key, type), | ||
width: 200, | ||
}; | ||
}).filter(field => !NOT_DISPLAY_COLUMN_KEYS.includes(field.key)); | ||
let displayFields = []; | ||
validFields.forEach(field => { | ||
displayFields.push(field); | ||
}); | ||
return displayFields; | ||
}; | ||
|
||
export { | ||
getCellValueByColumn, | ||
}; |
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