1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-23 12:27:48 +00:00
Files
seahub/frontend/src/components/wiki-list-view/wiki-list-view.js
2018-12-11 14:05:10 +08:00

70 lines
1.8 KiB
JavaScript

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { gettext } from '../../utils/constants';
import WikiListItem from './wiki-list-item';
const propTypes = {
data: PropTypes.object.isRequired,
renameWiki: PropTypes.func.isRequired,
deleteWiki: PropTypes.func.isRequired,
};
class WikiListView extends Component {
constructor(props) {
super(props);
this.state = {
isItemFreezed: false,
};
}
onFreezedItem = () => {
this.setState({isItemFreezed: true});
}
onUnfreezedItem = () => {
this.setState({isItemFreezed: false});
}
render() {
let { loading, errorMsg, wikis } = this.props.data;
if (loading) {
return <span className="loading-icon loading-tip"></span>;
} else if (errorMsg) {
return <p className="error text-center">{errorMsg}</p>;
} else {
return (
<table className="wiki-list-table">
<thead>
<tr>
<th width="50%">{gettext('Name')}</th>
<th width="20%">{gettext('Owner')}</th>
<th width="20%">{gettext('Last Update')}</th>
<th width="10%">{/* operation */}</th>
</tr>
</thead>
<tbody>
{wikis.map((wiki, index) => {
return (
<WikiListItem
key={index}
wiki={wiki}
renameWiki={this.props.renameWiki}
deleteWiki={this.props.deleteWiki}
isItemFreezed={this.state.isItemFreezed}
onFreezedItem={this.onFreezedItem}
onUnfreezedItem={this.onUnfreezedItem}
/>
);
})}
</tbody>
</table>
);
}
}
}
WikiListView.propTypes = propTypes;
export default WikiListView;