import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { gettext, repoID, slug, siteRoot, username, isPro } from '../../utils/constants';
import WikiMarkdownViewer from '../../components/wiki-markdown-viewer';
import WikiDirListView from '../../components/wiki-dir-list-view/wiki-dir-list-view';
import Loading from '../../components/loading';
import { Utils } from '../../utils/utils';
import Search from '../../components/search/search';
import Notification from '../../components/common/notification';
import Account from '../../components/common/account';
const propTypes = {
path: PropTypes.string.isRequired,
pathExist: PropTypes.bool.isRequired,
isViewFile: PropTypes.bool.isRequired,
isDataLoading: PropTypes.bool.isRequired,
content: PropTypes.string,
permission: PropTypes.string,
lastModified: PropTypes.string,
latestContributor: PropTypes.string,
direntList: PropTypes.array.isRequired,
onMenuClick: PropTypes.func.isRequired,
onSearchedClick: PropTypes.func.isRequired,
onMainNavBarClick: PropTypes.func.isRequired,
onDirentClick: PropTypes.func.isRequired,
onLinkClick: PropTypes.func.isRequired,
};
class MainPanel extends Component {
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;
}
if (index === (paths.length - 1)) {
return (