mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 02:42:47 +00:00
add libraryType to choose different create repo method
This commit is contained in:
@@ -35,8 +35,8 @@ class CreateRepoDialog extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit = () => {
|
handleSubmit = () => {
|
||||||
let isValidate = this.validateInputParams();
|
let isValid= this.validateInputParams();
|
||||||
if (isValidate) {
|
if (isValid) {
|
||||||
let repoName = this.state.repoName.trim();
|
let repoName = this.state.repoName.trim();
|
||||||
let password = this.state.encrypt ? this.state.password1 : '';
|
let password = this.state.encrypt ? this.state.password1 : '';
|
||||||
let repo = this.createRepo(repoName, password);
|
let repo = this.createRepo(repoName, password);
|
||||||
@@ -65,12 +65,11 @@ class CreateRepoDialog extends React.Component {
|
|||||||
errMessage = 'Name is required';
|
errMessage = 'Name is required';
|
||||||
this.setState({errMessage: errMessage});
|
this.setState({errMessage: errMessage});
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (repoName.indexOf('/') > -1) {
|
if (repoName.indexOf('/') > -1) {
|
||||||
errMessage = 'Name should not include \'/\'.';
|
errMessage = 'Name should not include \'/\'.';
|
||||||
this.setState({errMessage: errMessage});
|
this.setState({errMessage: errMessage});
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.state.encrypt) {
|
if (this.state.encrypt) {
|
||||||
let password1 = this.state.password1.trim();
|
let password1 = this.state.password1.trim();
|
||||||
@@ -108,22 +107,33 @@ class CreateRepoDialog extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createRepo = (repoName, password) => {
|
createRepo = (repoName, password) => {
|
||||||
|
let libraryType = this.props.libraryType;
|
||||||
let encrypt = password ? true : false;
|
let encrypt = password ? true : false;
|
||||||
let repo = {
|
let repo = null;
|
||||||
id: null,
|
if (libraryType === 'mine' || libraryType === 'public') {
|
||||||
name: repoName,
|
repo = {
|
||||||
desc: '',
|
id: null,
|
||||||
encrypted: encrypt,
|
name: repoName,
|
||||||
passwd: password,
|
desc: '',
|
||||||
passwd1: password,
|
encrypted: encrypt,
|
||||||
passwd2: password,
|
passwd: password,
|
||||||
mtime: 0,
|
passwd1: password,
|
||||||
mtime_relative: '',
|
passwd2: password,
|
||||||
owner: '-',
|
mtime: 0,
|
||||||
owner_nickname: '-',
|
mtime_relative: '',
|
||||||
permission: 'rw',
|
owner: '-',
|
||||||
storage_name: '-',
|
owner_nickname: '-',
|
||||||
};
|
permission: 'rw',
|
||||||
|
storage_name: '-',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (libraryType === 'group') {
|
||||||
|
repo = {
|
||||||
|
repo_name: repoName,
|
||||||
|
password: password,
|
||||||
|
permission: 'rw',
|
||||||
|
};
|
||||||
|
}
|
||||||
return repo;
|
return repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ import CreateRepoDialog from '../dialog/create-repo-dialog';
|
|||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
// isOwnLibrary: PropTypes.bool.isRequired,
|
// isOwnLibrary: PropTypes.bool.isRequired,
|
||||||
// libraryType: PropTypes.string.isRequired,
|
libraryType: PropTypes.string.isRequired,
|
||||||
onCreateRepo: PropTypes.func.isRequired,
|
onCreateRepo: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,12 +38,15 @@ class RepoViewToolbar extends React.Component {
|
|||||||
<i className="fas fa-plus-square op-icon"></i>
|
<i className="fas fa-plus-square op-icon"></i>
|
||||||
{gettext('New Library')}
|
{gettext('New Library')}
|
||||||
</button>
|
</button>
|
||||||
<button className="btn btn-secondary operation-item" title={gettext('More')} onClick={this.onShareClick}>{gettext('More')}</button>
|
{this.props.libraryType !== 'group' && (
|
||||||
|
<button className="btn btn-secondary operation-item" title={gettext('More')} onClick={this.onShareClick}>{gettext('More')}</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{this.state.isCreateRepoDialogShow && (
|
{this.state.isCreateRepoDialogShow && (
|
||||||
<ModalPortal>
|
<ModalPortal>
|
||||||
<CreateRepoDialog
|
<CreateRepoDialog
|
||||||
|
libraryType={this.props.libraryType}
|
||||||
onCreateRepo={this.onCreateRepo}
|
onCreateRepo={this.onCreateRepo}
|
||||||
onCreateToggle={this.onCreateToggle}
|
onCreateToggle={this.onCreateToggle}
|
||||||
/>
|
/>
|
||||||
|
@@ -284,7 +284,7 @@ class Group extends Component {
|
|||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div className="main-panel-north">
|
<div className="main-panel-north">
|
||||||
<RepoViewToolbar onShowSidePanel={this.props.onShowSidePanel} onCreateRepo={this.onCreateRepo} />
|
<RepoViewToolbar onShowSidePanel={this.props.onShowSidePanel} onCreateRepo={this.onCreateRepo} libraryType={'group'}/>
|
||||||
<CommonToolbar onSearchedClick={this.props.onSearchedClick} />
|
<CommonToolbar onSearchedClick={this.props.onSearchedClick} />
|
||||||
</div>
|
</div>
|
||||||
<div className="main-panel-center">
|
<div className="main-panel-center">
|
||||||
|
@@ -403,7 +403,7 @@ class MyLibraries extends Component {
|
|||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div className="main-panel-north">
|
<div className="main-panel-north">
|
||||||
<RepoViewToolbar onShowSidePanel={this.props.onShowSidePanel} onCreateRepo={this.onCreateRepo} />
|
<RepoViewToolbar onShowSidePanel={this.props.onShowSidePanel} onCreateRepo={this.onCreateRepo} libraryType={'mine'}/>
|
||||||
<CommonToolbar onSearchedClick={this.props.onSearchedClick} />
|
<CommonToolbar onSearchedClick={this.props.onSearchedClick} />
|
||||||
</div>
|
</div>
|
||||||
<div className="main-panel-center">
|
<div className="main-panel-center">
|
||||||
|
Reference in New Issue
Block a user