2021-10-18 07:47:55 +00:00
|
|
|
import { APPLICATIONS_URL } from "constants/routes";
|
2022-12-14 15:02:13 +00:00
|
|
|
import { showAdminSettings } from "@appsmith/utils/adminSettingsHelpers";
|
2021-10-18 07:47:55 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import { useSelector } from "react-redux";
|
|
|
|
|
import { Redirect, RouteComponentProps } from "react-router";
|
|
|
|
|
import { getCurrentUser } from "selectors/usersSelectors";
|
|
|
|
|
|
|
|
|
|
export default function WithSuperUserHOC(
|
|
|
|
|
Component: React.ComponentType<RouteComponentProps>,
|
|
|
|
|
) {
|
|
|
|
|
return function Wrapped(props: RouteComponentProps) {
|
|
|
|
|
const user = useSelector(getCurrentUser);
|
2022-04-07 17:57:32 +00:00
|
|
|
if (!user) return null;
|
2022-12-01 06:30:50 +00:00
|
|
|
if (!showAdminSettings(user)) {
|
2021-10-18 07:47:55 +00:00
|
|
|
return <Redirect to={APPLICATIONS_URL} />;
|
|
|
|
|
}
|
|
|
|
|
return <Component {...props} />;
|
|
|
|
|
};
|
|
|
|
|
}
|