@@ -209,5 +86,5 @@ export function OrgSelector({
);
}
- return orgSelectorContent;
+ return picker;
}
diff --git a/src/components/resource-launcher/LauncherOrgSelector.tsx b/src/components/resource-launcher/LauncherOrgSelector.tsx
index 04773d2de..80510d77e 100644
--- a/src/components/resource-launcher/LauncherOrgSelector.tsx
+++ b/src/components/resource-launcher/LauncherOrgSelector.tsx
@@ -1,28 +1,10 @@
"use client";
-import {
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
- CommandList
-} from "@app/components/ui/command";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger
-} from "@app/components/ui/popover";
-import { cn } from "@app/lib/cn";
-import { ListUserOrgsResponse } from "@server/routers/org";
-import { Check, ChevronDown, Plus } from "lucide-react";
-import { usePathname, useRouter } from "next/navigation";
-import { useMemo, useState } from "react";
-import { useTranslations } from "next-intl";
+import { OrgPicker } from "@app/components/OrgPicker";
import { Button } from "@app/components/ui/button";
-import { useEnvContext } from "@app/hooks/useEnvContext";
-import { useUserContext } from "@app/hooks/useUserContext";
-import { build } from "@server/build";
+import { ListUserOrgsResponse } from "@server/routers/org";
+import { ChevronDown } from "lucide-react";
+import { useTranslations } from "next-intl";
type LauncherOrgSelectorProps = {
orgId?: string;
@@ -30,111 +12,21 @@ type LauncherOrgSelectorProps = {
};
export function LauncherOrgSelector({ orgId, orgs }: LauncherOrgSelectorProps) {
- const [open, setOpen] = useState(false);
- const router = useRouter();
- const pathname = usePathname();
const t = useTranslations();
- const { env } = useEnvContext();
- const { user } = useUserContext();
-
const selectedOrg = orgs?.find((org) => org.orgId === orgId);
- let canCreateOrg = !env.flags.disableUserCreateOrg || user.serverAdmin;
- if (build === "saas" && user.type !== "internal") {
- canCreateOrg = false;
- }
-
- const sortedOrgs = useMemo(() => {
- if (!orgs?.length) {
- return orgs ?? [];
- }
- return [...orgs].sort((a, b) => {
- const aPrimary = Boolean(a.isPrimaryOrg);
- const bPrimary = Boolean(b.isPrimaryOrg);
- if (aPrimary && !bPrimary) {
- return -1;
- }
- if (!aPrimary && bPrimary) {
- return 1;
- }
- return 0;
- });
- }, [orgs]);
-
return (
-