2022-05-05 05:37:50 +00:00
|
|
|
import React from "react";
|
2022-02-11 18:08:46 +00:00
|
|
|
import AdminConfig from "./config";
|
|
|
|
|
import { Redirect, useParams } from "react-router";
|
|
|
|
|
import { SettingCategories } from "@appsmith/pages/AdminSettings/config/types";
|
2022-04-12 10:50:01 +00:00
|
|
|
import { ADMIN_SETTINGS_CATEGORY_DEFAULT_PATH } from "constants/routes";
|
2022-05-05 05:37:50 +00:00
|
|
|
import SettingsForm from "pages/Settings/SettingsForm";
|
2022-10-17 13:09:09 +00:00
|
|
|
import { AuditLogsUpgradePage } from "../Upgrade/AuditLogsUpgradePage";
|
|
|
|
|
import { AccessControlUpgradePage } from "../Upgrade/AccessControlUpgradePage";
|
2022-11-01 16:53:27 +00:00
|
|
|
import { UsageUpgradePage } from "../Upgrade/UsageUpgradePage";
|
2022-02-11 18:08:46 +00:00
|
|
|
|
|
|
|
|
const Main = () => {
|
|
|
|
|
const params = useParams() as any;
|
2022-06-08 13:18:15 +00:00
|
|
|
const { category, selected: subCategory } = params;
|
2022-02-11 18:08:46 +00:00
|
|
|
const wrapperCategory =
|
|
|
|
|
AdminConfig.wrapperCategories[subCategory ?? category];
|
|
|
|
|
|
2022-10-17 13:09:09 +00:00
|
|
|
/* New flow, where data is hand written and processed differently than old flow
|
|
|
|
|
* In old flow, config and a factory was used to generate the Main content.
|
|
|
|
|
*/
|
|
|
|
|
if (category === "access-control") {
|
|
|
|
|
return <AccessControlUpgradePage />;
|
|
|
|
|
}
|
|
|
|
|
if (category === "audit-logs") {
|
|
|
|
|
return <AuditLogsUpgradePage />;
|
|
|
|
|
}
|
2022-11-01 16:53:27 +00:00
|
|
|
if (category === "usage") {
|
|
|
|
|
return <UsageUpgradePage />;
|
|
|
|
|
}
|
2022-10-17 13:09:09 +00:00
|
|
|
|
|
|
|
|
/* Old, still working flow; config, factory based */
|
2022-05-18 04:53:08 +00:00
|
|
|
if (!!wrapperCategory?.component) {
|
2022-02-11 18:08:46 +00:00
|
|
|
const { component: WrapperCategoryComponent } = wrapperCategory;
|
|
|
|
|
return <WrapperCategoryComponent />;
|
|
|
|
|
} else if (
|
|
|
|
|
!Object.values(SettingCategories).includes(category) ||
|
|
|
|
|
(subCategory && !Object.values(SettingCategories).includes(subCategory))
|
|
|
|
|
) {
|
2022-03-25 10:43:26 +00:00
|
|
|
return <Redirect to={ADMIN_SETTINGS_CATEGORY_DEFAULT_PATH} />;
|
2022-02-11 18:08:46 +00:00
|
|
|
} else {
|
|
|
|
|
return <SettingsForm />;
|
2021-10-18 07:47:55 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-02-11 18:08:46 +00:00
|
|
|
export default Main;
|