fix: added OPENAPI_ENABLED & API_ENABLED variables

This commit is contained in:
charles-gauthereau
2026-05-28 22:08:49 +02:00
parent d49d8f52c4
commit 174ff0886c
9 changed files with 88 additions and 63 deletions
@@ -2,6 +2,7 @@ import { currentUser } from "@/lib/auth/current-user";
import { getAccounts, getSession, getSessions } from "@/lib/auth/auth";
import { LoggedInButtonClient } from "./logged-in-button";
import { SUPPORTED_PROVIDERS } from "@/lib/auth/config";
import { env } from "@/env.mjs";
export const LoggedInButton = async () => {
const user = await currentUser();
@@ -11,6 +12,7 @@ export const LoggedInButton = async () => {
if (!user) return null;
return (
<LoggedInButtonClient
user={user}
@@ -19,6 +21,7 @@ export const LoggedInButton = async () => {
currentSession={currentSession.session}
accounts={accounts}
providers={SUPPORTED_PROVIDERS.filter((p) => p.isActive)}
apiEnabled={env.API_ENABLED}
/>
);
};
+3 -1
View File
@@ -14,9 +14,10 @@ type LoggedInButtonClientProps = {
currentSession: Session;
accounts: Account[];
providers: AuthProviderConfig[];
apiEnabled: boolean;
};
export const LoggedInButtonClient = ({ user, sessions, currentSession, accounts, providers }: LoggedInButtonClientProps) => {
export const LoggedInButtonClient = ({ user, sessions, currentSession, accounts, providers, apiEnabled }: LoggedInButtonClientProps) => {
return (
<LoggedInDropdown
user={user}
@@ -27,6 +28,7 @@ export const LoggedInButtonClient = ({ user, sessions, currentSession, accounts,
// @ts-ignore
accounts={accounts}
providers={providers}
apiEnabled={apiEnabled}
>
<SidebarMenuButton type="button" className="h-auto justify-between py-2" data-testid="profile-dropdown">
<div className="flex items-center gap-2">
+3 -1
View File
@@ -16,9 +16,10 @@ export type LoggedInDropdownProps = PropsWithChildren<{
accounts: Account[];
children: ReactNode;
providers: AuthProviderConfig[];
apiEnabled: boolean;
}>;
export const LoggedInDropdown = ({ user, sessions, currentSession, accounts, children, providers }: LoggedInDropdownProps) => {
export const LoggedInDropdown = ({ user, sessions, currentSession, accounts, children, providers, apiEnabled }: LoggedInDropdownProps) => {
const router = useRouter();
const [isModalOpen, setIsModalOpen] = useState(false);
@@ -33,6 +34,7 @@ export const LoggedInDropdown = ({ user, sessions, currentSession, accounts, chi
open={isModalOpen}
onOpenChange={setIsModalOpen}
providers={providers}
apiEnabled={apiEnabled}
/>
<DropdownMenu>
<DropdownMenuTrigger asChild>{children}</DropdownMenuTrigger>
+3 -2
View File
@@ -19,9 +19,10 @@ type ProfileModalProps = {
accounts: Account[];
onOpenChange: (open: boolean) => void;
providers: AuthProviderConfig[];
apiEnabled: boolean;
};
export const ProfileModal = ({ user, sessions, currentSession, accounts, open, onOpenChange, providers }: ProfileModalProps) => {
export const ProfileModal = ({ user, sessions, currentSession, accounts, open, onOpenChange, providers, apiEnabled }: ProfileModalProps) => {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="w-[95vw] h-[90vh] max-w-md lg:max-w-[1000px] lg:h-[800px] pb-6 p-0 overflow-hidden flex flex-col outline-none gap-0 rounded-xl bg-background">
@@ -54,7 +55,7 @@ export const ProfileModal = ({ user, sessions, currentSession, accounts, open, o
</TabsContent>
<TabsContent value="account" className="mt-0 h-full p-6 lg:p-10 outline-none focus-visible:ring-0">
<ProfileAccount user={user} />
<ProfileAccount user={user} apiEnabled={apiEnabled} />
</TabsContent>
<TabsContent value="appearance" className="mt-0 h-full p-6 lg:p-10 outline-none focus-visible:ring-0">
+5 -15
View File
@@ -48,9 +48,11 @@ import { copyToClipboardWithMeta } from "@/components/common/copy-button";
interface ProfileAccountProps {
user: User;
apiEnabled: boolean;
}
export function ProfileAccount({ user }: ProfileAccountProps) {
export function ProfileAccount({ user, apiEnabled }: ProfileAccountProps) {
const router = useRouter();
const [isAddApiKeyOpen, setIsAddApiKeyOpen] = useState(false);
@@ -159,20 +161,6 @@ export function ProfileAccount({ user }: ProfileAccountProps) {
const { mutate: addApiKey, isPending: isAddingApikey } = useMutation({
mutationFn: async () => {
// const permissions = {
// organization: ["read", "read-write"],
// }
//
// const result = await authClient.apiKey.create({
// name: apiKeyName || "My API Key",
// prefix: "sk_",
// permissions
// });
//
// if (result?.error) {
// throw result.error;
// }
const result = await createApiKeysAction({
name: apiKeyName || "My API Key"
});
@@ -335,6 +323,7 @@ export function ProfileAccount({ user }: ProfileAccountProps) {
</Form>
</div>
{apiEnabled === true && (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="space-y-1">
@@ -434,6 +423,7 @@ export function ProfileAccount({ user }: ProfileAccountProps) {
)}
</div>
</div>
)}
</div>
<Dialog