2022-05-05 05:37:50 +00:00
|
|
|
import React from "react";
|
2024-08-06 14:52:22 +00:00
|
|
|
import AdminConfig from "ee/pages/AdminSettings/config";
|
2022-02-11 18:08:46 +00:00
|
|
|
import { Redirect, useParams } from "react-router";
|
2024-08-06 14:52:22 +00:00
|
|
|
import { SettingCategories } from "ee/pages/AdminSettings/config/types";
|
2023-08-28 15:37:32 +00:00
|
|
|
import SettingsForm from "pages/AdminSettings/SettingsForm";
|
2024-08-06 14:52:22 +00:00
|
|
|
import { getWrapperCategory } from "ee/utils/adminSettingsHelpers";
|
2022-12-01 06:30:50 +00:00
|
|
|
import { useSelector } from "react-redux";
|
|
|
|
|
import { getCurrentUser } from "selectors/usersSelectors";
|
2024-08-06 14:52:22 +00:00
|
|
|
import { getTenantPermissions } from "ee/selectors/tenantSelectors";
|
2023-09-29 20:42:56 +00:00
|
|
|
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
|
2024-08-06 14:52:22 +00:00
|
|
|
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
|
|
|
|
|
import { getAdminSettingsPath } from "ee/utils/BusinessFeatures/adminSettingsHelpers";
|
2022-02-11 18:08:46 +00:00
|
|
|
|
|
|
|
|
const Main = () => {
|
2024-07-31 15:41:28 +00:00
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2022-02-11 18:08:46 +00:00
|
|
|
const params = useParams() as any;
|
2022-06-08 13:18:15 +00:00
|
|
|
const { category, selected: subCategory } = params;
|
2022-12-01 06:30:50 +00:00
|
|
|
const user = useSelector(getCurrentUser);
|
|
|
|
|
const tenantPermissions = useSelector(getTenantPermissions);
|
|
|
|
|
const isSuperUser = user?.isSuperUser || false;
|
2023-08-28 15:37:32 +00:00
|
|
|
const wrapperCategory = getWrapperCategory(
|
|
|
|
|
AdminConfig.wrapperCategories,
|
|
|
|
|
subCategory,
|
|
|
|
|
category,
|
|
|
|
|
);
|
2023-09-29 20:42:56 +00:00
|
|
|
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
|
2022-10-17 13:09:09 +00:00
|
|
|
|
2022-05-18 04:53:08 +00:00
|
|
|
if (!!wrapperCategory?.component) {
|
2022-02-11 18:08:46 +00:00
|
|
|
const { component: WrapperCategoryComponent } = wrapperCategory;
|
2022-12-09 14:43:47 +00:00
|
|
|
return <WrapperCategoryComponent category={wrapperCategory} />;
|
2022-02-11 18:08:46 +00:00
|
|
|
} else if (
|
|
|
|
|
!Object.values(SettingCategories).includes(category) ||
|
|
|
|
|
(subCategory && !Object.values(SettingCategories).includes(subCategory))
|
|
|
|
|
) {
|
2022-12-01 06:30:50 +00:00
|
|
|
return (
|
|
|
|
|
<Redirect
|
2023-09-29 20:42:56 +00:00
|
|
|
to={getAdminSettingsPath(
|
|
|
|
|
isFeatureEnabled,
|
|
|
|
|
isSuperUser,
|
|
|
|
|
tenantPermissions,
|
|
|
|
|
)}
|
2022-12-01 06:30:50 +00:00
|
|
|
/>
|
|
|
|
|
);
|
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;
|