Skip to content

Commit ae99807

Browse files
committed
Allow admin tooltips while impersonating
1 parent bf4e505 commit ae99807

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

apps/webapp/app/components/admin/debugTooltip.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import {
55
TooltipProvider,
66
TooltipTrigger,
77
} from "~/components/primitives/Tooltip";
8+
import { useIsImpersonating } from "~/hooks/useOrganizations";
89
import { useHasAdminAccess } from "~/hooks/useUser";
910

1011
export function AdminDebugTooltip({ children }: { children: React.ReactNode }) {
1112
const hasAdminAccess = useHasAdminAccess();
13+
const isImpersonating = useIsImpersonating();
1214

13-
if (!hasAdminAccess) {
15+
if (!hasAdminAccess && !isImpersonating) {
1416
return null;
1517
}
1618

apps/webapp/app/hooks/useOrganizations.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,11 @@ export function useIsNewOrganizationPage(matches?: UIMatch[]): boolean {
5353
export const useOrganizationChanged = (action: (org: MatchedOrganization | undefined) => void) => {
5454
useChanged(useOptionalOrganization, action);
5555
};
56+
57+
export function useIsImpersonating(matches?: UIMatch[]) {
58+
const data = useTypedMatchesData<typeof orgLoader>({
59+
id: "routes/_app.orgs.$organizationSlug",
60+
matches,
61+
});
62+
return data?.isImpersonating === true;
63+
}

0 commit comments

Comments
 (0)