2019-02-27 11:44:22 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2019-05-05 07:18:54 +00:00
|
|
|
import { gettext } from '../../utils/constants';
|
2019-02-27 11:44:22 +00:00
|
|
|
import UserItem from './org-user-item';
|
|
|
|
|
|
|
|
const propTypes = {
|
2019-05-05 07:18:54 +00:00
|
|
|
initOrgUsersData: PropTypes.func.isRequired,
|
|
|
|
toggleDelete: PropTypes.func.isRequired,
|
|
|
|
orgUsers: PropTypes.array.isRequired,
|
|
|
|
page: PropTypes.number.isRequired,
|
|
|
|
pageNext: PropTypes.bool.isRequired,
|
2019-02-27 11:44:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class OrgUsersList extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
2020-04-27 06:46:41 +00:00
|
|
|
isItemFreezed: false
|
2019-02-27 11:44:22 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
onFreezedItem = () => {
|
|
|
|
this.setState({isItemFreezed: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
onUnfreezedItem = () => {
|
|
|
|
this.setState({isItemFreezed: false});
|
|
|
|
}
|
|
|
|
|
|
|
|
onChangePageNum = (e, num) => {
|
|
|
|
e.preventDefault();
|
2019-05-05 07:18:54 +00:00
|
|
|
let page = this.props.page;
|
2019-02-27 11:44:22 +00:00
|
|
|
|
|
|
|
if (num == 1) {
|
|
|
|
page = page + 1;
|
|
|
|
} else {
|
|
|
|
page = page - 1;
|
|
|
|
}
|
|
|
|
|
2019-05-05 07:18:54 +00:00
|
|
|
this.props.initOrgUsersData(page);
|
2019-02-27 11:44:22 +00:00
|
|
|
}
|
|
|
|
|
2020-04-27 06:46:41 +00:00
|
|
|
sortByQuotaUsage = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.sortByQuotaUsage();
|
|
|
|
}
|
|
|
|
|
2019-02-27 11:44:22 +00:00
|
|
|
render() {
|
2020-04-27 06:46:41 +00:00
|
|
|
const { sortBy, sortOrder } = this.props;
|
|
|
|
let sortIcon;
|
|
|
|
if (sortBy == '') {
|
|
|
|
// initial sort icon
|
|
|
|
sortIcon = <span className="fas fa-sort"></span>;
|
|
|
|
} else {
|
|
|
|
sortIcon = <span className={`fas ${sortOrder == 'asc' ? 'fa-caret-up' : 'fa-caret-down'}`}></span>;
|
|
|
|
}
|
2019-05-05 07:18:54 +00:00
|
|
|
let { orgUsers, page, pageNext } = this.props;
|
2019-02-27 11:44:22 +00:00
|
|
|
return (
|
|
|
|
<div className="cur-view-content">
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th width="30%">{gettext('Name')}</th>
|
|
|
|
<th width="15%">{gettext('Status')}</th>
|
2020-04-27 06:46:41 +00:00
|
|
|
<th width="20%">
|
|
|
|
<a className="d-inline-block table-sort-op" href="#" onClick={this.sortByQuotaUsage}>{gettext('Space Used')} {sortIcon}</a> / {gettext('Quota')}
|
|
|
|
</th>
|
|
|
|
<th width="25%">{gettext('Created At')} / {gettext('Last Login')}</th>
|
|
|
|
<th width="10%">{/*Operations*/}</th>
|
2019-02-27 11:44:22 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2020-09-24 08:53:55 +00:00
|
|
|
{orgUsers.map((item, index) => {
|
2019-03-13 07:16:05 +00:00
|
|
|
return (
|
|
|
|
<UserItem
|
2020-09-24 08:53:55 +00:00
|
|
|
key={index}
|
2019-03-13 07:16:05 +00:00
|
|
|
user={item}
|
2020-04-27 06:46:41 +00:00
|
|
|
currentTab="users"
|
2019-03-13 07:16:05 +00:00
|
|
|
isItemFreezed={this.state.isItemFreezed}
|
2019-05-05 07:18:54 +00:00
|
|
|
toggleDelete={this.props.toggleDelete}
|
2019-03-13 07:16:05 +00:00
|
|
|
onFreezedItem={this.onFreezedItem}
|
|
|
|
onUnfreezedItem={this.onUnfreezedItem}
|
|
|
|
/>
|
|
|
|
);})}
|
2019-02-27 11:44:22 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<div className="paginator">
|
2019-05-05 07:18:54 +00:00
|
|
|
{page !=1 && <a href="#" onClick={(e) => this.onChangePageNum(e, -1)}>{gettext('Previous')}</a>}
|
|
|
|
{(page != 1 && pageNext) && <span> | </span>}
|
|
|
|
{pageNext && <a href="#" onClick={(e) => this.onChangePageNum(e, 1)}>{gettext('Next')}</a>}
|
2019-02-27 11:44:22 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OrgUsersList.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default OrgUsersList;
|