import { useEffect, useState } from "react"; import { useLocation } from "wouter"; import { Building2, ChevronLeft, ChevronRight, Plus, Search } from "lucide-react"; import { can, type RoleDef } from "@/lib/adminAccess"; import { describeDirectoryError, listRoles } from "@/lib/adminDirectory"; import { drawableLogo, getTenants, queryTenants, type DirectoryTenant } from "@/lib/adminTenants"; import { formatSize } from "@/lib/format"; import { proxiedImageUrl } from "@/lib/html"; import { plural, t } from "@/lib/i18n"; import { useSession } from "@/store/session"; import { Empty, Spinner } from "@/ui/misc"; import { usePermissions } from "./usePermissions"; import { TenantSheet } from "./TenantSheet"; const PAGE_SIZE = 50; /** * Tenants: separate organisations on one server, each with its own people, * domains and limits. * * The section is offered to whoever may read tenants, but on a server that does * not report Enterprise the page is only the notice: tenants there hold nobody * to anything beyond an ordinary user's permissions, so there is nothing worth * creating or listing. A server that reports no edition at all counts as not * Enterprise. */ export function TenantsAdmin({ selectedId }: { selectedId?: string }) { const edition = useSession((s) => s.session?.ihasmail?.server?.edition ?? null); if (edition !== "enterprise") { return (
{t("Separate organisations on one server, each with its own people, domains and limits.")}
{t("Tenants are a Stalwart Enterprise feature. This server does not report Enterprise, so anyone inside a tenant has only an ordinary user's permissions.")}