1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

Merge branch '7.1'

Conflicts:
	frontend/src/pages/search/advanced-search.js
This commit is contained in:
llj
2020-07-22 10:59:53 +08:00
58 changed files with 743 additions and 690 deletions

View File

@@ -14,19 +14,46 @@ const propsTypes = {
onChange: PropTypes.func.isRequired
};
const FORMAT = 'YYYY-MM-DD HH:mm';
class Picker extends React.Component {
constructor(props) {
super(props);
this.defaultCalendarValue = null;
this.calendarContainerRef = React.createRef();
this.inputRef = React.createRef();
this.state = {
isOpen: false
};
}
closeDialog = () => {
this.setState({
isOpen: false
});
}
openDialog = () => {
this.setState({
isOpen: true
});
}
clickOutsideToClose = (e) => {
if (!this.inputRef.current.contains(e.target) &&
!this.calendarContainerRef.current.contains(e.target)) {
this.closeDialog();
}
}
componentDidMount() {
let lang = window.app.config.lang;
this.defaultCalendarValue = moment().locale(lang).clone();
document.addEventListener('click', this.clickOutsideToClose);
}
componentWillUnmount() {
document.removeEventListener('click', this.clickOutsideToClose);
}
getCalendarContainer = () => {
@@ -35,12 +62,20 @@ class Picker extends React.Component {
render() {
const props = this.props;
let showHourAndMinute = true; // default: true
if (props.showHourAndMinute != undefined) {
showHourAndMinute = props.showHourAndMinute;
}
const FORMAT = showHourAndMinute ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
const calendar = (<Calendar
defaultValue={this.defaultCalendarValue}
disabledDate={props.disabledDate}
format={FORMAT}
locale={translateCalendar()}
showHourAndMinute={true}
showHourAndMinute={showHourAndMinute}
/>);
return (
<DatePicker
@@ -48,6 +83,7 @@ class Picker extends React.Component {
getCalendarContainer={this.getCalendarContainer}
calendar={calendar}
value={props.value}
open={this.state.isOpen}
onChange={props.onChange}
>
{
@@ -59,9 +95,11 @@ class Picker extends React.Component {
style={{ width: props.inputWidth || 250 }}
tabIndex="-1"
disabled={props.disabled}
readOnly
readOnly={true}
value={value && value.format(FORMAT) || ''}
className="form-control"
onClick={this.openDialog}
ref={this.inputRef}
/>
<div ref={this.calendarContainerRef} />
</div>

View File

@@ -32,7 +32,7 @@ class AboutDialog extends React.Component {
<button type="button" className="close" onClick={this.toggle}><span aria-hidden="true">×</span></button>
<div className="about-content">
<p><img src={mediaUrl + logoPath} height={logoHeight} width={logoWidth} title={siteTitle} alt="logo" /></p>
<p>{gettext('Server Version: ')}{seafileVersion}<br />© 2019 {gettext('Seafile')}</p>
<p>{gettext('Server Version: ')}{seafileVersion}<br />© 2020 {gettext('Seafile')}</p>
<p>{this.renderExternalAboutLinks()}</p>
<p><a href={href} target="_blank">{gettext('About Us')}</a></p>
</div>

View File

@@ -12,16 +12,26 @@ const propTypes = {
class DeleteRepoDialog extends Component {
constructor(props) {
super(props);
this.state = {
isRequestSended: false,
};
}
toggle = () => {
this.props.toggle();
}
onDeleteRepo = () => {
this.props.onDeleteRepo(this.props.repo);
this.setState({isRequestSended: true}, () => {
this.props.onDeleteRepo(this.props.repo);
});
}
render() {
const { isRequestSended } = this.state;
const repo = this.props.repo;
const repoName = '<span class="op-target">' + Utils.HTMLescape(repo.repo_name || repo.name) + '</span>';
let message = gettext('Are you sure you want to delete %s ?');
@@ -35,7 +45,7 @@ class DeleteRepoDialog extends Component {
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
<Button color="primary" onClick={this.onDeleteRepo}>{gettext('Delete')}</Button>
<Button color="primary" disabled={isRequestSended} onClick={this.onDeleteRepo}>{gettext('Delete')}</Button>
</ModalFooter>
</Modal>
);

View File

@@ -51,14 +51,22 @@ class ShareDialog extends React.Component {
}
getInitialActiveTab = () => {
const { repoEncrypted, userPerm, enableDirPrivateShare } = this.props;
let { repoEncrypted, userPerm, enableDirPrivateShare, itemType } = this.props;
const enableShareLink = !repoEncrypted && canGenerateShareLink;
const enableUploadLink = !repoEncrypted && canGenerateUploadLink && userPerm == 'rw';
// for encrypted repo, 'dir private share' is only enabled for the repo itself,
// not for the folders in it.
if (repoEncrypted) {
enableDirPrivateShare = itemType == 'library';
}
if (enableShareLink) {
return 'shareLink';
} else if (enableUploadLink) {
return 'uploadLink';
} else if (itemType == 'file' || itemType == 'dir') {
return 'internalLink';
} else if (enableDirPrivateShare) {
return 'shareToUser';
}
@@ -77,10 +85,16 @@ class ShareDialog extends React.Component {
}
let activeTab = this.state.activeTab;
const { repoEncrypted, userPerm, enableDirPrivateShare, itemType } = this.props;
let { repoEncrypted, userPerm, enableDirPrivateShare, itemType } = this.props;
const enableShareLink = !repoEncrypted && canGenerateShareLink;
const enableUploadLink = !repoEncrypted && canGenerateUploadLink && userPerm == 'rw';
// for encrypted repo, 'dir private share' is only enabled for the repo itself,
// not for the folders in it.
if (repoEncrypted) {
enableDirPrivateShare = itemType == 'library';
}
return (
<Fragment>
<div className="share-dialog-side">
@@ -184,17 +198,20 @@ class ShareDialog extends React.Component {
renderFileContent = () => {
let activeTab = this.state.activeTab;
const { itemType } = this.props;
const { itemType, itemName, repoEncrypted } = this.props;
const enableShareLink = !repoEncrypted && canGenerateShareLink;
return (
<Fragment>
<div className="share-dialog-side">
<Nav pills>
{enableShareLink &&
<NavItem>
<NavLink className={activeTab === 'shareLink' ? 'active' : ''} onClick={(this.toggle.bind(this, 'shareLink'))}>
{gettext('Share Link')}
</NavLink>
</NavItem>
}
<NavItem>
<NavLink className={activeTab === 'internalLink' ? 'active' : ''} onClick={this.toggle.bind(this, 'internalLink')}>
{gettext('Internal Link')}
@@ -204,7 +221,7 @@ class ShareDialog extends React.Component {
</div>
<div className="share-dialog-main">
<TabContent activeTab={this.state.activeTab}>
{activeTab === 'shareLink' &&
{enableShareLink && activeTab === 'shareLink' &&
<TabPane tabId="shareLink">
<GenerateShareLink
itemPath={this.props.itemPath}
@@ -239,8 +256,7 @@ class ShareDialog extends React.Component {
}
render() {
const { itemType, itemName, repoEncrypted } = this.props;
const enableShareLink = !repoEncrypted && canGenerateShareLink;
const { itemType, itemName } = this.props;
return (
<div>
<Modal isOpen={true} style={{maxWidth: '760px'}} className="share-dialog" toggle={this.props.toggleDialog}>
@@ -250,7 +266,7 @@ class ShareDialog extends React.Component {
</ModalHeader>
<ModalBody className="share-dialog-content">
{(itemType === 'library' || itemType === 'dir') && this.renderDirContent()}
{(itemType === 'file' && enableShareLink) && this.renderFileContent()}
{itemType === 'file' && this.renderFileContent()}
</ModalBody>
</Modal>
</div>

View File

@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { gettext, siteRoot } from '../../utils/constants';
import { gettext } from '../../utils/constants';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { seafileAPI } from '../../utils/seafile-api';
import moment from 'moment';
@@ -9,7 +9,7 @@ import { Utils } from '../../utils/utils';
const propTypes = {
toggleCancel: PropTypes.func.isRequired,
addWiki: PropTypes.func.isRequired,
addWiki: PropTypes.func.isRequired
};
class WikiSelectDialog extends React.Component {
@@ -24,10 +24,26 @@ class WikiSelectDialog extends React.Component {
componentDidMount() {
seafileAPI.listRepos().then(res => {
let repoList = res.data.repos.map(item => {
let repo = new Repo(item);
return repo;
});
let repoList = res.data.repos
.filter(item => {
switch (item.type) {
case 'mine': // my libraries
return !item.encrypted;
case 'shared': // libraries shared with me
// 'is_admin': the library is shared with 'admin' permission
return !item.encrypted && item.is_admin;
case 'group':
default:
return !item.encrypted && !res.data.repos.some(repo => {
// just remove the duplicated libraries
return repo.type != item.type && repo.repo_id == item.repo_id;
});
}
})
.map(item => {
let repo = new Repo(item);
return repo;
});
repoList = Utils.sortRepos(repoList, 'name', 'asc');
this.setState({repos: repoList});
});

View File

@@ -766,7 +766,7 @@ class DirentListItem extends React.Component {
itemPath={direntPath}
userPerm={dirent.permission}
repoID={this.props.repoID}
repoEncrypted={false}
repoEncrypted={this.props.repoEncrypted}
enableDirPrivateShare={this.props.enableDirPrivateShare}
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
toggleDialog={this.closeSharedDialog}

View File

@@ -63,8 +63,9 @@ class FileToolbar extends React.Component {
}
let showShareBtn = false;
if (!repoEncrypted &&
(filePerm == 'rw' || filePerm == 'r') && canGenerateShareLink) {
if (repoEncrypted) {
showShareBtn = true; // for internal link
} else if ((filePerm == 'rw' || filePerm == 'r') && canGenerateShareLink) {
showShareBtn = true;
}
@@ -212,7 +213,7 @@ class FileToolbar extends React.Component {
itemPath={filePath}
userPerm={filePerm}
repoID={repoID}
repoEncrypted={false}
repoEncrypted={repoEncrypted}
toggleDialog={this.toggleShareDialog}
/>
</ModalPortal>

View File

@@ -162,10 +162,6 @@ class DirOperationToolbar extends React.Component {
render() {
let { path, repoName, userPerm } = this.props;
if (userPerm !== 'rw' && userPerm !== 'admin') {
return '';
}
let itemType = path === '/' ? 'library' : 'dir';
let itemName = path == '/' ? repoName : Utils.getFolderName(path);
@@ -197,28 +193,30 @@ class DirOperationToolbar extends React.Component {
return (
<Fragment>
<div className="dir-operation">
<div className="operation">
{content}
{(userPerm === 'rw' || userPerm === 'admin') && (
<div className="dir-operation">
<div className="operation">
{content}
</div>
{this.state.isUploadMenuShow && (
<ul className="menu dropdown-menu" style={this.state.operationMenuStyle}>
<li className="dropdown-item" onClick={this.onUploadFile}>{gettext('Upload Files')}</li>
<li className="dropdown-item" onClick={this.onUploadFolder}>{gettext('Upload Folder')}</li>
</ul>
)}
{this.state.isCreateMenuShow && (
<ul className="menu dropdown-menu" style={this.state.operationMenuStyle}>
<li className="dropdown-item" onClick={this.onCreateFolderToggle}>{gettext('New Folder')}</li>
<li className="dropdown-item" onClick={this.onCreateFileToggle}>{gettext('New File')}</li>
<li className="dropdown-divider"></li>
<li className="dropdown-item" onClick={this.onCreateMarkdownToggle}>{gettext('New Markdown File')}</li>
<li className="dropdown-item" onClick={this.onCreateExcelToggle}>{gettext('New Excel File')}</li>
<li className="dropdown-item" onClick={this.onCreatePPTToggle}>{gettext('New PowerPoint File')}</li>
<li className="dropdown-item" onClick={this.onCreateWordToggle}>{gettext('New Word File')}</li>
</ul>
)}
</div>
{this.state.isUploadMenuShow && (
<ul className="menu dropdown-menu" style={this.state.operationMenuStyle}>
<li className="dropdown-item" onClick={this.onUploadFile}>{gettext('Upload Files')}</li>
<li className="dropdown-item" onClick={this.onUploadFolder}>{gettext('Upload Folder')}</li>
</ul>
)}
{this.state.isCreateMenuShow && (
<ul className="menu dropdown-menu" style={this.state.operationMenuStyle}>
<li className="dropdown-item" onClick={this.onCreateFolderToggle}>{gettext('New Folder')}</li>
<li className="dropdown-item" onClick={this.onCreateFileToggle}>{gettext('New File')}</li>
<li className="dropdown-divider"></li>
<li className="dropdown-item" onClick={this.onCreateMarkdownToggle}>{gettext('New Markdown File')}</li>
<li className="dropdown-item" onClick={this.onCreateExcelToggle}>{gettext('New Excel File')}</li>
<li className="dropdown-item" onClick={this.onCreatePPTToggle}>{gettext('New PowerPoint File')}</li>
<li className="dropdown-item" onClick={this.onCreateWordToggle}>{gettext('New Word File')}</li>
</ul>
)}
</div>
)}
{Utils.isDesktop() && <ViewModeToolbar currentMode={this.props.currentMode} switchViewMode={this.props.switchViewMode} />}
{this.state.isCreateFileDialogShow && (
<ModalPortal>

View File

@@ -327,20 +327,22 @@ class MultipleDirOperationToolbar extends React.Component {
const dirent = this.props.selectedDirentList[0];
let direntPath = this.getDirentPath(dirent);
if (userPerm !== 'rw' && userPerm !== 'admin') {
return '';
}
return (
<Fragment>
<div className="dir-operation">
<div className="d-flex">
<ButtonGroup className="flex-row group-operations">
<Button className="secondary group-op-item action-icon sf2-icon-move" title={gettext('Move')} onClick={this.onMoveToggle}></Button>
<Button className="secondary group-op-item action-icon sf2-icon-copy" title={gettext('Copy')} onClick={this.onCopyToggle}></Button>
<Button className="secondary group-op-item action-icon sf2-icon-delete" title={gettext('Delete')} onClick={this.onItemsDelete}></Button>
<Button className="secondary group-op-item action-icon sf2-icon-download" title={gettext('Download')} onClick={this.onItemsDownload}></Button>
{(userPerm === 'rw' || userPerm === 'admin') && (
<Fragment>
<Button className="secondary group-op-item action-icon sf2-icon-move" title={gettext('Move')} onClick={this.onMoveToggle}></Button>
<Button className="secondary group-op-item action-icon sf2-icon-copy" title={gettext('Copy')} onClick={this.onCopyToggle}></Button>
<Button className="secondary group-op-item action-icon sf2-icon-delete" title={gettext('Delete')} onClick={this.onItemsDelete}></Button>
</Fragment>
)}
{(userPerm === 'rw' || userPerm === 'admin' || userPerm === 'r') && (
<Button className="secondary group-op-item action-icon sf2-icon-download" title={gettext('Download')} onClick={this.onItemsDownload}></Button>
)}
{this.props.selectedDirentList.length === 1 &&
<ItemDropdownMenu
tagName={'button'}
@@ -396,7 +398,7 @@ class MultipleDirOperationToolbar extends React.Component {
itemPath={direntPath}
userPerm={dirent.permission}
repoID={repoID}
repoEncrypted={false}
repoEncrypted={this.props.repoEncrypted}
enableDirPrivateShare={this.props.enableDirPrivateShare}
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
toggleDialog={this.toggleCancel}

View File

@@ -118,7 +118,7 @@ class ViewFileToolbar extends React.Component {
{gettext('More')}
</DropdownToggle>
<DropdownMenu>
{this.props.showShareBtn && canGenerateShareLink &&
{this.props.showShareBtn &&
<DropdownItem onClick={this.onShareToggle}>{gettext('Share')}</DropdownItem>
}
<DropdownItem onClick={this.onEditFileTagToggle}>{gettext('Tags')}</DropdownItem>
@@ -174,4 +174,4 @@ class ViewFileToolbar extends React.Component {
ViewFileToolbar.propTypes = propTypes;
export default ViewFileToolbar;
export default ViewFileToolbar;