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

110 lines
3.5 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 10:19:03 +00:00
import SharedRepoListItem from './shared-repo-list-item';
2018-12-08 00:37:18 +00:00
const propTypes = {
2018-12-21 07:40:59 +00:00
libraryType: PropTypes.string,
2018-12-08 08:35:00 +00:00
currentGroup: PropTypes.object,
2018-12-10 03:52:44 +00:00
isShowTableThread: PropTypes.bool,
2018-12-21 07:40:59 +00:00
repoList: PropTypes.array.isRequired,
2018-12-10 10:37:59 +00:00
onItemUnshare: PropTypes.func.isRequired,
2018-12-16 03:17:17 +00:00
onItemDelete: PropTypes.func.isRequired,
2018-12-08 00:37:18 +00:00
};
2018-12-10 10:19:03 +00:00
class SharedRepoListView 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 10:19:03 +00:00
<SharedRepoListItem
2018-12-10 01:01:05 +00:00
key={repo.repo_id}
repo={repo}
2018-12-21 07:40:59 +00:00
libraryType={this.props.libraryType}
2018-12-10 01:01:05 +00:00
currentGroup={this.props.currentGroup}
isItemFreezed={this.state.isItemFreezed}
onFreezedItem={this.onFreezedItem}
2018-12-10 10:37:59 +00:00
onItemUnshare={this.props.onItemUnshare}
2018-12-16 03:17:17 +00:00
onItemDelete={this.props.onItemDelete}
2018-12-10 01:01:05 +00:00
/>
);
})}
</Fragment>
);
}
2018-12-08 00:37:18 +00:00
renderPCUI = () => {
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 (
2018-12-29 08:16:20 +00:00
<table className={isShowTableThread ? '' : 'table-thead-hidden'}>
<thead>
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>
2018-12-10 09:59:26 +00:00
<th width={'14%'}>{gettext("Size")}</th>
<th width={'14%'}>{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-10 09:59:26 +00:00
<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-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 (
2018-12-29 08:16:20 +00:00
<table className={isShowTableThread ? '' : 'table-thead-hidden'}>
<thead>
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-10 10:12:46 +00:00
{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>
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 10:19:03 +00:00
SharedRepoListView.propTypes = propTypes;
2018-12-08 00:37:18 +00:00
2018-12-10 10:19:03 +00:00
export default SharedRepoListView;