1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 06:33:48 +00:00

Merge pull request #5827 from haiwen/add-freeze-operation

Add freeze operation
This commit is contained in:
杨顺强
2023-12-14 10:54:26 +08:00
committed by GitHub
4 changed files with 28 additions and 1 deletions

View File

@@ -33,6 +33,8 @@ class ExternalOperations extends React.Component {
this.unsubscribeStar = eventBus.subscribe(EXTERNAL_EVENT.TOGGLE_STAR, this.toggleStar);
this.unsubscribeUnmark = eventBus.subscribe(EXTERNAL_EVENT.UNMARK_AS_DRAFT, this.unmark);
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.SHARE_SDOC, this.onShareToggle);
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.FREEZE_DOCUMENT, this.onFreezeDocument);
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.UNFREEZE, this.unFreeze);
}
componentWillUnmount() {
@@ -79,6 +81,28 @@ class ExternalOperations extends React.Component {
this.setState({isShowShareDialog: !this.state.isShowShareDialog});
};
onFreezeDocument = () => {
const { repoID, docPath } = this.props;
seafileAPI.lockfile(repoID, docPath, -1).then((res) => {
const eventBus = EventBus.getInstance();
eventBus.dispatch(EXTERNAL_EVENT.REFRESH_DOCUMENT);
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
};
unFreeze = () => {
const { repoID, docPath } = this.props;
seafileAPI.unlockfile(repoID, docPath).then((res) => {
const eventBus = EventBus.getInstance();
eventBus.dispatch(EXTERNAL_EVENT.REFRESH_DOCUMENT);
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
};
render() {
const { repoID, docPath, docName, docPerm } = this.props;
const { isShowInternalLinkDialog, isShowShareDialog } = this.state;

View File

@@ -6,7 +6,7 @@ import { Utils } from './utils/utils';
import Loading from './components/loading';
import SdocEditor from './pages/sdoc/sdoc-editor';
const { serviceURL, avatarURL, siteRoot, lang, mediaUrl } = window.app.config;
const { serviceURL, avatarURL, siteRoot, lang, mediaUrl, isPro } = window.app.config;
const { username, name } = window.app.userInfo;
const {
repoID, repoName, parentDir, filePerm,
@@ -45,6 +45,7 @@ window.seafile = {
revisionId,
mediaUrl,
isFreezed,
isPro: isPro === 'True' ? true : false,
};
ReactDom.render(