diff --git a/frontend/src/pages/wiki2/index-md-viewer/index.js b/frontend/src/pages/wiki2/index-md-viewer/index.js
deleted file mode 100644
index e7dfdfa934..0000000000
--- a/frontend/src/pages/wiki2/index-md-viewer/index.js
+++ /dev/null
@@ -1,114 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import { mdStringToSlate } from '@seafile/seafile-editor';
-import { isPublicWiki, repoID, serviceURL, slug } from '../../../utils/constants';
-import { Utils } from '../../../utils/utils';
-import { generateNavItems } from '../utils/generate-navs';
-import NavItem from './nav-item';
-
-import'./style.css';
-
-const viewerPropTypes = {
- indexContent: PropTypes.string.isRequired,
- onLinkClick: PropTypes.func.isRequired,
-};
-
-class IndexMdViewer extends React.Component {
-
- constructor(props) {
- super(props);
- this.links = [];
- this.state = {
- currentPath: '',
- treeRoot: { name: '', href: '', children: [], isRoot: true },
- };
- }
-
- componentDidMount() {
- const { indexContent } = this.props;
- const slateNodes = mdStringToSlate(indexContent);
- const newSlateNodes = Utils.changeMarkdownNodes(slateNodes, this.changeInlineNode);
- const treeRoot = generateNavItems(newSlateNodes);
- this.setState({
- treeRoot: treeRoot,
- });
- }
-
- onLinkClick = (node) => {
- const { currentPath } = this.state;
- if (node.path === currentPath) return;
- if (node.path) {
- this.setState({ currentPath: node.path });
- }
- if (node.href) this.props.onLinkClick(node.href);
- };
-
- changeInlineNode = (item) => {
- if (item.type == 'link' || item.type === 'image') {
- let url;
-
- // change image url
- if (item.type == 'image' && isPublicWiki) {
- url = item.data.src;
- const re = new RegExp(serviceURL + '/lib/' + repoID +'/file.*raw=1');
- // different repo
- if (!re.test(url)) {
- return;
- }
- // get image path
- let index = url.indexOf('/file');
- let index2 = url.indexOf('?');
- const imagePath = url.substring(index + 5, index2);
- // replace url
- item.data.src = serviceURL + '/view-image-via-public-wiki/?slug=' + slug + '&path=' + imagePath;
- }
-
- else if (item.type == 'link') {
- url = item.url;
- /* eslint-disable */
- let expression = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/
- /* eslint-enable */
- let re = new RegExp(expression);
-
- // Solving relative paths
- if (!re.test(url)) {
- if (url.startsWith('./')) {
- url = url.slice(2);
- }
- item.url = serviceURL + '/published/' + slug + '/' + url;
- }
- // change file url
- else if (Utils.isInternalMarkdownLink(url, repoID)) {
- let path = Utils.getPathFromInternalMarkdownLink(url, repoID);
- // replace url
- item.url = serviceURL + '/published/' + slug + path;
- }
- // change dir url
- else if (Utils.isInternalDirLink(url, repoID)) {
- let path = Utils.getPathFromInternalDirLink(url, repoID);
- // replace url
- item.url = serviceURL + '/published/' + slug + path;
- }
- }
- }
-
- return item;
- };
-
- render() {
- const { treeRoot, currentPath } = this.state;
- return (
-
- {treeRoot.children.map(node => {
- return (
-
- );
- })}
-
- );
- }
-}
-
-IndexMdViewer.propTypes = viewerPropTypes;
-
-export default IndexMdViewer;
diff --git a/frontend/src/pages/wiki2/index-md-viewer/nav-item.js b/frontend/src/pages/wiki2/index-md-viewer/nav-item.js
deleted file mode 100644
index 3bfdd0064e..0000000000
--- a/frontend/src/pages/wiki2/index-md-viewer/nav-item.js
+++ /dev/null
@@ -1,91 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import classNames from 'classnames';
-
-const propTypes = {
- node: PropTypes.object.isRequired,
- currentPath: PropTypes.string,
- onLinkClick: PropTypes.func.isRequired,
-};
-
-class NavItem extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- expanded: false
- };
- }
-
- toggleExpanded = () => {
- const { expanded } = this.state;
- this.setState({ expanded: !expanded });
- };
-
- onLinkClick = (event) => {
- event.preventDefault();
- const { node } = this.props;
- const { expanded } = this.state;
- if (node.children && node.children.length > 0 && !expanded) {
- this.setState({expanded: !expanded});
- return;
- }
- this.props.onLinkClick(node);
- };
-
- itemClick = () => {
- const { node } = this.props;
- const { expanded } = this.state;
- if (node.children && node.children.length > 0) {
- this.setState({expanded: !expanded});
- return;
- }
- };
-
- renderLink = ({ href, name, path, children }) => {
- const { currentPath } = this.props;
- const className = classNames('wiki-nav-content', {
- 'no-children': !children || children.length === 0,
- 'wiki-nav-content-highlight': currentPath === path,
- });
- if (href && name) {
- return (
-
- );
- }
-
- if (name) {
- return {name}
;
- }
-
- return null;
- };
-
- render() {
- const { node } = this.props;
- const { expanded } = this.state;
- if (node.children.length > 0) {
- return (
-
-
- {}
-
- {this.renderLink(node)}
- {expanded && node.children.map((child, index) => {
- return (
-
- );
- })}
-
- );
- }
-
- return this.renderLink(node);
- }
-}
-
-NavItem.propTypes = propTypes;
-
-export default NavItem;
diff --git a/frontend/src/pages/wiki2/index-md-viewer/style.css b/frontend/src/pages/wiki2/index-md-viewer/style.css
deleted file mode 100644
index cc49daacc4..0000000000
--- a/frontend/src/pages/wiki2/index-md-viewer/style.css
+++ /dev/null
@@ -1,37 +0,0 @@
-.wiki-nav-content {
- margin-top: 18px;
-}
-
-.wiki-nav-content.no-children {
- margin-left: 1rem;
-}
-
-.wiki-nav-content a,
-.wiki-nav-content span {
- color: #4d5156;
- font-size: 14px;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- display: block;
-}
-
-.wiki-nav-content a:hover {
- text-decoration: none;
- color: #eb8205;
-}
-
-.wiki-nav-content-highlight a {
- text-decoration: none;
- color: #eb8205;
-}
-
-.switch-btn {
- position: absolute;
- left: 0;
- top: 2px;
- color: #c0c0c0;
- cursor: pointer;
- font-size: 12px;
- padding-right: 10px;
-}
diff --git a/frontend/src/pages/wiki2/index.js b/frontend/src/pages/wiki2/index.js
index a7cdf66df0..bab8c0256d 100644
--- a/frontend/src/pages/wiki2/index.js
+++ b/frontend/src/pages/wiki2/index.js
@@ -5,15 +5,11 @@ import { Modal } from 'reactstrap';
import { Utils } from '../../utils/utils';
import wikiAPI from '../../utils/wiki-api';
import SDocServerApi from '../../utils/sdoc-server-api';
-import { slug, wikiId, siteRoot, initialPath, isDir, sharedToken, hasIndex, lang, isWiki2, seadocServerUrl } from '../../utils/constants';
-import Dirent from '../../models/dirent';
+import { wikiId, siteRoot, lang, isWiki2, seadocServerUrl } from '../../utils/constants';
import WikiConfig from './models/wiki-config';
-import TreeNode from '../../components/tree-view/tree-node';
-import treeHelper from '../../components/tree-view/tree-helper';
import toaster from '../../components/toast';
import SidePanel from './side-panel';
import MainPanel from './main-panel';
-// import WikiLeftBar from './wiki-left-bar/wiki-left-bar';
import PageUtils from './view-structure/page-utils';
import '../../css/layout.css';
@@ -33,17 +29,9 @@ class Wiki extends Component {
closeSideBar: false,
isViewFile: true,
isDataLoading: false,
- direntList: [],
editorContent: {},
permission: '',
- lastModified: '',
- latestContributor: '',
- isTreeDataLoading: true,
isConfigLoading: true,
- treeData: treeHelper.buildTree(),
- currentNode: null,
- indexNode: null,
- indexContent: '',
currentPageId: '',
config: new WikiConfig({}),
repoId: '',
@@ -51,9 +39,6 @@ class Wiki extends Component {
assets_url: '',
};
- window.onpopstate = this.onpopstate;
- this.indexPath = '/index.md';
- this.homePath = '/home.md';
this.pythonWrapper = null;
}
@@ -65,15 +50,6 @@ class Wiki extends Component {
componentDidMount() {
this.getWikiConfig();
- this.loadSidePanel(initialPath);
- this.loadWikiData(initialPath);
-
- this.links = document.querySelectorAll('#wiki-file-content a');
- this.links.forEach(link => link.addEventListener('click', this.onConentLinkClick));
- }
-
- componentWillUnmount() {
- this.links.forEach(link => link.removeEventListener('click', this.onConentLinkClick));
}
handlePath = () => {
@@ -129,77 +105,6 @@ class Wiki extends Component {
}
};
- loadSidePanel = (initialPath) => {
- if (hasIndex) {
- this.loadIndexNode();
- return;
- }
-
- // load dir list
- initialPath = (isDir === 'None' || Utils.isSdocFile(initialPath)) ? '/' : initialPath;
- this.loadNodeAndParentsByPath(initialPath);
- };
-
- loadWikiData = (initialPath) => {
- this.pythonWrapper = document.getElementById('wiki-file-content');
- if (isDir === 'False' && Utils.isSdocFile(initialPath)) {
- this.showDir('/');
- return;
- }
-
- if (isDir === 'False') {
- // this.showFile(initialPath);
- this.setState({ path: initialPath });
- return;
- }
-
- // if it is a file list, remove the template content provided by python
- this.removePythonWrapper();
-
- if (isDir === 'True') {
- this.showDir(initialPath);
- return;
- }
-
- if (isDir === 'None' && initialPath === '/home.md') {
- this.showDir('/');
- return;
- }
-
- if (isDir === 'None') {
- this.setState({ pathExist: false });
- let fileUrl = siteRoot + this.handlePath() + wikiId + Utils.encodePath(initialPath);
- window.history.pushState({ url: fileUrl, path: initialPath }, initialPath, fileUrl);
- }
- };
-
- loadIndexNode = () => {
- wikiAPI.listWiki2Dir(wikiId, '/').then(res => {
- let tree = this.state.treeData;
- this.addFirstResponseListToNode(res.data.dirent_list, tree.root);
- let indexNode = tree.getNodeByPath(this.indexPath);
- wikiAPI.getWiki2FileContent(wikiId, indexNode.path).then(res => {
- this.setState({
- treeData: tree,
- indexNode: indexNode,
- indexContent: res.data.content,
- isTreeDataLoading: false,
- });
- });
- }).catch(() => {
- this.setState({ isLoadFailed: true });
- });
- };
-
- showDir = (dirPath) => {
- this.removePythonWrapper();
- this.loadDirentList(dirPath);
-
- // update location url
- let fileUrl = siteRoot + this.handlePath() + wikiId + Utils.encodePath(dirPath);
- window.history.pushState({ url: fileUrl, path: dirPath }, dirPath, fileUrl);
- };
-
getSdocFileContent = (docUuid, accessToken) => {
const config = {
docUuid,
@@ -218,118 +123,6 @@ class Wiki extends Component {
});
};
- showFile = (filePath) => {
- this.setState({
- isDataLoading: true,
- });
- wikiAPI.getWiki2FileContent(wikiId, filePath).then(res => {
- const { permission, last_modified, latest_contributor, seadoc_access_token, assets_url } = res.data;
- this.setState({
- permission,
- lastModified: moment.unix(last_modified).fromNow(),
- latestContributor: latest_contributor,
- seadoc_access_token,
- assets_url,
- isViewFile: true,
- path: filePath,
- });
- const docUuid = assets_url.slice(assets_url.lastIndexOf('/') + 1);
- this.getSdocFileContent(docUuid, seadoc_access_token);
- }).catch(error => {
- let errorMsg = Utils.getErrorMsg(error);
- toaster.danger(errorMsg);
- });
-
- const hash = window.location.hash;
- let fileUrl = `${siteRoot}${this.handlePath()}${wikiId}${Utils.encodePath(filePath)}${hash}`;
- if (filePath === '/home.md') {
- window.history.replaceState({ url: fileUrl, path: filePath }, filePath, fileUrl);
- } else {
- window.history.pushState({ url: fileUrl, path: filePath }, filePath, fileUrl);
- }
- };
-
- loadDirentList = (dirPath) => {
- this.setState({ isDataLoading: true });
- wikiAPI.listWiki2Dir(wikiId, dirPath).then(res => {
- let direntList = res.data.dirent_list.map(item => {
- let dirent = new Dirent(item);
- return dirent;
- });
- if (dirPath === '/') {
- direntList = direntList.filter(item => {
- if (item.type === 'dir') {
- let name = item.name.toLowerCase();
- return name !== 'drafts' && name !== 'images' && name !== 'downloads';
- }
- return true;
- });
- }
- direntList = Utils.sortDirents(direntList, 'name', 'asc');
- this.setState({
- path: dirPath,
- isViewFile: false,
- direntList: direntList,
- isDataLoading: false,
- });
- }).catch(() => {
- this.setState({ isLoadFailed: true });
- });
- };
-
- loadTreeNodeByPath = (path) => {
- let tree = this.state.treeData.clone();
- let node = tree.getNodeByPath(path);
- if (!node.isLoaded) {
- wikiAPI.listWiki2Dir(wikiId, node.path).then(res => {
- this.addResponseListToNode(res.data.dirent_list, node);
- let parentNode = tree.getNodeByPath(node.parentNode.path);
- parentNode.isExpanded = true;
- this.setState({
- treeData: tree,
- currentNode: node
- });
- });
- } else {
- let parentNode = tree.getNodeByPath(node.parentNode.path);
- parentNode.isExpanded = true;
- this.setState({ treeData: tree, currentNode: node }); //tree
- }
- };
-
- loadNodeAndParentsByPath = (path) => {
- let tree = this.state.treeData.clone();
- if (Utils.isMarkdownFile(path)) {
- path = Utils.getDirName(path);
- }
- wikiAPI.listWiki2Dir(wikiId, path, true).then(res => {
- let direntList = res.data.dirent_list;
- let results = {};
- for (let i = 0; i < direntList.length; i++) {
- let object = direntList[i];
- let key = object.parent_dir;
- if (!results[key]) {
- results[key] = [];
- }
- results[key].push(object);
- }
- for (let key in results) {
- let node = tree.getNodeByPath(key);
- if (!node.isLoaded && node.path === '/') {
- this.addFirstResponseListToNode(results[key], node);
- } else if (!node.isLoaded) {
- this.addResponseListToNode(results[key], node);
- }
- }
- this.setState({
- isTreeDataLoading: false,
- treeData: tree
- });
- }).catch(() => {
- this.setState({ isLoadFailed: true });
- });
- };
-
removePythonWrapper = () => {
if (this.pythonWrapper) {
document.body.removeChild(this.pythonWrapper);
@@ -337,227 +130,10 @@ class Wiki extends Component {
}
};
- onConentLinkClick = (event) => {
- event.preventDefault();
- event.stopPropagation();
- let link = '';
- if (event.target.tagName !== 'A') {
- let target = event.target.parentNode;
- while (target.tagName !== 'A') {
- target = target.parentNode;
- }
- link = target.href;
- } else {
- link = event.target.href;
- }
- this.onLinkClick(link);
- };
-
- onLinkClick = (link) => {
- const url = link;
- if (Utils.isWikiInternalMarkdownLink(url, slug)) {
- let path = Utils.getPathFromWikiInternalMarkdownLink(url, slug);
- this.showFile(path);
- } else if (Utils.isWikiInternalDirLink(url, slug)) {
- let path = Utils.getPathFromWikiInternalDirLink(url, slug);
- this.showDir(path);
- } else {
- window.location.href = url;
- }
- if (!this.state.closeSideBar) {
- this.setState({ closeSideBar: true });
- }
- };
-
- onpopstate = (event) => {
- if (event.state && event.state.path) {
- let path = event.state.path;
- if (Utils.isMarkdownFile(path)) {
- this.showFile(path);
- } else {
- this.loadDirentList(path);
- this.setState({
- path: path,
- isViewFile: false
- });
- }
- }
- };
-
- onSearchedClick = (item) => {
- let path = item.is_dir ? item.path.slice(0, item.path.length - 1) : item.path;
- if (this.state.currentPath === path) {
- return;
- }
-
- // load sidePanel
- let index = -1;
- let paths = Utils.getPaths(path);
- for (let i = 0; i < paths.length; i++) {
- // eslint-disable-next-line no-use-before-define
- let node = this.state.treeData.getNodeByPath(node);
- if (!node) {
- index = i;
- break;
- }
- }
- if (index === -1) { // all the data has been loaded already.
- let tree = this.state.treeData.clone();
- let node = tree.getNodeByPath(item.path);
- treeHelper.expandNode(node);
- this.setState({ treeData: tree });
- } else {
- this.loadNodeAndParentsByPath(path);
- }
-
- // load mainPanel
- if (item.is_dir) {
- this.showDir(path);
- } else {
- if (Utils.isMarkdownFile(path)) {
- this.showFile(path);
- } else {
- let url = siteRoot + 'd/' + sharedToken + '/files/?p=' + Utils.encodePath(path);
- let newWindow = window.open('about:blank');
- newWindow.location.href = url;
- }
- }
- };
-
- onMenuClick = () => {
- this.setState({ closeSideBar: !this.state.closeSideBar });
- };
-
- onMainNavBarClick = (nodePath) => {
- let tree = this.state.treeData.clone();
- let node = tree.getNodeByPath(nodePath);
- tree.expandNode(node);
- this.setState({ treeData: tree, currentNode: node });
- this.showDir(node.path);
- };
-
- onDirentClick = (dirent) => {
- let direntPath = Utils.joinPath(this.state.path, dirent.name);
- if (dirent.isDir()) { // is dir
- this.loadTreeNodeByPath(direntPath);
- this.showDir(direntPath);
- } else { // is file
- if (Utils.isMarkdownFile(direntPath)) {
- this.showFile(direntPath);
- } else {
- const w = window.open('about:blank');
- const url = siteRoot + 'd/' + sharedToken + '/files/?p=' + Utils.encodePath(direntPath);
- w.location.href = url;
- }
- }
- };
-
onCloseSide = () => {
this.setState({ closeSideBar: !this.state.closeSideBar });
};
- onNodeClick = (node) => {
- if (!this.state.pathExist) {
- this.setState({ pathExist: true });
- }
-
- if (node.object.isDir()) {
- if (!node.isLoaded) {
- let tree = this.state.treeData.clone();
- node = tree.getNodeByPath(node.path);
- wikiAPI.listWiki2Dir(wikiId, node.path).then(res => {
- this.addResponseListToNode(res.data.dirent_list, node);
- tree.collapseNode(node);
- this.setState({ treeData: tree });
- });
- }
- if (node.path === this.state.path) {
- if (node.isExpanded) {
- let tree = treeHelper.collapseNode(this.state.treeData, node);
- this.setState({ treeData: tree });
- } else {
- let tree = this.state.treeData.clone();
- node = tree.getNodeByPath(node.path);
- tree.expandNode(node);
- this.setState({ treeData: tree });
- }
- }
- }
-
- if (node.path === this.state.path) {
- return;
- }
-
- if (node.object.isDir()) { // isDir
- this.showDir(node.path);
- } else {
- if (Utils.isMarkdownFile(node.path) || Utils.isSdocFile(node.path)) {
- if (node.path !== this.state.path) {
- this.showFile(node.path);
- }
- this.onCloseSide();
- } else {
- const w = window.open('about:blank');
- const url = siteRoot + 'd/' + sharedToken + '/files/?p=' + Utils.encodePath(node.path);
- w.location.href = url;
- }
- }
- };
-
- onNodeCollapse = (node) => {
- let tree = treeHelper.collapseNode(this.state.treeData, node);
- this.setState({ treeData: tree });
- };
-
- onNodeExpanded = (node) => {
- let tree = this.state.treeData.clone();
- node = tree.getNodeByPath(node.path);
- if (!node.isLoaded) {
- wikiAPI.listWiki2Dir(wikiId, node.path).then(res => {
- this.addResponseListToNode(res.data.dirent_list, node);
- this.setState({ treeData: tree });
- });
- } else {
- tree.expandNode(node);
- this.setState({ treeData: tree });
- }
- };
-
- addFirstResponseListToNode = (list, node) => {
- node.isLoaded = true;
- node.isExpanded = true;
- let direntList = list.map(item => {
- return new Dirent(item);
- });
- direntList = direntList.filter(item => {
- if (item.type === 'dir') {
- let name = item.name.toLowerCase();
- return name !== 'drafts' && name !== 'images' && name !== 'downloads';
- }
- return true;
- });
- direntList = Utils.sortDirents(direntList, 'name', 'asc');
-
- let nodeList = direntList.map(object => {
- return new TreeNode({ object });
- });
- node.addChildren(nodeList);
- };
-
- addResponseListToNode = (list, node) => {
- node.isLoaded = true;
- node.isExpanded = true;
- let direntList = list.map(item => {
- return new Dirent(item);
- });
- direntList = Utils.sortDirents(direntList, 'name', 'asc');
-
- let nodeList = direntList.map(object => {
- return new TreeNode({ object });
- });
- node.addChildren(nodeList);
- };
-
showPage = (pageId, filePath) => {
this.setState({
isDataLoading: true,
@@ -565,11 +141,9 @@ class Wiki extends Component {
this.removePythonWrapper();
wikiAPI.getWiki2Page(wikiId, pageId).then(res => {
- const { permission, last_modified, latest_contributor, seadoc_access_token, assets_url } = res.data;
+ const { permission, seadoc_access_token, assets_url } = res.data;
this.setState({
permission,
- lastModified: moment.unix(last_modified).fromNow(),
- latestContributor: latest_contributor,
seadoc_access_token,
assets_url,
isViewFile: true,
@@ -597,16 +171,10 @@ class Wiki extends Component {
const { pages } = config;
const currentPage = PageUtils.getPageById(pages, pageId);
const path = currentPage.path;
- if (Utils.isMarkdownFile(path) || Utils.isSdocFile(path)) {
- if (path !== this.state.path) {
- this.showPage(pageId, path);
- }
- this.onCloseSide();
- } else {
- const w = window.open('about:blank');
- const url = siteRoot + 'd/' + sharedToken + '/files/?p=' + Utils.encodePath(path);
- w.location.href = url;
+ if (path !== this.state.path) {
+ this.showPage(pageId, path);
}
+ this.onCloseSide();
this.setState({
currentPageId: pageId,
path: path,
@@ -618,25 +186,10 @@ class Wiki extends Component {
render() {
return (
- {/* {isWiki2 &&
-
this.saveWikiConfig(Object.assign({}, this.state.config, data))}
- />
- } */}
diff --git a/frontend/src/pages/wiki2/main-panel.js b/frontend/src/pages/wiki2/main-panel.js
index 72628f1111..1fbe42881f 100644
--- a/frontend/src/pages/wiki2/main-panel.js
+++ b/frontend/src/pages/wiki2/main-panel.js
@@ -1,7 +1,7 @@
-import React, { Component, Fragment } from 'react';
+import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { SdocWikiViewer } from '@seafile/sdoc-editor';
-import { gettext, repoID, siteRoot, username } from '../../utils/constants';
+import { gettext, username } from '../../utils/constants';
import Loading from '../../components/loading';
import { Utils } from '../../utils/utils';
import Account from '../../components/common/account';
@@ -14,12 +14,6 @@ const propTypes = {
isDataLoading: PropTypes.bool.isRequired,
editorContent: PropTypes.object,
permission: PropTypes.string,
- lastModified: PropTypes.string,
- latestContributor: PropTypes.string,
- onMenuClick: PropTypes.func.isRequired,
- onSearchedClick: PropTypes.func.isRequired,
- onMainNavBarClick: PropTypes.func.isRequired,
- onLinkClick: PropTypes.func.isRequired,
seadoc_access_token: PropTypes.string,
assets_url: PropTypes.string,
config: PropTypes.object,
@@ -30,59 +24,11 @@ class MainPanel extends Component {
constructor(props) {
super(props);
-
this.state = {
docUuid: '',
};
}
- onMenuClick = () => {
- this.props.onMenuClick();
- };
-
- onEditClick = (e) => {
- e.preventDefault();
- let url = siteRoot + 'lib/' + repoID + '/file' + this.props.path + '?mode=edit';
- window.open(url);
- };
-
- onMainNavBarClick = (e) => {
- let path = Utils.getEventData(e, 'path');
- this.props.onMainNavBarClick(path);
- };
-
- renderNavPath = () => {
- let paths = this.props.path.split('/');
- let nodePath = '';
- let pathElem = paths.map((item, index) => {
- if (item === '') {
- return null;
- }
- if (index === (paths.length - 1)) {
- return (
-
- /
- {item}
-
- );
- } else {
- nodePath += '/' + item;
- return (
-
- /
-
- {item}
-
-
- );
- }
- });
- return pathElem;
- };
-
static getDerivedStateFromProps(props, state) {
const { seadoc_access_token } = props;
const config = window.app.config;
@@ -102,7 +48,6 @@ class MainPanel extends Component {
}
render() {
- const errMessage = ({gettext('Folder does not exist.')}
);
const { permission, pathExist, isDataLoading, isViewFile } = this.props;
const isViewingFile = pathExist && !isDataLoading && isViewFile;
const isReadOnly = !(permission === 'rw');
@@ -119,7 +64,9 @@ class MainPanel extends Component {
- {!this.props.pathExist && errMessage}
+ {!this.props.pathExist &&
+
{gettext('Folder does not exist.')}
+ }
{this.props.pathExist && this.props.isDataLoading &&
}
{isViewingFile && Utils.isSdocFile(this.props.path) && (
{
- return (
-
- );
- };
-
- renderTreeView = () => {
- return (
-
- {/* {this.props.treeData && (
-
- )} */}
- {isWiki2 &&
-
- }
- {this.state.isShowNewFolderDialog &&
-
- }
- {this.state.isShowAddNewPageDialog &&
-
- }
-
- );
- };
-
confirmDeletePage = (pageId) => {
const config = deepCopy(this.props.config);
const { pages, navigation } = config;
@@ -373,28 +314,40 @@ class SidePanel extends Component {
);
};
- renderContent = () => {
- const { isLoading, indexNode, config } = this.props;
- if (isLoading) {
- return ;
- }
- if (indexNode) {
- return this.renderIndexView();
- }
- if (isObjectNotEmpty(config)) {
- return this.renderFolderView();
- }
- return this.renderTreeView();
+ renderNoFolder = () => {
+ return (
+
+ {isWiki2 &&
+
+ }
+ {this.state.isShowNewFolderDialog &&
+
+ }
+ {this.state.isShowAddNewPageDialog &&
+
+ }
+
+ );
};
render() {
+ const { isLoading, config } = this.props;
return (
{repoName}
- {this.renderContent()}
+ {isLoading ? : (isObjectNotEmpty(config) ? this.renderFolderView() : this.renderNoFolder())}
);
diff --git a/frontend/src/utils/wiki-api.js b/frontend/src/utils/wiki-api.js
index fe258a4523..3698024931 100644
--- a/frontend/src/utils/wiki-api.js
+++ b/frontend/src/utils/wiki-api.js
@@ -106,24 +106,6 @@ class WikiAPI {
// for wiki2
- listWiki2Dir(wikiId, dirPath, withParents) {
- const path = encodeURIComponent(dirPath);
- let url = this.server + '/api/v2.1/wiki2/' + wikiId + '/page-dir/?p=' + path;
- if (withParents) {
- url = this.server + '/api/v2.1/wiki2/' + wikiId + '/page-dir/?p=' + path + '&with_parents=' + withParents;
- }
- return this.req.get(url);
- }
-
-
- getWiki2FileContent(wikiId, filePath) {
- const path = encodeURIComponent(filePath);
- const time = new Date().getTime();
- const url = this.server + '/api/v2.1/wiki2/' + wikiId + '/content/' + '?p=' + path + '&_=' + time;
- return this.req.get(url);
- }
-
-
listWikis2(options) {
/*
* options: `{type: 'shared'}`, `{type: ['mine', 'shared', ...]}`