Merge pull request #3375 from fosrl/resource-launcher

Resource launcher
This commit is contained in:
Owen Schwartz
2026-07-01 21:19:19 -04:00
committed by GitHub
62 changed files with 6698 additions and 1269 deletions

View File

@@ -0,0 +1,9 @@
import { Loader2 } from "lucide-react";
export default function OrgPageLoading() {
return (
<div className="flex items-center justify-center py-16">
<Loader2 className="size-6 animate-spin text-muted-foreground" />
</div>
);
}

View File

@@ -1,9 +1,9 @@
import { Layout } from "@app/components/Layout";
import MemberResourcesPortal from "@app/components/MemberResourcesPortal";
import ResourceLauncher from "@app/components/resource-launcher/ResourceLauncher";
import { internal } from "@app/lib/api";
import { authCookieHeader } from "@app/lib/api/cookies";
import { fetchLauncherPageData } from "@app/lib/launcherServerData";
import { verifySession } from "@app/lib/auth/verifySession";
import { pullEnv } from "@app/lib/pullEnv";
import UserProvider from "@app/providers/UserProvider";
import { ListUserOrgsResponse } from "@server/routers/org";
import { GetOrgOverviewResponse } from "@server/routers/org/getOrgOverview";
@@ -13,12 +13,14 @@ import { cache } from "react";
type OrgPageProps = {
params: Promise<{ orgId: string }>;
searchParams: Promise<Record<string, string>>;
};
export const dynamic = "force-dynamic";
export default async function OrgPage(props: OrgPageProps) {
const params = await props.params;
const orgId = params.orgId;
const env = pullEnv();
if (!orgId) {
redirect(`/`);
@@ -40,12 +42,6 @@ export default async function OrgPage(props: OrgPageProps) {
overview = res.data.data;
} catch (e) {}
// If user is admin or owner, redirect to settings
if (overview?.isAdmin || overview?.isOwner) {
redirect(`/${orgId}/settings`);
}
// For non-admin users, show the member resources portal
let orgs: ListUserOrgsResponse["orgs"] = [];
try {
const getOrgs = cache(async () =>
@@ -60,10 +56,40 @@ export default async function OrgPage(props: OrgPageProps) {
}
} catch (e) {}
const isAdminOrOwner = Boolean(overview?.isAdmin || overview?.isOwner);
const searchParams = new URLSearchParams(await props.searchParams);
const launcherData = overview
? await fetchLauncherPageData(
orgId,
searchParams,
await authCookieHeader()
)
: null;
return (
<UserProvider user={user}>
<Layout orgId={orgId} navItems={[]} orgs={orgs}>
{overview && <MemberResourcesPortal orgId={orgId} />}
<Layout
orgId={orgId}
orgs={orgs}
navItems={[]}
showSidebar={false}
launcherMode
showViewAsAdmin={isAdminOrOwner}
>
{overview && launcherData ? (
<ResourceLauncher
orgId={orgId}
isAdmin={isAdminOrOwner}
views={launcherData.views}
activeViewId={launcherData.activeViewId}
config={launcherData.config}
savedConfig={launcherData.savedConfig}
groups={launcherData.groups}
groupsPagination={launcherData.groupsPagination}
resourcesByGroupKey={launcherData.resourcesByGroupKey}
/>
) : null}
</Layout>
</UserProvider>
);

View File

@@ -107,7 +107,15 @@ export default async function Page(props: {
}
if (targetOrgId) {
return <RedirectToOrg targetOrgId={targetOrgId} />;
const targetOrg = orgs.find((org) => org.orgId === targetOrgId);
return (
<RedirectToOrg
targetOrgId={targetOrgId}
isAdminOrOwner={Boolean(
targetOrg?.isAdmin || targetOrg?.isOwner
)}
/>
);
}
return (