Client: move general pages to lazy loading from react-router-dom
This commit is contained in:
parent
2a6210f9eb
commit
b7050a86e2
@ -25,17 +25,20 @@
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
import React from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import PropTypes from "prop-types";
|
||||
import Section from "@docspace/shared/components/section";
|
||||
import SectionWrapper from "SRC_DIR/components/Section";
|
||||
import { SectionHeaderContent, SectionBodyContent } from "./Section";
|
||||
|
||||
import Dialogs from "../Home/Section/AccountsBody/Dialogs";
|
||||
|
||||
import withCultureNames from "SRC_DIR/HOCs/withCultureNames";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { withTranslation } from "react-i18next";
|
||||
|
||||
import Section from "@docspace/shared/components/section";
|
||||
|
||||
import SectionWrapper from "SRC_DIR/components/Section";
|
||||
import PrivateRoute from "SRC_DIR/components/PrivateRouteWrapper";
|
||||
import Dialogs from "SRC_DIR/pages/Home/Section/AccountsBody/Dialogs";
|
||||
import withCultureNames from "SRC_DIR/HOCs/withCultureNames";
|
||||
|
||||
import { SectionHeaderContent, SectionBodyContent } from "./Section";
|
||||
|
||||
class Profile extends React.Component {
|
||||
componentDidMount() {
|
||||
const {
|
||||
@ -137,7 +140,7 @@ Profile.propTypes = {
|
||||
language: PropTypes.string,
|
||||
};
|
||||
|
||||
export default inject(
|
||||
const ComponentPure = inject(
|
||||
({
|
||||
authStore,
|
||||
settingsStore,
|
||||
@ -194,3 +197,17 @@ export default inject(
|
||||
};
|
||||
},
|
||||
)(observer(withTranslation(["Profile", "Common"])(withCultureNames(Profile))));
|
||||
|
||||
export const Component = () => {
|
||||
const location = useLocation();
|
||||
|
||||
const fileManagement = location.pathname.includes("file-management");
|
||||
|
||||
return (
|
||||
<PrivateRoute withCollaborator={fileManagement} restricted={fileManagement}>
|
||||
<ComponentPure />
|
||||
</PrivateRoute>
|
||||
);
|
||||
};
|
||||
|
||||
Component.displayName = "Profile";
|
||||
|
@ -24,16 +24,7 @@
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
import React from "react";
|
||||
import { Navigate } from "react-router-dom";
|
||||
import loadable from "@loadable/component";
|
||||
|
||||
import PrivateRoute from "../components/PrivateRouteWrapper";
|
||||
import componentLoader from "@docspace/shared/utils/component-loader";
|
||||
|
||||
const Profile = loadable(() =>
|
||||
componentLoader(() => import("../pages/Profile")),
|
||||
);
|
||||
|
||||
const generalRoutes = [
|
||||
{
|
||||
@ -51,35 +42,19 @@ const generalRoutes = [
|
||||
},
|
||||
{
|
||||
path: "login",
|
||||
element: (
|
||||
<PrivateRoute>
|
||||
<Profile />
|
||||
</PrivateRoute>
|
||||
),
|
||||
lazy: () => import("../pages/Profile"),
|
||||
},
|
||||
{
|
||||
path: "notifications",
|
||||
element: (
|
||||
<PrivateRoute>
|
||||
<Profile />
|
||||
</PrivateRoute>
|
||||
),
|
||||
lazy: () => import("../pages/Profile"),
|
||||
},
|
||||
{
|
||||
path: "file-management",
|
||||
element: (
|
||||
<PrivateRoute withCollaborator restricted>
|
||||
<Profile />
|
||||
</PrivateRoute>
|
||||
),
|
||||
lazy: () => import("../pages/Profile"),
|
||||
},
|
||||
{
|
||||
path: "interface-theme",
|
||||
element: (
|
||||
<PrivateRoute>
|
||||
<Profile />
|
||||
</PrivateRoute>
|
||||
),
|
||||
lazy: () => import("../pages/Profile"),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -27,7 +27,13 @@
|
||||
import PortalSettingsRoutes from "./portalSettings";
|
||||
import ClientRoutes from "./client";
|
||||
import ConfirmRoutes from "./confirm";
|
||||
import { generalRoutes } from "./general";
|
||||
|
||||
const routes = [...ClientRoutes, PortalSettingsRoutes, ...ConfirmRoutes];
|
||||
const routes = [
|
||||
...ClientRoutes,
|
||||
PortalSettingsRoutes,
|
||||
...ConfirmRoutes,
|
||||
// ...generalRoutes,
|
||||
];
|
||||
|
||||
export default routes;
|
||||
|
@ -37,7 +37,6 @@ import ErrorBoundary from "../components/ErrorBoundaryWrapper";
|
||||
import { generalRoutes } from "./general";
|
||||
import SettingsContainer from "../pages/PortalSettings/categories/integration/LDAP/sub-components/SettingsContainer";
|
||||
import SyncContainer from "../pages/PortalSettings/categories/integration/LDAP/sub-components/SyncContainer";
|
||||
import StyledLdapPage from "../pages/PortalSettings/categories/integration/LDAP/styled-components/StyledLdapPage";
|
||||
|
||||
const PortalSettings = loadable(() =>
|
||||
componentLoader(() => import("../pages/PortalSettings")),
|
||||
|
Loading…
Reference in New Issue
Block a user