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

Merge pull request #3326 from haiwen/update_txt_file_save_mechanism

Update txt file save mechanism
This commit is contained in:
Daniel Pan
2019-04-19 18:42:51 +08:00
committed by GitHub
3 changed files with 101 additions and 17 deletions

View File

@@ -10,6 +10,9 @@ import ShareDialog from '../dialog/share-dialog';
const propTypes = {
isLocked: PropTypes.bool.isRequired,
lockedByMe: PropTypes.bool.isRequired,
onSaveChangedContent: PropTypes.func.isRequired,
isSaving: PropTypes.bool.isRequired,
isContentChangedButNotSaved: PropTypes.bool.isRequired,
toggleLockFile: PropTypes.func.isRequired,
toggleCommentPanel: PropTypes.func.isRequired
};
@@ -45,7 +48,6 @@ class FileToolbar extends React.Component {
render() {
const { isLocked, lockedByMe } = this.props;
let showLockUnlockBtn = false;
let lockUnlockText, lockUnlockIcon;
if (canLockUnlockFile) {
@@ -101,15 +103,25 @@ class FileToolbar extends React.Component {
href={`${siteRoot}repo/file_revisions/${repoID}/?p=${encodeURIComponent(filePath)}&referer=${encodeURIComponent(location.href)}`}
/>
)}
{(canEditFile && !err) && (
<IconButton
id="edit"
icon="fa fa-edit"
text={gettext('Edit')}
tag="a"
href={`${siteRoot}repo/${repoID}/file/edit/?p=${encodeURIComponent(filePath)}&file_enc=${encodeURIComponent(fileEnc)}`}
/>
)}
{(canEditFile && !err) &&
( this.props.isSaving ?
<button type={'button'} className={'btn btn-icon btn-secondary btn-active'}>
<i className={'fa fa-spin fa-spinner'}/></button> :
(
this.props.isContentChangedButNotSaved ?
<IconButton
text={gettext('Save')}
id={'saveButton'}
icon={'fa fa-save'}
// button imported in this file does not have functionalities of
// isActive as button imported in markdowneditor has
//isActive={!isContentChanged}
onClick={this.props.onSaveChangedContent}
/> :
<button type={'button'} className={'btn btn-icon btn-secondary btn-active'} disabled>
<i className={'fa fa-save'}/></button>
)
)}
{canDownloadFile && (
<IconButton
id="download-file"

View File

@@ -10,13 +10,17 @@ import CommentPanel from './comment-panel';
import '../../css/file-view.css';
const propTypes = {
content: PropTypes.object.isRequired
onSaveChangedContent: PropTypes.func.isRequired,
content: PropTypes.object.isRequired,
isSaving: PropTypes.bool.isRequired,
isContentChangedButNotSaved: PropTypes.bool.isRequired,
};
const { isStarred, isLocked, lockedByMe,
repoID, filePath, enableWatermark, userNickName
} = window.app.pageOptions;
class FileView extends React.Component {
constructor(props) {
@@ -25,7 +29,7 @@ class FileView extends React.Component {
isStarred: isStarred,
isLocked: isLocked,
lockedByMe: lockedByMe,
isCommentPanelOpen: false
isCommentPanelOpen: false,
};
}
@@ -81,6 +85,9 @@ class FileView extends React.Component {
<FileToolbar
isLocked={this.state.isLocked}
lockedByMe={this.state.lockedByMe}
onSaveChangedContent={this.props.onSaveChangedContent}
isSaving={this.props.isSaving}
isContentChangedButNotSaved={this.props.isContentChangedButNotSaved}
toggleLockFile={this.toggleLockFile}
toggleCommentPanel={this.toggleCommentPanel}
/>