1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 05:39:59 +00:00

Fix edit page UI (#6083)

* 01 change add new page dialog

* 02 open first page when page load

* fix init wiki do not have page
This commit is contained in:
Michael An
2024-05-15 18:27:33 +08:00
committed by GitHub
parent 7bfc7bae0c
commit 7cdcbb5376
3 changed files with 38 additions and 9 deletions

View File

@@ -80,10 +80,16 @@ class Wiki extends Component {
getWikiConfig = () => {
wikiAPI.getWiki2Config(wikiId).then(res => {
const { wiki_config, repo_id } = res.data.wiki;
const config = new WikiConfig(JSON.parse(wiki_config) || {});
this.setState({
config: new WikiConfig(JSON.parse(wiki_config) || {}),
config,
isConfigLoading: false,
repoId: repo_id,
}, () => {
const pageId = this.getFirstPageId(config);
if (pageId) {
this.setCurrentPage(pageId);
}
});
}).catch((error) => {
let errorMsg = Utils.getErrorMsg(error);
@@ -107,6 +113,15 @@ class Wiki extends Component {
});
};
getFirstPageId = (config) => {
const item = config.navigation[0] || {};
if (item.type === 'page') {
return item.id;
} else if (item.type === 'folder') {
return item.children[0].id;
}
};
loadSidePanel = (initialPath) => {
if (hasIndex) {
this.loadIndexNode();