mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-11 20:01:10 +00:00
feat: change ux
This commit is contained in:
@@ -39,21 +39,17 @@ class Wiki extends Component {
|
|||||||
assets_url: '',
|
assets_url: '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillMount() {
|
UNSAFE_componentWillMount() {
|
||||||
if (!Utils.isDesktop()) {
|
if (!Utils.isDesktop()) {
|
||||||
this.setState({ closeSideBar: true });
|
this.setState({ closeSideBar: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.getWikiConfig();
|
this.getWikiConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePath = () => {
|
handlePath = () => {
|
||||||
return isWiki2 ? 'wikis/' : 'published/';
|
return isWiki2 ? 'wikis/' : 'published/';
|
||||||
};
|
};
|
||||||
|
|
||||||
getWikiConfig = () => {
|
getWikiConfig = () => {
|
||||||
wikiAPI.getWiki2Config(wikiId).then(res => {
|
wikiAPI.getWiki2Config(wikiId).then(res => {
|
||||||
const { wiki_config, repo_id } = res.data.wiki;
|
const { wiki_config, repo_id } = res.data.wiki;
|
||||||
@@ -89,7 +85,6 @@ class Wiki extends Component {
|
|||||||
onError && onError();
|
onError && onError();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
getFirstPageId = (config) => {
|
getFirstPageId = (config) => {
|
||||||
if (!config || !Array.isArray(config.navigation)) return '';
|
if (!config || !Array.isArray(config.navigation)) return '';
|
||||||
for (let i = 0; i < config.navigation.length; i++) {
|
for (let i = 0; i < config.navigation.length; i++) {
|
||||||
@@ -102,7 +97,6 @@ class Wiki extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getSdocFileContent = (docUuid, accessToken) => {
|
getSdocFileContent = (docUuid, accessToken) => {
|
||||||
const config = {
|
const config = {
|
||||||
docUuid,
|
docUuid,
|
||||||
@@ -120,11 +114,9 @@ class Wiki extends Component {
|
|||||||
toaster.danger(errorMsg);
|
toaster.danger(errorMsg);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onCloseSide = () => {
|
onCloseSide = () => {
|
||||||
this.setState({ closeSideBar: !this.state.closeSideBar });
|
this.setState({ closeSideBar: !this.state.closeSideBar });
|
||||||
};
|
};
|
||||||
|
|
||||||
showPage = (pageId, filePath) => {
|
showPage = (pageId, filePath) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
isDataLoading: true,
|
isDataLoading: true,
|
||||||
@@ -150,7 +142,6 @@ class Wiki extends Component {
|
|||||||
const fileUrl = `${siteRoot}${this.handlePath()}${wikiId}/?${params.toString()}`;
|
const fileUrl = `${siteRoot}${this.handlePath()}${wikiId}/?${params.toString()}`;
|
||||||
window.history.pushState({ url: fileUrl, path: filePath }, filePath, fileUrl);
|
window.history.pushState({ url: fileUrl, path: filePath }, filePath, fileUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
setCurrentPage = (pageId, callback) => {
|
setCurrentPage = (pageId, callback) => {
|
||||||
const { currentPageId, config } = this.state;
|
const { currentPageId, config } = this.state;
|
||||||
if (pageId === currentPageId) {
|
if (pageId === currentPageId) {
|
||||||
@@ -171,7 +162,6 @@ class Wiki extends Component {
|
|||||||
callback && callback();
|
callback && callback();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onUpdatePage = (pageId, newPage) => {
|
onUpdatePage = (pageId, newPage) => {
|
||||||
if (newPage.name === '') {
|
if (newPage.name === '') {
|
||||||
toaster.danger(gettext('Page name cannot be empty'));
|
toaster.danger(gettext('Page name cannot be empty'));
|
||||||
@@ -179,13 +169,17 @@ class Wiki extends Component {
|
|||||||
}
|
}
|
||||||
const { config } = this.state
|
const { config } = this.state
|
||||||
let pages = config.pages;
|
let pages = config.pages;
|
||||||
let currentPage = pages.find(page => page.id === pageId);
|
let newPages = pages.map(page => {
|
||||||
Object.assign(currentPage, newPage);
|
if (page.id === pageId) {
|
||||||
config.pages = pages;
|
return { ...page, ...newPage };
|
||||||
this.saveWikiConfig(config);
|
}
|
||||||
|
return page;
|
||||||
|
});
|
||||||
|
const newConfig = { ...config, pages: newPages };
|
||||||
|
this.saveWikiConfig(newConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="main" className="wiki-main">
|
<div id="main" className="wiki-main">
|
||||||
<SidePanel
|
<SidePanel
|
||||||
|
@@ -92,7 +92,7 @@ class MainPanel extends Component {
|
|||||||
document={this.props.editorContent}
|
document={this.props.editorContent}
|
||||||
docUuid={this.state.docUuid}
|
docUuid={this.state.docUuid}
|
||||||
isWikiReadOnly={isReadOnly}
|
isWikiReadOnly={isReadOnly}
|
||||||
topSlot={<Input className='sf-wiki-title' bsSize="lg" onBlur={this.handleRenameDocument} defaultValue={currentPageConfig.name} />}
|
topSlot={<Input className='sf-wiki-title' bsSize="lg" onChange={this.handleRenameDocument} defaultValue={currentPageConfig.name} />}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@@ -36,6 +36,7 @@ function getPaths(navigation, currentPageId, pages) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function WikiTopNav({ config, currentPageId }) {
|
function WikiTopNav({ config, currentPageId }) {
|
||||||
|
console.log('config in wiki top nav',config)
|
||||||
const { navigation, pages } = config;
|
const { navigation, pages } = config;
|
||||||
const paths = getPaths(navigation, currentPageId, pages);
|
const paths = getPaths(navigation, currentPageId, pages);
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user