mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
add create department dialog
This commit is contained in:
@@ -4,18 +4,18 @@ import RepoPath from './repo-path';
|
|||||||
import RepoTool from './repo-tool';
|
import RepoTool from './repo-tool';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
currentTab: PropTypes.string.isRequired,
|
libraryType: PropTypes.string.isRequired,
|
||||||
currentGroup: PropTypes.object,
|
currentGroup: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
class CurGroupPath extends React.Component {
|
class CurGroupPath extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { currentTab, currentGroup } = this.props;
|
let { libraryType, currentGroup } = this.props;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<RepoPath currentTab={currentTab} currentGroup={currentGroup}/>
|
<RepoPath libraryType={libraryType} currentGroup={currentGroup}/>
|
||||||
<RepoTool currentTab={currentTab} currentGroup={currentGroup}/>
|
<RepoTool libraryType={libraryType} currentGroup={currentGroup}/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -4,14 +4,14 @@ import {gettext, siteRoot} from '../../utils/constants';
|
|||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
currentGroup: PropTypes.object, // for group
|
currentGroup: PropTypes.object, // for group
|
||||||
currentTab: PropTypes.string.isRequired, //for my-library, shared width me, shared whith all, groups
|
libraryType: PropTypes.string.isRequired, //for my-library, shared width me, shared whith all, groups
|
||||||
};
|
};
|
||||||
|
|
||||||
class RepoPath extends React.Component {
|
class RepoPath extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { currentTab, currentGroup } = this.props;
|
let { libraryType, currentGroup } = this.props;
|
||||||
if (currentTab === 'group' && currentGroup) {
|
if (libraryType === 'group' && currentGroup) {
|
||||||
return (
|
return (
|
||||||
<div className="path-container">
|
<div className="path-container">
|
||||||
<a href={`${siteRoot}groups/`}>{gettext("Groups")}</a>
|
<a href={`${siteRoot}groups/`}>{gettext("Groups")}</a>
|
||||||
@@ -26,7 +26,7 @@ class RepoPath extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="path-container">
|
<div className="path-container">
|
||||||
<span>{currentTab}</span>
|
<span>{libraryType}</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -4,13 +4,13 @@ import { gettext, username } from '../../utils/constants';
|
|||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
currentGroup: PropTypes.object, // for group
|
currentGroup: PropTypes.object, // for group
|
||||||
currentTab: PropTypes.string.isRequired, //for my-library, shared width me, shared whith all, groups
|
libraryType: PropTypes.string.isRequired, //for my-library, shared width me, shared whith all, groups
|
||||||
};
|
};
|
||||||
|
|
||||||
class RepoTool extends React.Component {
|
class RepoTool extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.currentTab === 'group' && this.props.currentGroup) {
|
if (this.props.libraryType === 'group' && this.props.currentGroup) {
|
||||||
let currentGroup = this.props.currentGroup;
|
let currentGroup = this.props.currentGroup;
|
||||||
let isShowSettingIcon = !(currentGroup.parent_group_id !== 0 && currentGroup.admins.indexOf(username) === -1);
|
let isShowSettingIcon = !(currentGroup.parent_group_id !== 0 && currentGroup.admins.indexOf(username) === -1);
|
||||||
return (
|
return (
|
||||||
|
106
frontend/src/components/dialog/create-department-repo-dialog.js
Normal file
106
frontend/src/components/dialog/create-department-repo-dialog.js
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Col, FormText } from 'reactstrap';
|
||||||
|
import { gettext, maxFileName } from '../../utils/constants';
|
||||||
|
|
||||||
|
const propTypes = {
|
||||||
|
onCreateRepo: PropTypes.func.isRequired,
|
||||||
|
onCreateToggle: PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
class CreateDepartmentRepoDialog extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
repoName: '',
|
||||||
|
errMessage: '',
|
||||||
|
};
|
||||||
|
this.newInput = React.createRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
handleChange = (e) => {
|
||||||
|
this.setState({
|
||||||
|
repoName: e.target.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleSubmit = () => {
|
||||||
|
let isValid = this.validateRepoName();
|
||||||
|
if (isValid) {
|
||||||
|
let repo = this.createRepo(this.state.repoName);
|
||||||
|
this.props.onCreateRepo(repo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
handleKeyPress = (e) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
this.handleSubmit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle = () => {
|
||||||
|
this.props.onCreateToggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount = () => {
|
||||||
|
this.newInput.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
validateRepoName = () => {
|
||||||
|
let errMessage = '';
|
||||||
|
let repoName = this.state.repoName.trim();
|
||||||
|
if (!repoName.length) {
|
||||||
|
errMessage = 'Name is required';
|
||||||
|
this.setState({errMessage: errMessage});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (repoName.indexOf('/') > -1) {
|
||||||
|
errMessage = 'Name should not include \'/\'.';
|
||||||
|
this.setState({errMessage: errMessage});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (repoName.length > maxFileName) {
|
||||||
|
errMessage = 'RepoName\'s length is must little than ' + maxFileName;
|
||||||
|
this.setState({errMessage: errMessage});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
createRepo = (repoName) => {
|
||||||
|
let repo = { repo_name: repoName };
|
||||||
|
return repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Modal isOpen={true} toggle={this.toggle}>
|
||||||
|
<ModalHeader toggle={this.toggle}>{gettext('New Department Library')}</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<Form>
|
||||||
|
<FormGroup>
|
||||||
|
<Label for="repo-name">{gettext('Name')}</Label>
|
||||||
|
<Input
|
||||||
|
id="repo-name"
|
||||||
|
onKeyPress={this.handleKeyPress}
|
||||||
|
innerRef={input => {this.newInput = input;}}
|
||||||
|
value={this.state.repoName}
|
||||||
|
onChange={this.handleChange}
|
||||||
|
maxLength={maxFileName}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
</Form>
|
||||||
|
<Label className="err-message">{gettext(this.state.errMessage)}</Label>
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button color="primary" onClick={this.handleSubmit}>{gettext('Submit')}</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateDepartmentRepoDialog.propTypes = propTypes;
|
||||||
|
|
||||||
|
export default CreateDepartmentRepoDialog;
|
@@ -9,8 +9,8 @@ const propTypes = {
|
|||||||
currentGroup: PropTypes.object,
|
currentGroup: PropTypes.object,
|
||||||
repo: PropTypes.object.isRequired,
|
repo: PropTypes.object.isRequired,
|
||||||
isItemFreezed: PropTypes.bool.isRequired,
|
isItemFreezed: PropTypes.bool.isRequired,
|
||||||
isShowRepoOwner: PropTypes.bool.isRequired,
|
|
||||||
onFreezedItem: PropTypes.func.isRequired,
|
onFreezedItem: PropTypes.func.isRequired,
|
||||||
|
onItemUnshared: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
class SharedRepoListItem extends React.Component {
|
class SharedRepoListItem extends React.Component {
|
||||||
@@ -34,6 +34,15 @@ class SharedRepoListItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMouseOver = () => {
|
||||||
|
if (!this.props.isItemFreezed) {
|
||||||
|
this.setState({
|
||||||
|
highlight: true,
|
||||||
|
isOperationShow: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMouseLeave = () => {
|
onMouseLeave = () => {
|
||||||
if (!this.props.isItemFreezed) {
|
if (!this.props.isItemFreezed) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -128,6 +137,7 @@ class SharedRepoListItem extends React.Component {
|
|||||||
|
|
||||||
onItemUnshared = () => {
|
onItemUnshared = () => {
|
||||||
// todo
|
// todo
|
||||||
|
this.props.onItemUnshared(this.props.repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
onItemDelete = () => {
|
onItemDelete = () => {
|
||||||
@@ -208,7 +218,7 @@ class SharedRepoListItem extends React.Component {
|
|||||||
// scene two: (share, unshare), (share), (unshare)
|
// scene two: (share, unshare), (share), (unshare)
|
||||||
let operations = this.generatorOperations();
|
let operations = this.generatorOperations();
|
||||||
const shareOperation = <a href="#" className="sf2-icon-share sf2-x op-icon" title={gettext("Share")} onClick={this.onItemShared}></a>;
|
const shareOperation = <a href="#" className="sf2-icon-share sf2-x op-icon" title={gettext("Share")} onClick={this.onItemShared}></a>;
|
||||||
const unshareOperation = <a href="#" className="sf2-icon-x3 sf2-x op-icon" title={gettext("Unshare")} onClick={this.onItemShared}></a>
|
const unshareOperation = <a href="#" className="sf2-icon-x3 sf2-x op-icon" title={gettext("Unshare")} onClick={this.onItemUnshared}></a>
|
||||||
const deleteOperation = <a href="#" className="sf2-icon-delete sf2-x op-icon" title={gettext('Delete')} onClick={this.onItemDelete}></a>;
|
const deleteOperation = <a href="#" className="sf2-icon-delete sf2-x op-icon" title={gettext('Delete')} onClick={this.onItemDelete}></a>;
|
||||||
|
|
||||||
if (this.isDeparementOnwerGroupMember) {
|
if (this.isDeparementOnwerGroupMember) {
|
||||||
@@ -255,28 +265,28 @@ class SharedRepoListItem extends React.Component {
|
|||||||
|
|
||||||
renderPCUI = () => {
|
renderPCUI = () => {
|
||||||
let { iconUrl, iconTitle, libPath } = this.getRepoComputeParams();
|
let { iconUrl, iconTitle, libPath } = this.getRepoComputeParams();
|
||||||
let { repo, isShowRepoOwner } = this.props;
|
let { repo } = this.props;
|
||||||
return (
|
return (
|
||||||
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
|
||||||
<td><img src={iconUrl} title={repo.iconTitle} alt={iconTitle} width="24" /></td>
|
<td><img src={iconUrl} title={repo.iconTitle} alt={iconTitle} width="24" /></td>
|
||||||
<td><a href={libPath}>{repo.repo_name}</a></td>
|
<td><a href={libPath}>{repo.repo_name}</a></td>
|
||||||
<td>{this.state.isOperationShow && this.generatorPCMenu()}</td>
|
<td>{this.state.isOperationShow && this.generatorPCMenu()}</td>
|
||||||
<td>{repo.size}</td>
|
<td>{repo.size}</td>
|
||||||
<td title={moment(repo.last_modified).format('llll')}>{moment(repo.last_modified).fromNow()}</td>
|
<td title={moment(repo.last_modified).format('llll')}>{moment(repo.last_modified).fromNow()}</td>
|
||||||
{isShowRepoOwner && <td title={repo.owner_contact_email}>{repo.owner_name}</td>}
|
<td title={repo.owner_contact_email}>{repo.owner_name}</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderMobileUI = () => {
|
renderMobileUI = () => {
|
||||||
let { iconUrl, iconTitle, libPath } = this.getRepoComputeParams();
|
let { iconUrl, iconTitle, libPath } = this.getRepoComputeParams();
|
||||||
let { repo, isShowRepoOwner } = this.props;
|
let { repo } = this.props;
|
||||||
return (
|
return (
|
||||||
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
|
||||||
<td><img src={iconUrl} title={iconTitle} alt={iconTitle}/></td>
|
<td><img src={iconUrl} title={iconTitle} alt={iconTitle}/></td>
|
||||||
<td>
|
<td>
|
||||||
<a href={libPath}>{repo.repo_name}</a><br />
|
<a href={libPath}>{repo.repo_name}</a><br />
|
||||||
{isShowRepoOwner ? <span className="item-meta-info" title={repo.owner_contact_email}>{repo.owner_name}</span> : null}
|
<span className="item-meta-info" title={repo.owner_contact_email}>{repo.owner_name}</span>
|
||||||
<span className="item-meta-info">{repo.size}</span>
|
<span className="item-meta-info">{repo.size}</span>
|
||||||
<span className="item-meta-info" title={moment(repo.last_modified).format('llll')}>{moment(repo.last_modified).fromNow()}</span>
|
<span className="item-meta-info" title={moment(repo.last_modified).format('llll')}>{moment(repo.last_modified).fromNow()}</span>
|
||||||
</td>
|
</td>
|
||||||
|
@@ -6,8 +6,8 @@ import ShareRepoListItem from './share-repo-list-item';
|
|||||||
const propTypes = {
|
const propTypes = {
|
||||||
currentGroup: PropTypes.object,
|
currentGroup: PropTypes.object,
|
||||||
repoList: PropTypes.array.isRequired,
|
repoList: PropTypes.array.isRequired,
|
||||||
isShowRepoOwner: PropTypes.bool.isRequired,
|
|
||||||
isShowTableThread: PropTypes.bool,
|
isShowTableThread: PropTypes.bool,
|
||||||
|
onItemUnshared: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShareRepoListView extends React.Component {
|
class ShareRepoListView extends React.Component {
|
||||||
@@ -33,10 +33,10 @@ class ShareRepoListView extends React.Component {
|
|||||||
<ShareRepoListItem
|
<ShareRepoListItem
|
||||||
key={repo.repo_id}
|
key={repo.repo_id}
|
||||||
repo={repo}
|
repo={repo}
|
||||||
isShowRepoOwner={this.props.isShowRepoOwner}
|
|
||||||
currentGroup={this.props.currentGroup}
|
currentGroup={this.props.currentGroup}
|
||||||
isItemFreezed={this.state.isItemFreezed}
|
isItemFreezed={this.state.isItemFreezed}
|
||||||
onFreezedItem={this.onFreezedItem}
|
onFreezedItem={this.onFreezedItem}
|
||||||
|
onItemUnshared={this.props.onItemUnshared}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -45,7 +45,6 @@ class ShareRepoListView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderPCUI = () => {
|
renderPCUI = () => {
|
||||||
let isShowRepoOwner = this.props.isShowRepoOwner;
|
|
||||||
let isShowTableThread = this.props.isShowTableThread !== undefined ? this.props.isShowTableThread : true;
|
let isShowTableThread = this.props.isShowTableThread !== undefined ? this.props.isShowTableThread : true;
|
||||||
return (
|
return (
|
||||||
<table>
|
<table>
|
||||||
@@ -56,11 +55,11 @@ class ShareRepoListView extends React.Component {
|
|||||||
<a className="table-sort-op by-name" href="#">{/*TODO: sort*/}<span className="sort-icon icon-caret-down hide"></span></a>
|
<a className="table-sort-op by-name" href="#">{/*TODO: sort*/}<span className="sort-icon icon-caret-down hide"></span></a>
|
||||||
</th>
|
</th>
|
||||||
<th width="12%"><span className="sr-only">{gettext("Actions")}</span></th>
|
<th width="12%"><span className="sr-only">{gettext("Actions")}</span></th>
|
||||||
<th width={isShowRepoOwner ? '14%' : '22%'}>{gettext("Size")}</th>
|
<th width={'14%'}>{gettext("Size")}</th>
|
||||||
<th width={isShowRepoOwner ? '14%' : '22%'}>{gettext("Last Update")}
|
<th width={'14%'}>{gettext("Last Update")}
|
||||||
<a className="table-sort-op by-time" href="#">{/*TODO: sort*/}<span className="sort-icon icon-caret-up"></span></a>
|
<a className="table-sort-op by-time" href="#">{/*TODO: sort*/}<span className="sort-icon icon-caret-up"></span></a>
|
||||||
</th>
|
</th>
|
||||||
{isShowRepoOwner && <th width="16%">{gettext("Owner")}</th>}
|
<th width="16%">{gettext("Owner")}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -71,7 +70,6 @@ class ShareRepoListView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderMobileUI = () => {
|
renderMobileUI = () => {
|
||||||
let isShowRepoOwner = this.props.isShowRepoOwner;
|
|
||||||
let isShowTableThread = this.props.isShowTableThread !== undefined ? this.props.isShowTableThread : true;
|
let isShowTableThread = this.props.isShowTableThread !== undefined ? this.props.isShowTableThread : true;
|
||||||
return (
|
return (
|
||||||
<table>
|
<table>
|
||||||
@@ -79,15 +77,11 @@ class ShareRepoListView extends React.Component {
|
|||||||
<tr>
|
<tr>
|
||||||
<th width="18%"><span className="sr-only">{gettext("Library Type")}</span></th>
|
<th width="18%"><span className="sr-only">{gettext("Library Type")}</span></th>
|
||||||
<th width="68%">
|
<th width="68%">
|
||||||
{isShowRepoOwner ? (
|
|
||||||
<Fragment>
|
<Fragment>
|
||||||
{gettext("Sort:")} {/* TODO: sort */}
|
{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("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>
|
{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>
|
</Fragment>
|
||||||
) :
|
|
||||||
(gettext('name'))
|
|
||||||
}
|
|
||||||
</th>
|
</th>
|
||||||
<th width="14%"><span className="sr-only">{gettext("Actions")}</span></th>
|
<th width="14%"><span className="sr-only">{gettext("Actions")}</span></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -3,11 +3,13 @@ import PropTypes from 'prop-types';
|
|||||||
import { gettext, username, loginUrl } from '../../utils/constants';
|
import { gettext, username, loginUrl } from '../../utils/constants';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import Loading from '../../components/loading';
|
import Loading from '../../components/loading';
|
||||||
|
import ModalPortal from '../../components/modal-portal';
|
||||||
import Group from '../../models/group';
|
import Group from '../../models/group';
|
||||||
import RepoInfo from '../../models/repoInfo';
|
import RepoInfo from '../../models/repoInfo';
|
||||||
import CommonToolbar from '../../components/toolbar/common-toolbar';
|
import CommonToolbar from '../../components/toolbar/common-toolbar';
|
||||||
import RepoViewToolbar from '../../components/toolbar/repo-view-toobar';
|
|
||||||
import CurRepoPath from '../../components/cur-repo-path/';
|
import CurRepoPath from '../../components/cur-repo-path/';
|
||||||
|
import CreateRepoDialog from '../../components/dialog/create-repo-dialog';
|
||||||
|
import CreateDepartmentRepoDialog from '../../components/dialog/create-department-repo-dialog';
|
||||||
import ShareRepoListView from '../../components/share-repo-list-view/share-repo-list-view';
|
import ShareRepoListView from '../../components/share-repo-list-view/share-repo-list-view';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
@@ -15,6 +17,8 @@ const propTypes = {
|
|||||||
onSearchedClick: PropTypes.func.isRequired,
|
onSearchedClick: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const DEPARETMENT_GROUP_ONWER_NAME = 'system admin';
|
||||||
|
|
||||||
class GroupView extends React.Component {
|
class GroupView extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -26,8 +30,9 @@ class GroupView extends React.Component {
|
|||||||
currentGroup: null,
|
currentGroup: null,
|
||||||
isStaff: false,
|
isStaff: false,
|
||||||
repoList: [],
|
repoList: [],
|
||||||
currentTab: 'group',
|
libraryType: 'group',
|
||||||
isShowRepoOwner: true,
|
isCreateRepoDialogShow: false,
|
||||||
|
isDepartmentGroup: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,10 +52,12 @@ class GroupView extends React.Component {
|
|||||||
let currentGroup = new Group(res.data);
|
let currentGroup = new Group(res.data);
|
||||||
let emptyTip = this.getEmptyTip(currentGroup);
|
let emptyTip = this.getEmptyTip(currentGroup);
|
||||||
let isStaff = currentGroup.admins.indexOf(username) > -1; //for item operations
|
let isStaff = currentGroup.admins.indexOf(username) > -1; //for item operations
|
||||||
|
let isDepartmentGroup = currentGroup.owner === DEPARETMENT_GROUP_ONWER_NAME;
|
||||||
this.setState({
|
this.setState({
|
||||||
emptyTip: emptyTip,
|
emptyTip: emptyTip,
|
||||||
currentGroup: currentGroup,
|
currentGroup: currentGroup,
|
||||||
isStaff: isStaff,
|
isStaff: isStaff,
|
||||||
|
isDepartmentGroup: isDepartmentGroup,
|
||||||
});
|
});
|
||||||
this.loadRepos(groupID);
|
this.loadRepos(groupID);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@@ -141,6 +148,10 @@ class GroupView extends React.Component {
|
|||||||
return emptyTip;
|
return emptyTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCreateRepoToggle = () => {
|
||||||
|
this.setState({isCreateRepoDialogShow: !this.state.isCreateRepoDialogShow});
|
||||||
|
}
|
||||||
|
|
||||||
onCreateRepo = (repo) => {
|
onCreateRepo = (repo) => {
|
||||||
let groupId = this.props.groupID;
|
let groupId = this.props.groupID;
|
||||||
seafileAPI.createGroupRepo(groupId, repo).then(res => {
|
seafileAPI.createGroupRepo(groupId, repo).then(res => {
|
||||||
@@ -150,6 +161,7 @@ class GroupView extends React.Component {
|
|||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
//todo
|
//todo
|
||||||
});
|
});
|
||||||
|
this.onCreateRepoToggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
addRepoItem = (repo) => {
|
addRepoItem = (repo) => {
|
||||||
@@ -158,22 +170,36 @@ class GroupView extends React.Component {
|
|||||||
return newRepoList;
|
return newRepoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onItemUnshared = (repo) => {
|
||||||
|
let group = this.state.currentGroup;
|
||||||
|
seafileAPI.unshareRepo(repo.repo_id, {share_type: 'group', group_id: group.id}).then(() => {
|
||||||
|
let repoList = this.state.repoList.filter(item => {
|
||||||
|
return item.repo_id !== repo.repo_id;
|
||||||
|
});
|
||||||
|
this.setState({repoList: repoList});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { errMessage, emptyTip } = this.state;
|
let { errMessage, emptyTip } = this.state;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div className="main-panel-north">
|
<div className="main-panel-north">
|
||||||
<RepoViewToolbar
|
<div className="cur-view-toolbar border-left-show">
|
||||||
libraryType={this.state.currentTab}
|
<span className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none" title="Side Nav Menu" onClick={this.props.onShowSidePanel}></span>
|
||||||
onShowSidePanel={this.props.onShowSidePanel}
|
<div className="operation">
|
||||||
onCreateRepo={this.onCreateRepo}
|
<button className="btn btn-secondary operation-item" title={gettext('New Library')} onClick={this.onCreateRepoToggle}>
|
||||||
/>
|
<i className="fas fa-plus-square op-icon"></i>
|
||||||
|
{gettext('New Library')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<CommonToolbar onSearchedClick={this.props.onSearchedClick} />
|
<CommonToolbar onSearchedClick={this.props.onSearchedClick} />
|
||||||
</div>
|
</div>
|
||||||
<div className="main-panel-center">
|
<div className="main-panel-center">
|
||||||
<div className="cur-view-container">
|
<div className="cur-view-container">
|
||||||
<div className="cur-view-path">
|
<div className="cur-view-path">
|
||||||
<CurRepoPath currentTab={this.state.currentTab} currentGroup={this.state.currentGroup}/>
|
<CurRepoPath libraryType={this.state.libraryType} currentGroup={this.state.currentGroup}/>
|
||||||
</div>
|
</div>
|
||||||
<div className="cur-view-content">
|
<div className="cur-view-content">
|
||||||
{this.state.isLoading && <Loading />}
|
{this.state.isLoading && <Loading />}
|
||||||
@@ -183,12 +209,29 @@ class GroupView extends React.Component {
|
|||||||
<ShareRepoListView
|
<ShareRepoListView
|
||||||
repoList={this.state.repoList}
|
repoList={this.state.repoList}
|
||||||
currentGroup={this.state.currentGroup}
|
currentGroup={this.state.currentGroup}
|
||||||
isShowRepoOwner={this.state.isShowRepoOwner}
|
onItemUnshared={this.onItemUnshared}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{this.state.isCreateRepoDialogShow && !this.state.isDepartmentGroup && (
|
||||||
|
<ModalPortal>
|
||||||
|
<CreateRepoDialog
|
||||||
|
hasPermission={this.hasPermission}
|
||||||
|
libraryType={this.state.libraryType}
|
||||||
|
onCreateToggle={this.onCreateRepoToggle}
|
||||||
|
onCreateRepo={this.onCreateRepo}
|
||||||
|
/>
|
||||||
|
</ModalPortal>
|
||||||
|
)}
|
||||||
|
{this.state.isCreateRepoDialogShow && this.state.isDepartmentGroup &&
|
||||||
|
<CreateDepartmentRepoDialog
|
||||||
|
isAdmin={this.state.isAdmin}
|
||||||
|
onCreateToggle={this.onCreateRepoToggle}
|
||||||
|
onCreateRepo={this.onCreateRepo}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@ export const storages = window.app.pageOptions.storages; // storage backends
|
|||||||
export const enableRepoSnapshotLabel = window.app.pageOptions.enableRepoSnapshotLabel;
|
export const enableRepoSnapshotLabel = window.app.pageOptions.enableRepoSnapshotLabel;
|
||||||
export const shareLinkExpireDaysMin = window.app.pageOptions.shareLinkExpireDaysMin;
|
export const shareLinkExpireDaysMin = window.app.pageOptions.shareLinkExpireDaysMin;
|
||||||
export const shareLinkExpireDaysMax = window.app.pageOptions.shareLinkExpireDaysMax;
|
export const shareLinkExpireDaysMax = window.app.pageOptions.shareLinkExpireDaysMax;
|
||||||
|
export const maxFileName = window.app.pageOptions.maxFileName;
|
||||||
|
|
||||||
// wiki
|
// wiki
|
||||||
export const slug = window.wiki ? window.wiki.config.slug : '';
|
export const slug = window.wiki ? window.wiki.config.slug : '';
|
||||||
|
@@ -61,6 +61,7 @@
|
|||||||
enableRepoSnapshotLabel: {% if enable_repo_snapshot_label %} true {% else %} false {% endif %},
|
enableRepoSnapshotLabel: {% if enable_repo_snapshot_label %} true {% else %} false {% endif %},
|
||||||
shareLinkExpireDaysMin: "{{ share_link_expire_days_min }}",
|
shareLinkExpireDaysMin: "{{ share_link_expire_days_min }}",
|
||||||
shareLinkExpireDaysMax: "{{ share_link_expire_days_max }}",
|
shareLinkExpireDaysMax: "{{ share_link_expire_days_max }}",
|
||||||
|
maxFileName: "{{ max_file_name }}"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user