forked from github/plane
041c3af35a
* refactor: shift instance admin restriction content to seperate component. fix: instance components export logic. * style: fix sidebar dropdown `God Mode` icon padding. * style: update profile settings user dropdown menu width. * fix: update input type to `password` for Client Secret and API/ Access Key fields. * style: update loader design for all forms. * fix: typo * style: ui updates. * chore: add show/ hide button for all password fields.
34 lines
978 B
TypeScript
34 lines
978 B
TypeScript
import { FC, ReactNode } from "react";
|
|
import { observer } from "mobx-react-lite";
|
|
// hooks
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
// components
|
|
import { InstanceAdminRestriction } from "components/instance";
|
|
|
|
export interface IAdminAuthWrapper {
|
|
children: ReactNode;
|
|
}
|
|
|
|
export const AdminAuthWrapper: FC<IAdminAuthWrapper> = observer(({ children }) => {
|
|
// store
|
|
const {
|
|
user: { isUserInstanceAdmin },
|
|
workspace: { workspaceSlug },
|
|
user: { currentUserSettings },
|
|
} = useMobxStore();
|
|
|
|
// redirect url
|
|
const redirectWorkspaceSlug =
|
|
workspaceSlug ||
|
|
currentUserSettings?.workspace?.last_workspace_slug ||
|
|
currentUserSettings?.workspace?.fallback_workspace_slug ||
|
|
"";
|
|
|
|
// if user does not have admin access to the instance
|
|
if (isUserInstanceAdmin !== undefined && isUserInstanceAdmin === false) {
|
|
return <InstanceAdminRestriction redirectWorkspaceSlug={redirectWorkspaceSlug} />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
});
|