1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-04-28 03:10:45 +00:00
This commit is contained in:
孙永强 2025-04-01 11:59:06 +08:00 committed by r350178982
parent 44223ae538
commit c7a9b4a99c
4 changed files with 14 additions and 8 deletions

View File

@ -155,8 +155,8 @@ class Wiki extends Component {
});
}, 1000);
updatePageLockedToServer = (pageId, locked) => {
wikiAPI.updateWiki2PageLocked(wikiId, pageId, locked).then(res => {
updatePageLock = (pageId, locked) => {
wikiAPI.updateWiki2PageLock(wikiId, pageId, locked).then(res => {
this.setState(prevState => {
const updatedPages = prevState.config.pages.map(page => {
if (page.id === pageId) {
@ -441,7 +441,7 @@ class Wiki extends Component {
assets_url={this.state.assets_url}
onUpdatePage={this.onUpdatePage}
currentPageLocked={this.state.currentPageLocked}
updatePageLockedToServer={this.updatePageLockedToServer}
updatePageLock={this.updatePageLock}
setCurrentPage={this.setCurrentPage}
isUpdateBySide={this.state.isUpdateBySide}
style={mainPanelStyle}

View File

@ -26,7 +26,7 @@ const propTypes = {
currentPageId: PropTypes.string,
isUpdateBySide: PropTypes.bool,
onUpdatePage: PropTypes.func,
updatePageLockedToServer: PropTypes.func,
updatePageLock: PropTypes.func,
currentPageLocked: PropTypes.bool,
onAddWikiPage: PropTypes.func,
style: PropTypes.object.isRequired,
@ -109,7 +109,7 @@ class MainPanel extends Component {
};
toggleFreezeStatus = () => {
this.props.updatePageLockedToServer(this.state.currentPageConfig.id, !this.props.currentPageLocked);
this.props.updatePageLock(this.state.currentPageConfig.id, !this.props.currentPageLocked);
};
render() {

View File

@ -224,10 +224,10 @@ class WikiAPI {
return this.req.get(url);
}
updateWiki2PageLocked(wikiId, pageId, locked) {
updateWiki2PageLock(wikiId, pageId, locked) {
const url = this.server + '/api/v2.1/wiki2/' + wikiId + '/page/' + pageId + '/';
let params = {
locked: locked
is_lock_page: locked
};
return this.req.put(url, params);
}

View File

@ -864,7 +864,7 @@ class Wiki2PageView(APIView):
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
locked = request.data.get('locked', None)
locked = request.data.get('is_lock_page', None)
if locked is None:
error_msg = 'locked is required.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
@ -872,10 +872,16 @@ class Wiki2PageView(APIView):
wiki_config = get_wiki_config(repo_id, username)
pages = wiki_config.get('pages', [])
for page in pages:
page_exists = False
if page['id'] == page_id:
page['locked'] = locked
path = page['path']
page_exists = True
break
if not page_exists:
error_msg = 'page %s not found.' % page_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
wiki_config['pages'] = pages
wiki_config = json.dumps(wiki_config)
save_wiki_config(wiki, username, wiki_config)