1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-10 11:21:29 +00:00

change the mechanism of saving txt file, use md file's way of saving

This commit is contained in:
LeoSirius
2019-04-18 18:18:11 +08:00
parent 56bb4fa5fe
commit cdc9d4865e
3 changed files with 76 additions and 15 deletions

View File

@@ -10,6 +10,7 @@ import ShareDialog from '../dialog/share-dialog';
const propTypes = {
isLocked: PropTypes.bool.isRequired,
lockedByMe: PropTypes.bool.isRequired,
onSaveChangedContent: PropTypes.func.isRequired,
toggleLockFile: PropTypes.func.isRequired,
toggleCommentPanel: PropTypes.func.isRequired
};
@@ -38,7 +39,6 @@ class FileToolbar extends React.Component {
render() {
const { isLocked, lockedByMe } = this.props;
let showLockUnlockBtn = false;
let lockUnlockText, lockUnlockIcon;
if (canLockUnlockFile) {
@@ -94,14 +94,17 @@ 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) &&
(<IconButton
text={gettext('Save')}
id={'saveButton'}
icon={'fa fa-save'}
// button imported in this file does not have functionalities of
// disabled, isActive as button imported in markdowneditor has
//disabled={isContentChanged}
//isActive={!isContentChanged}
onClick={this.props.onSaveChangedContent}
/>
)}
{canDownloadFile && (
<IconButton

View File

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