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

@@ -0,0 +1,3 @@
.add-new-page-dialog .modal-footer .loading-icon {
margin: 0;
}

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();

View File

@@ -1,12 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Modal, ModalHeader, ModalBody, ModalFooter, Form, FormGroup, Label, Input, Button } from 'reactstrap';
import { Modal, ModalHeader, ModalBody, ModalFooter, Label, Input, Button } from 'reactstrap';
import { gettext, repoID } from '../../../utils/constants';
import { seafileAPI } from '../../../utils/seafile-api';
import { Utils } from '../../../utils/utils';
import toaster from '../../../components/toast';
import Loading from '../../../components/loading';
import '../css/add-new-page-dialog.css';
const propTypes = {
toggle: PropTypes.func.isRequired,
onAddNewPage: PropTypes.func,
@@ -56,6 +58,13 @@ class AddNewPageDialog extends React.Component {
}
};
handleKeyDown = (e) => {
if (e.keyCode === 13) {
e.preventDefault();
this.onSubmit();
}
};
toggle = () => {
this.props.toggle();
};
@@ -111,15 +120,17 @@ class AddNewPageDialog extends React.Component {
render() {
return (
<Modal isOpen={true} toggle={this.toggle} autoFocus={false}>
<Modal isOpen={true} toggle={this.toggle} autoFocus={false} className='add-new-page-dialog'>
<ModalHeader toggle={this.toggle}>{gettext('Add page')}</ModalHeader>
<ModalBody className='pr-4'>
<Form>
<FormGroup>
<Label>{gettext('Page name')}</Label>
<Input value={this.state.pageName} onChange={this.handleChange} autoFocus={true} />
</FormGroup>
</Form>
<Label>{gettext('Page name')}</Label>
<Input
className="mb-4"
value={this.state.pageName}
onChange={this.handleChange}
autoFocus={true}
onKeyDown={this.handleKeyDown}
/>
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>