Skip to content

Commit

Permalink
[refactor] lib container view (#6766)
Browse files Browse the repository at this point in the history
* [refactor] lib container view

* optimize codes
  • Loading branch information
Michael18811380328 committed Sep 13, 2024
1 parent 3dae590 commit 453c84f
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 515 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DirentDetail from './dirent-details';
import ObjectUtils from '../../metadata/metadata-view/utils/object-utils';
import { MetadataContext } from '../../metadata';

const Index = React.memo(({ repoID, path, dirent, currentRepoInfo, repoTags, fileTags, onClose, onFileTagChanged }) => {
const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, repoTags, fileTags, onClose, onFileTagChanged }) => {

useEffect(() => {
// init context
Expand Down Expand Up @@ -45,7 +45,7 @@ const Index = React.memo(({ repoID, path, dirent, currentRepoInfo, repoTags, fil
return !isChanged;
});

Index.propTypes = {
DetailContainer.propTypes = {
repoID: PropTypes.string,
path: PropTypes.string,
dirent: PropTypes.object,
Expand All @@ -56,4 +56,4 @@ Index.propTypes = {
onFileTagChanged: PropTypes.func,
};

export default Index;
export default DetailContainer;
6 changes: 3 additions & 3 deletions frontend/src/components/dirent-detail/dirent-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ class DirentDetails extends React.Component {
{this.renderImage()}
{dirent && direntDetail && (
<div className="detail-content">
{dirent.type !== 'file' ? (
{dirent.type !== 'file' ?
<DirDetails
repoID={repoID}
repoInfo={this.props.currentRepoInfo}
dirent={dirent}
direntDetail={direntDetail}
path={this.props.dirent ? path + '/' + dirent.name : path}
/>
) : (
:
<FileDetails
repoID={repoID}
repoInfo={this.props.currentRepoInfo}
Expand All @@ -120,7 +120,7 @@ class DirentDetails extends React.Component {
fileTagList={dirent ? dirent.file_tags : fileTags}
onFileTagChanged={this.props.onFileTagChanged}
/>
)}
}
</div>
)}
</Body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { useEffect, useMemo, useState } from 'react';
import PropTypes from 'prop-types';
import { Formatter } from '@seafile/sf-metadata-ui-component';
import { Utils } from '../../../utils/utils';
import { gettext } from '../../../utils/constants';
import { seafileAPI } from '../../../utils/seafile-api';
import toaster from '../../toast';
import { Detail, Header, Body } from '../detail';
import Repo from '../../../models/repo';
import Loading from '../../loading';
import DetailItem from '../detail-item';
import { CellType } from '../../../metadata/metadata-view/_basic';
import { Utils } from '../../utils/utils';
import { gettext } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
import toaster from '../toast';
import { Detail, Header, Body } from './detail';
import Repo from '../../models/repo';
import Loading from '../loading';
import DetailItem from './detail-item';
import { CellType } from '../../metadata/metadata-view/_basic';

const LibDetail = React.memo(({ currentRepoInfo, onClose }) => {
const [isLoading, setLoading] = useState(true);
Expand All @@ -36,9 +36,9 @@ const LibDetail = React.memo(({ currentRepoInfo, onClose }) => {
<Detail>
<Header title={currentRepoInfo.repo_name} icon={smallIconUrl} onClose={onClose} />
<Body>
{isLoading ? (
{isLoading ?
<div className="w-100 h-100 d-flex algin-items-center justify-content-center"><Loading /></div>
) : (
:
<div className="detail-content">
<DetailItem field={filesField} value={repo.file_count || 0} className="sf-metadata-property-detail-formatter">
<Formatter field={filesField} value={repo.file_count || 0} />
Expand All @@ -62,7 +62,7 @@ const LibDetail = React.memo(({ currentRepoInfo, onClose }) => {
<Formatter field={mtimeField} value={repo.last_modified} />
</DetailItem>
</div>
)}
}
</Body>
</Detail>
);
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/toolbar/selected-dirents-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const propTypes = {
isGroupOwnedRepo: PropTypes.bool.isRequired,
};

class MultipleDirOperationToolbar extends React.Component {
class SelectedDirentsToolbar extends React.Component {

constructor(props) {
super(props);
Expand Down Expand Up @@ -471,6 +471,6 @@ class MultipleDirOperationToolbar extends React.Component {
}
}

MultipleDirOperationToolbar.propTypes = propTypes;
SelectedDirentsToolbar.propTypes = propTypes;

export default MultipleDirOperationToolbar;
export default SelectedDirentsToolbar;
6 changes: 6 additions & 0 deletions frontend/src/models/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Dirent from './dirent';
import FileTag from './file-tag';
import RepoTag from './repo-tag';
import RepoInfo from './repo-info';

export { Dirent, FileTag, RepoTag, RepoInfo };
Loading

0 comments on commit 453c84f

Please sign in to comment.