forgeplus-react/src/forge/Index.js

85 lines
2.4 KiB
JavaScript
Raw Normal View History

2020-06-02 18:54:46 +08:00
import React, { Component } from "react";
2020-03-16 14:12:11 +08:00
2020-06-02 18:54:46 +08:00
import { Route, Switch } from "react-router-dom";
import { withRouter } from "react-router";
2020-03-16 14:12:11 +08:00
2020-06-02 18:54:46 +08:00
import { SnackbarHOC } from "educoder";
import { CNotificationHOC } from "../modules/courses/common/CNotificationHOC";
import { TPMIndexHOC } from "../modules/tpm/TPMIndexHOC";
2020-07-17 17:36:36 +08:00
import Handbook from './Component/Handbook';
2020-06-22 14:07:06 +08:00
import "./css/index.scss";
2020-03-16 14:12:11 +08:00
2020-06-02 18:54:46 +08:00
import Loadable from "react-loadable";
import Loading from "../Loading";
import { ImageLayerOfCommentHOC } from "../modules/page/layers/ImageLayerOfCommentHOC";
2020-03-16 14:12:11 +08:00
const ProjectNew = Loadable({
2020-07-06 16:11:44 +08:00
loader: () => import("./New/Index"),
2020-05-11 14:18:32 +08:00
loading: Loading,
2020-06-02 18:54:46 +08:00
});
2020-03-16 14:12:11 +08:00
const ProjectIndex = Loadable({
2020-06-02 18:54:46 +08:00
loader: () => import("./Main/Index"),
2020-05-11 14:18:32 +08:00
loading: Loading,
2020-06-02 18:54:46 +08:00
});
2020-03-16 14:12:11 +08:00
const ProjectDetail = Loadable({
2020-06-02 18:54:46 +08:00
loader: () => import("./Main/Detail"),
2020-05-11 14:18:32 +08:00
loading: Loading,
2020-06-02 18:54:46 +08:00
});
2020-03-16 14:12:11 +08:00
2020-06-15 15:31:21 +08:00
const Infos = Loadable({
loader: () => import("./users/Infos"),
loading: Loading,
});
2020-06-02 18:54:46 +08:00
class Index extends Component {
2020-05-11 14:18:32 +08:00
render() {
return (
2020-03-16 14:12:11 +08:00
<div className="newMain clearfix">
2020-07-17 17:36:36 +08:00
<Handbook />
2020-03-16 14:12:11 +08:00
<Switch {...this.props}>
2021-01-28 11:48:21 +08:00
<Route
path="/projects/:projectsType/new/:OIdentifier"
render={(props) => (
<ProjectNew {...this.props} {...props} />
)}
></Route>
2020-06-02 18:54:46 +08:00
<Route
path="/projects/:projectsType/new"
render={(props) => (
2020-06-15 15:31:21 +08:00
<ProjectNew {...this.props} {...props} />
2020-06-02 18:54:46 +08:00
)}
2020-03-16 14:12:11 +08:00
></Route>
2020-06-02 18:54:46 +08:00
<Route
2020-08-12 18:13:18 +08:00
path="/projects/:owner/:projectsId"
2020-06-02 18:54:46 +08:00
render={(props) => (
2020-06-15 15:31:21 +08:00
<ProjectDetail {...this.props} {...props} />
2020-06-02 18:54:46 +08:00
)}
2020-03-16 14:12:11 +08:00
></Route>
2020-06-02 18:54:46 +08:00
<Route
path="/projects"
render={(props) => (
2020-06-15 15:31:21 +08:00
<ProjectIndex {...this.props} {...props} />
)}
></Route>
<Route
exact
path="/"
render={(props) => (
this.props.current_user && this.props.current_user.login ?
2020-06-18 14:35:36 +08:00
<Infos {...this.props} {...props} />
2020-06-15 15:31:21 +08:00
:
<ProjectIndex {...this.props} {...props} />
2020-06-02 18:54:46 +08:00
)}
2020-03-16 14:12:11 +08:00
></Route>
</Switch>
</div>
2020-06-02 18:54:46 +08:00
);
2020-03-16 14:12:11 +08:00
}
}
2020-06-02 18:54:46 +08:00
export default withRouter(
ImageLayerOfCommentHOC({
imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget",
parentSelector: ".newMain",
})(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(Index))))
);