mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-31 06:34:40 +00:00
update
This commit is contained in:
@@ -155,8 +155,8 @@ class Wiki extends Component {
|
|||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
updatePageLockedToServer = (pageId, locked) => {
|
updatePageLock = (pageId, locked) => {
|
||||||
wikiAPI.updateWiki2PageLocked(wikiId, pageId, locked).then(res => {
|
wikiAPI.updateWiki2PageLock(wikiId, pageId, locked).then(res => {
|
||||||
this.setState(prevState => {
|
this.setState(prevState => {
|
||||||
const updatedPages = prevState.config.pages.map(page => {
|
const updatedPages = prevState.config.pages.map(page => {
|
||||||
if (page.id === pageId) {
|
if (page.id === pageId) {
|
||||||
@@ -441,7 +441,7 @@ class Wiki extends Component {
|
|||||||
assets_url={this.state.assets_url}
|
assets_url={this.state.assets_url}
|
||||||
onUpdatePage={this.onUpdatePage}
|
onUpdatePage={this.onUpdatePage}
|
||||||
currentPageLocked={this.state.currentPageLocked}
|
currentPageLocked={this.state.currentPageLocked}
|
||||||
updatePageLockedToServer={this.updatePageLockedToServer}
|
updatePageLock={this.updatePageLock}
|
||||||
setCurrentPage={this.setCurrentPage}
|
setCurrentPage={this.setCurrentPage}
|
||||||
isUpdateBySide={this.state.isUpdateBySide}
|
isUpdateBySide={this.state.isUpdateBySide}
|
||||||
style={mainPanelStyle}
|
style={mainPanelStyle}
|
||||||
|
@@ -26,7 +26,7 @@ const propTypes = {
|
|||||||
currentPageId: PropTypes.string,
|
currentPageId: PropTypes.string,
|
||||||
isUpdateBySide: PropTypes.bool,
|
isUpdateBySide: PropTypes.bool,
|
||||||
onUpdatePage: PropTypes.func,
|
onUpdatePage: PropTypes.func,
|
||||||
updatePageLockedToServer: PropTypes.func,
|
updatePageLock: PropTypes.func,
|
||||||
currentPageLocked: PropTypes.bool,
|
currentPageLocked: PropTypes.bool,
|
||||||
onAddWikiPage: PropTypes.func,
|
onAddWikiPage: PropTypes.func,
|
||||||
style: PropTypes.object.isRequired,
|
style: PropTypes.object.isRequired,
|
||||||
@@ -109,7 +109,7 @@ class MainPanel extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
toggleFreezeStatus = () => {
|
toggleFreezeStatus = () => {
|
||||||
this.props.updatePageLockedToServer(this.state.currentPageConfig.id, !this.props.currentPageLocked);
|
this.props.updatePageLock(this.state.currentPageConfig.id, !this.props.currentPageLocked);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@@ -224,10 +224,10 @@ class WikiAPI {
|
|||||||
return this.req.get(url);
|
return this.req.get(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateWiki2PageLocked(wikiId, pageId, locked) {
|
updateWiki2PageLock(wikiId, pageId, locked) {
|
||||||
const url = this.server + '/api/v2.1/wiki2/' + wikiId + '/page/' + pageId + '/';
|
const url = this.server + '/api/v2.1/wiki2/' + wikiId + '/page/' + pageId + '/';
|
||||||
let params = {
|
let params = {
|
||||||
locked: locked
|
is_lock_page: locked
|
||||||
};
|
};
|
||||||
return this.req.put(url, params);
|
return this.req.put(url, params);
|
||||||
}
|
}
|
||||||
|
@@ -864,7 +864,7 @@ class Wiki2PageView(APIView):
|
|||||||
error_msg = 'Library %s not found.' % repo_id
|
error_msg = 'Library %s not found.' % repo_id
|
||||||
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
|
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:
|
if locked is None:
|
||||||
error_msg = 'locked is required.'
|
error_msg = 'locked is required.'
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
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)
|
wiki_config = get_wiki_config(repo_id, username)
|
||||||
pages = wiki_config.get('pages', [])
|
pages = wiki_config.get('pages', [])
|
||||||
for page in pages:
|
for page in pages:
|
||||||
|
page_exists = False
|
||||||
if page['id'] == page_id:
|
if page['id'] == page_id:
|
||||||
page['locked'] = locked
|
page['locked'] = locked
|
||||||
path = page['path']
|
path = page['path']
|
||||||
|
page_exists = True
|
||||||
break
|
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['pages'] = pages
|
||||||
wiki_config = json.dumps(wiki_config)
|
wiki_config = json.dumps(wiki_config)
|
||||||
save_wiki_config(wiki, username, wiki_config)
|
save_wiki_config(wiki, username, wiki_config)
|
||||||
|
Reference in New Issue
Block a user