2018-09-21 06:16:15 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
2018-09-29 10:32:53 +00:00
|
|
|
import { Router } from '@reach/router';
|
2018-10-09 02:56:59 +00:00
|
|
|
import { siteRoot } from './utils/constants';
|
2018-09-21 06:16:15 +00:00
|
|
|
import SidePanel from './components/side-panel';
|
|
|
|
import MainPanel from './components/main-panel';
|
|
|
|
import DraftsView from './pages/drafts/drafts-view';
|
2018-10-15 07:51:29 +00:00
|
|
|
import DraftContent from './pages/drafts/draft-content';
|
|
|
|
import ReviewContent from './pages/drafts/review-content';
|
2018-09-21 06:16:15 +00:00
|
|
|
import FilesActivities from './pages/dashboard/files-activities';
|
2018-10-08 07:33:40 +00:00
|
|
|
import Starred from './pages/starred/starred';
|
2018-11-10 09:14:07 +00:00
|
|
|
import LinkedDevices from './pages/linked-devices/linked-devices';
|
2018-11-01 09:52:59 +00:00
|
|
|
import editUtilties from './utils/editor-utilties';
|
2018-11-19 03:53:44 +00:00
|
|
|
import ShareAdminLibraries from './pages/share-admin/libraries';
|
|
|
|
import ShareAdminFolders from './pages/share-admin/folders';
|
|
|
|
import ShareAdminShareLinks from './pages/share-admin/share-links';
|
|
|
|
import ShareAdminUploadLinks from './pages/share-admin/upload-links';
|
2018-09-21 06:16:15 +00:00
|
|
|
|
|
|
|
import 'seafile-ui';
|
|
|
|
import './assets/css/fa-solid.css';
|
|
|
|
import './assets/css/fa-regular.css';
|
|
|
|
import './assets/css/fontawesome.css';
|
|
|
|
import './css/layout.css';
|
|
|
|
import './css/toolbar.css';
|
|
|
|
import './css/search.css';
|
|
|
|
|
|
|
|
class App extends Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isOpen: false,
|
2018-09-25 01:13:06 +00:00
|
|
|
isSidePanelClosed: false,
|
2018-11-01 09:52:59 +00:00
|
|
|
draftCounts: 0,
|
2018-11-08 02:36:41 +00:00
|
|
|
draftList:[],
|
|
|
|
isLoadingDraft: true,
|
2018-09-21 06:16:15 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-11-01 09:52:59 +00:00
|
|
|
componentDidMount() {
|
2018-11-08 02:36:41 +00:00
|
|
|
this.getDrafts();
|
2018-11-01 09:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getDrafts = () => {
|
|
|
|
editUtilties.listDrafts().then(res => {
|
|
|
|
this.setState({
|
|
|
|
draftCounts: res.data.draft_counts,
|
2018-11-08 02:36:41 +00:00
|
|
|
draftList: res.data.data,
|
|
|
|
isLoadingDraft: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
updateDraftsList = (draft_id) => {
|
|
|
|
this.setState({
|
|
|
|
draftCounts: this.state.draftCounts - 1,
|
|
|
|
draftList: this.state.draftList.filter(draft => draft.id != draft_id),
|
|
|
|
});
|
2018-11-01 09:52:59 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 01:13:06 +00:00
|
|
|
onCloseSidePanel = () => {
|
|
|
|
this.setState({
|
|
|
|
isSidePanelClosed: !this.state.isSidePanelClosed
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onShowSidePanel = () => {
|
|
|
|
this.setState({
|
|
|
|
isSidePanelClosed: !this.state.isSidePanelClosed
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-09-21 06:16:15 +00:00
|
|
|
render() {
|
2018-11-01 09:52:59 +00:00
|
|
|
|
2018-10-08 07:33:40 +00:00
|
|
|
let href = window.location.href.split('/');
|
2018-09-21 06:16:15 +00:00
|
|
|
let currentTab = href[href.length - 2];
|
2018-09-27 07:09:44 +00:00
|
|
|
|
2018-09-21 06:16:15 +00:00
|
|
|
return (
|
|
|
|
<div id="main">
|
2018-11-01 09:52:59 +00:00
|
|
|
<SidePanel isSidePanelClosed={this.state.isSidePanelClosed} onCloseSidePanel={this.onCloseSidePanel} currentTab={currentTab} draftCounts={this.state.draftCounts} />
|
2018-09-21 06:16:15 +00:00
|
|
|
|
2018-09-27 07:09:44 +00:00
|
|
|
<MainPanel onShowSidePanel={this.onShowSidePanel}>
|
2018-09-21 06:16:15 +00:00
|
|
|
<Router>
|
2018-09-27 07:09:44 +00:00
|
|
|
<FilesActivities path={siteRoot + 'dashboard'} />
|
2018-10-15 07:51:29 +00:00
|
|
|
<DraftsView path={siteRoot + 'drafts'} currentTab={currentTab}>
|
2018-11-08 02:36:41 +00:00
|
|
|
<DraftContent path='/' getDrafts={this.getDrafts}
|
|
|
|
isLoadingDraft={this.state.isLoadingDraft}
|
|
|
|
draftList={this.state.draftList}
|
|
|
|
updateDraftsList={this.updateDraftsList}
|
|
|
|
/>
|
2018-10-15 07:51:29 +00:00
|
|
|
<ReviewContent path='reviews' />
|
|
|
|
</DraftsView>
|
2018-10-08 07:33:40 +00:00
|
|
|
<Starred path={siteRoot + 'starred'} />
|
2018-11-10 09:14:07 +00:00
|
|
|
<LinkedDevices path={siteRoot + 'linked-devices'} />
|
2018-11-19 03:53:44 +00:00
|
|
|
<ShareAdminLibraries path={siteRoot + 'share-admin-libs'} />
|
|
|
|
<ShareAdminFolders path={siteRoot + 'share-admin-folders'} />
|
|
|
|
<ShareAdminShareLinks path={siteRoot + 'share-admin-share-links'} />
|
|
|
|
<ShareAdminUploadLinks path={siteRoot + 'share-admin-upload-links'} />
|
2018-09-21 06:16:15 +00:00
|
|
|
</Router>
|
|
|
|
</MainPanel>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
<App />,
|
|
|
|
document.getElementById('wrapper')
|
|
|
|
);
|