diff --git a/frontend/src/pages/wiki2/index.js b/frontend/src/pages/wiki2/index.js index bfb0a0d765..1618c7822d 100644 --- a/frontend/src/pages/wiki2/index.js +++ b/frontend/src/pages/wiki2/index.js @@ -39,21 +39,17 @@ class Wiki extends Component { assets_url: '', }; } - UNSAFE_componentWillMount() { if (!Utils.isDesktop()) { this.setState({ closeSideBar: true }); } } - componentDidMount() { this.getWikiConfig(); } - handlePath = () => { return isWiki2 ? 'wikis/' : 'published/'; }; - getWikiConfig = () => { wikiAPI.getWiki2Config(wikiId).then(res => { const { wiki_config, repo_id } = res.data.wiki; @@ -89,7 +85,6 @@ class Wiki extends Component { onError && onError(); }); }; - getFirstPageId = (config) => { if (!config || !Array.isArray(config.navigation)) return ''; for (let i = 0; i < config.navigation.length; i++) { @@ -102,7 +97,6 @@ class Wiki extends Component { } } }; - getSdocFileContent = (docUuid, accessToken) => { const config = { docUuid, @@ -120,11 +114,9 @@ class Wiki extends Component { toaster.danger(errorMsg); }); }; - onCloseSide = () => { this.setState({ closeSideBar: !this.state.closeSideBar }); }; - showPage = (pageId, filePath) => { this.setState({ isDataLoading: true, @@ -150,7 +142,6 @@ class Wiki extends Component { const fileUrl = `${siteRoot}${this.handlePath()}${wikiId}/?${params.toString()}`; window.history.pushState({ url: fileUrl, path: filePath }, filePath, fileUrl); }; - setCurrentPage = (pageId, callback) => { const { currentPageId, config } = this.state; if (pageId === currentPageId) { @@ -171,7 +162,6 @@ class Wiki extends Component { callback && callback(); }); }; - onUpdatePage = (pageId, newPage) => { if (newPage.name === '') { toaster.danger(gettext('Page name cannot be empty')); @@ -179,13 +169,17 @@ class Wiki extends Component { } const { config } = this.state let pages = config.pages; - let currentPage = pages.find(page => page.id === pageId); - Object.assign(currentPage, newPage); - config.pages = pages; - this.saveWikiConfig(config); + let newPages = pages.map(page => { + if (page.id === pageId) { + return { ...page, ...newPage }; + } + return page; + }); + const newConfig = { ...config, pages: newPages }; + this.saveWikiConfig(newConfig); }; - render() { + return (
} + topSlot={} />
)} diff --git a/frontend/src/pages/wiki2/top-nav/index.jsx b/frontend/src/pages/wiki2/top-nav/index.jsx index ba7256827c..5c68db5e2a 100644 --- a/frontend/src/pages/wiki2/top-nav/index.jsx +++ b/frontend/src/pages/wiki2/top-nav/index.jsx @@ -36,6 +36,7 @@ function getPaths(navigation, currentPageId, pages) { } function WikiTopNav({ config, currentPageId }) { + console.log('config in wiki top nav',config) const { navigation, pages } = config; const paths = getPaths(navigation, currentPageId, pages); return (