mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 18:03:48 +00:00
* 01 share repo to group UI * 02 ADD_SHARED_REPO_INTO_GROUP * 03 share folder to groups * 04 system admin share repo to group * 05 remove old NoGroupMessage * 06 change API * change API * change select icons indents
97 lines
3.3 KiB
JavaScript
97 lines
3.3 KiB
JavaScript
import React, { Fragment } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Modal, ModalHeader, ModalBody, TabContent, TabPane, Nav, NavItem, NavLink } from 'reactstrap';
|
|
import { gettext } from '../../../utils/constants';
|
|
import SysAdminShareToUser from './sysadmin-share-to-user';
|
|
import SysAdminShareToGroup from './sysadmin-share-to-group';
|
|
import '../../../css/share-link-dialog.css';
|
|
|
|
const propTypes = {
|
|
itemName: PropTypes.string.isRequired,
|
|
itemPath: PropTypes.string.isRequired,
|
|
toggleDialog: PropTypes.func.isRequired,
|
|
repoID: PropTypes.string.isRequired,
|
|
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
|
repoEncrypted: PropTypes.bool,
|
|
userPerm: PropTypes.string,
|
|
enableDirPrivateShare: PropTypes.bool
|
|
};
|
|
|
|
class SysAdminShareDialog extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
activeTab: this.getInitialActiveTab(),
|
|
isRepoOwner: false
|
|
};
|
|
}
|
|
|
|
getInitialActiveTab = () => {
|
|
return 'shareToUser';
|
|
};
|
|
|
|
toggle = (tab) => {
|
|
if (this.state.activeTab !== tab) {
|
|
this.setState({ activeTab: tab });
|
|
}
|
|
};
|
|
|
|
renderDirContent = () => {
|
|
let activeTab = this.state.activeTab;
|
|
const { enableDirPrivateShare, isGroupOwnedRepo } = this.props;
|
|
return (
|
|
<Fragment>
|
|
<div className="share-dialog-side">
|
|
<Nav pills>
|
|
{enableDirPrivateShare &&
|
|
<Fragment>
|
|
<NavItem>
|
|
<NavLink className={activeTab === 'shareToUser' ? 'active' : ''} onClick={this.toggle.bind(this, 'shareToUser')}>
|
|
{gettext('Share to user')}
|
|
</NavLink>
|
|
</NavItem>
|
|
<NavItem>
|
|
<NavLink className={activeTab === 'shareToGroup' ? 'active' : ''} onClick={this.toggle.bind(this, 'shareToGroup')}>
|
|
{gettext('Share to group')}
|
|
</NavLink>
|
|
</NavItem>
|
|
</Fragment>
|
|
}
|
|
</Nav>
|
|
</div>
|
|
<div className="share-dialog-main">
|
|
<TabContent activeTab={this.state.activeTab}>
|
|
{enableDirPrivateShare &&
|
|
<Fragment>
|
|
<TabPane tabId="shareToUser">
|
|
<SysAdminShareToUser itemType={'library'} isGroupOwnedRepo={isGroupOwnedRepo} itemPath={this.props.itemPath} repoID={this.props.repoID} isRepoOwner={this.state.isRepoOwner}/>
|
|
</TabPane>
|
|
<TabPane tabId="shareToGroup">
|
|
<SysAdminShareToGroup itemType={'library'} isGroupOwnedRepo={isGroupOwnedRepo} itemPath={this.props.itemPath} repoID={this.props.repoID} isRepoOwner={this.state.isRepoOwner}/>
|
|
</TabPane>
|
|
</Fragment>
|
|
}
|
|
</TabContent>
|
|
</div>
|
|
</Fragment>
|
|
);
|
|
};
|
|
|
|
render() {
|
|
return (
|
|
<div>
|
|
<Modal isOpen={true} style={{ maxWidth: '800px' }} className="share-dialog" toggle={this.props.toggleDialog}>
|
|
<ModalHeader toggle={this.props.toggleDialog}>{gettext('Share')} <span className="op-target" title={this.props.itemName}>{this.props.itemName}</span></ModalHeader>
|
|
<ModalBody className="share-dialog-content">
|
|
{this.renderDirContent()}
|
|
</ModalBody>
|
|
</Modal>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
SysAdminShareDialog.propTypes = propTypes;
|
|
|
|
export default SysAdminShareDialog;
|