1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-22 19:02:21 +00:00
seahub/frontend/src/components/share-repo-list-view/share-repo-list-view.js

114 lines
3.6 KiB
JavaScript
Raw Normal View History

2018-12-08 08:35:00 +00:00
import React, {Fragment} from 'react';
2018-12-08 00:37:18 +00:00
import PropTypes from 'prop-types';
import { gettext } from '../../utils/constants';
2018-12-10 03:52:44 +00:00
import ShareRepoListItem from './share-repo-list-item';
2018-12-08 00:37:18 +00:00
const propTypes = {
2018-12-08 08:35:00 +00:00
currentGroup: PropTypes.object,
2018-12-08 00:37:18 +00:00
repoList: PropTypes.array.isRequired,
2018-12-08 08:35:00 +00:00
isShowRepoOwner: PropTypes.bool.isRequired,
2018-12-10 03:52:44 +00:00
isShowTableThread: PropTypes.bool,
2018-12-08 00:37:18 +00:00
};
2018-12-10 03:52:44 +00:00
class ShareRepoListView extends React.Component {
2018-12-08 00:37:18 +00:00
constructor(props) {
super(props);
this.state = {
isItemFreezed: false,
};
}
2018-12-10 01:01:05 +00:00
onFreezedItem = () => {
this.setState({
isItemFreezed: !this.state.isItemFreezed,
});
}
renderRepoListView = () => {
return (
<Fragment>
{this.props.repoList.map(repo => {
return (
2018-12-10 03:52:44 +00:00
<ShareRepoListItem
2018-12-10 01:01:05 +00:00
key={repo.repo_id}
repo={repo}
isShowRepoOwner={this.props.isShowRepoOwner}
currentGroup={this.props.currentGroup}
isItemFreezed={this.state.isItemFreezed}
onFreezedItem={this.onFreezedItem}
/>
);
})}
</Fragment>
);
}
2018-12-08 00:37:18 +00:00
renderPCUI = () => {
2018-12-08 08:35:00 +00:00
let isShowRepoOwner = this.props.isShowRepoOwner;
2018-12-10 03:52:44 +00:00
let isShowTableThread = this.props.isShowTableThread !== undefined ? this.props.isShowTableThread : true;
2018-12-08 00:37:18 +00:00
return (
<table>
2018-12-10 03:52:44 +00:00
<thead className={isShowTableThread ? '' : 'vh'}>
2018-12-08 00:37:18 +00:00
<tr>
<th width="4%"><span className="sr-only">{gettext("Library Type")}</span></th>
2018-12-08 08:35:00 +00:00
<th width="40%">{gettext("Name")}
2018-12-08 00:37:18 +00:00
<a className="table-sort-op by-name" href="#">{/*TODO: sort*/}<span className="sort-icon icon-caret-down hide"></span></a>
</th>
2018-12-08 08:35:00 +00:00
<th width="12%"><span className="sr-only">{gettext("Actions")}</span></th>
<th width={isShowRepoOwner ? '14%' : '22%'}>{gettext("Size")}</th>
<th width={isShowRepoOwner ? '14%' : '22%'}>{gettext("Last Update")}
2018-12-08 00:37:18 +00:00
<a className="table-sort-op by-time" href="#">{/*TODO: sort*/}<span className="sort-icon icon-caret-up"></span></a>
</th>
2018-12-08 08:35:00 +00:00
{isShowRepoOwner && <th width="16%">{gettext("Owner")}</th>}
2018-12-08 00:37:18 +00:00
</tr>
</thead>
<tbody>
2018-12-10 01:01:05 +00:00
{this.renderRepoListView()}
2018-12-08 00:37:18 +00:00
</tbody>
</table>
);
}
renderMobileUI = () => {
2018-12-08 08:35:00 +00:00
let isShowRepoOwner = this.props.isShowRepoOwner;
2018-12-10 03:52:44 +00:00
let isShowTableThread = this.props.isShowTableThread !== undefined ? this.props.isShowTableThread : true;
2018-12-08 00:37:18 +00:00
return (
<table>
2018-12-10 03:52:44 +00:00
<thead className={isShowTableThread ? '' : 'vh'}>
2018-12-08 00:37:18 +00:00
<tr>
<th width="18%"><span className="sr-only">{gettext("Library Type")}</span></th>
<th width="68%">
2018-12-08 08:35:00 +00:00
{isShowRepoOwner ? (
<Fragment>
{gettext("Sort:")} {/* TODO: sort */}
{gettext("name")}<a className="table-sort-op mobile-table-sort-op by-name" href="#"> <span className="sort-icon icon-caret-down hide"></span></a>
{gettext("last update")}<a className="table-sort-op mobile-table-sort-op by-time" href="#"> <span className="sort-icon icon-caret-up"></span></a>
</Fragment>
) :
(gettext('name'))
}
2018-12-08 00:37:18 +00:00
</th>
<th width="14%"><span className="sr-only">{gettext("Actions")}</span></th>
</tr>
</thead>
<tbody>
2018-12-10 01:01:05 +00:00
{this.renderRepoListView()}
2018-12-08 00:37:18 +00:00
</tbody>
</table>
);
}
render() {
if (window.innerWidth >= 768) {
return this.renderPCUI();
} else {
return this.renderMobileUI();
}
}
}
2018-12-10 03:52:44 +00:00
ShareRepoListView.propTypes = propTypes;
2018-12-08 00:37:18 +00:00
2018-12-10 03:52:44 +00:00
export default ShareRepoListView;