2018-09-12 02:32:31 +00:00
|
|
|
import React, { Component } from 'react';
|
2018-09-18 02:11:37 +00:00
|
|
|
import { gettext, repoID, serviceUrl, slug, siteRoot, isPro, permission } from '../../components/constants';
|
2018-09-12 02:32:31 +00:00
|
|
|
import Search from '../../components/search';
|
|
|
|
import Account from '../../components/account';
|
2018-09-18 02:11:37 +00:00
|
|
|
import Notification from '../../components/notification';
|
2018-09-12 02:32:31 +00:00
|
|
|
import MarkdownViewer from '../../components/markdown-viewer';
|
|
|
|
import TreeDirView from '../../components/tree-dir-view/tree-dir-view';
|
|
|
|
|
|
|
|
class MainPanel extends Component {
|
|
|
|
|
|
|
|
onMenuClick = () => {
|
|
|
|
this.props.onMenuClick();
|
|
|
|
}
|
|
|
|
|
|
|
|
onEditClick = (e) => {
|
|
|
|
// const w=window.open('about:blank')
|
|
|
|
e.preventDefault();
|
|
|
|
window.location.href= serviceUrl + '/lib/' + repoID + '/file' + this.props.filePath + '?mode=edit';
|
|
|
|
}
|
|
|
|
|
|
|
|
onMainNavBarClick = (e) => {
|
|
|
|
this.props.onMainNavBarClick(e.target.dataset.path);
|
|
|
|
}
|
|
|
|
|
|
|
|
switchViewMode = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.switchViewMode(e.target.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
let filePathList = this.props.filePath.split('/');
|
|
|
|
let nodePath = "";
|
|
|
|
let pathElem = filePathList.map((item, index) => {
|
|
|
|
if (item === "") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (index === (filePathList.length - 1)) {
|
|
|
|
return (
|
|
|
|
<span key={index}><span className="path-split">/</span>{item}</span>
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
nodePath += "/" + item;
|
|
|
|
return (
|
|
|
|
<a key={index} className="custom-link" data-path={nodePath} onClick={this.onMainNavBarClick}><span className="path-split">/</span>{item}</a>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="wiki-main-panel o-hidden">
|
|
|
|
<div className="main-panel-top panel-top">
|
|
|
|
<span className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none" title="Side Nav Menu" onClick={this.onMenuClick}></span>
|
|
|
|
<div className="wiki-page-ops">
|
2018-09-18 02:11:37 +00:00
|
|
|
{ permission &&
|
2018-09-12 02:32:31 +00:00
|
|
|
<a className="btn btn-secondary btn-topbar" title="Edit File" onClick={this.onEditClick}>{gettext("Edit")}</a>
|
|
|
|
}
|
|
|
|
<a className="btn btn-secondary btn-topbar sf2-icon-list-view" id='list' title={gettext("List")} onClick={this.switchViewMode}></a>
|
|
|
|
<a className="btn btn-secondary btn-topbar sf2-icon-grid-view" id='grid' title={gettext("Grid")} onClick={this.switchViewMode}></a>
|
|
|
|
</div>
|
|
|
|
<div className="common-toolbar">
|
2018-09-12 06:15:27 +00:00
|
|
|
{isPro && <Search onSearchedClick={this.props.onSearchedClick}
|
2018-09-18 02:11:37 +00:00
|
|
|
placeholder={gettext("Search files in this library")}
|
2018-09-12 06:15:27 +00:00
|
|
|
/>
|
|
|
|
}
|
2018-09-18 02:11:37 +00:00
|
|
|
<Notification />
|
|
|
|
<Account />
|
2018-09-12 02:32:31 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="cur-view-main">
|
|
|
|
<div className="cur-view-path">
|
|
|
|
<div className="path-containter">
|
2018-09-12 06:15:27 +00:00
|
|
|
<a href={siteRoot + '#common/'} className="normal">{gettext("Libraries")}</a>
|
2018-09-12 02:32:31 +00:00
|
|
|
<span className="path-split">/</span>
|
|
|
|
<a href={siteRoot + 'wiki/lib/' + repoID + '/'} className="normal">{slug}</a>
|
|
|
|
{pathElem}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="cur-view-container">
|
|
|
|
{ this.props.isViewFileState && <MarkdownViewer
|
|
|
|
markdownContent={this.props.content}
|
|
|
|
latestContributor={this.props.latestContributor}
|
|
|
|
lastModified = {this.props.lastModified}
|
|
|
|
onLinkClick={this.props.onLinkClick}
|
|
|
|
isFileLoading={this.props.isFileLoading}
|
|
|
|
/>}
|
|
|
|
{ !this.props.isViewFileState &&
|
|
|
|
<TreeDirView
|
|
|
|
node={this.props.changedNode}
|
|
|
|
onMainNodeClick={this.props.onMainNodeClick}
|
|
|
|
>
|
|
|
|
</TreeDirView>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MainPanel;
|