mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
feat(supabase): add credentials handling for Supabase API keys and URL
This commit introduces the ability to fetch and store Supabase API keys and URL credentials when a project is selected. This enables the application to dynamically configure the Supabase connection environment variables, improving the integration with Supabase services. The changes include updates to the Supabase connection logic, new API endpoints, and modifications to the chat and prompt components to utilize the new credentials.
This commit is contained in:
@@ -169,6 +169,10 @@ export const ChatImpl = memo(
|
||||
supabase: {
|
||||
isConnected: supabaseConn.isConnected,
|
||||
hasSelectedProject: !!selectedProject,
|
||||
credentials: {
|
||||
supabaseUrl: supabaseConn?.credentials?.supabaseUrl,
|
||||
anonKey: supabaseConn?.credentials?.anonKey,
|
||||
},
|
||||
},
|
||||
},
|
||||
sendExtraMessageFields: true,
|
||||
|
||||
@@ -21,11 +21,11 @@ export function SupabaseConnection() {
|
||||
handleCreateProject,
|
||||
updateToken,
|
||||
isConnected,
|
||||
fetchProjectApiKeys,
|
||||
} = useSupabaseConnection();
|
||||
|
||||
const currentChatId = useStore(chatId);
|
||||
|
||||
// Add event listener for opening the connection dialog
|
||||
useEffect(() => {
|
||||
const handleOpenConnectionDialog = () => {
|
||||
setIsDialogOpen(true);
|
||||
@@ -38,7 +38,6 @@ export function SupabaseConnection() {
|
||||
};
|
||||
}, [setIsDialogOpen]);
|
||||
|
||||
// Load the selected project from localStorage when connected or chat changes
|
||||
useEffect(() => {
|
||||
if (isConnected && currentChatId) {
|
||||
const savedProjectId = localStorage.getItem(`supabase-project-${currentChatId}`);
|
||||
@@ -70,6 +69,12 @@ export function SupabaseConnection() {
|
||||
}
|
||||
}, [isConnected, supabaseConn.token]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isConnected && supabaseConn.selectedProjectId && supabaseConn.token) {
|
||||
fetchProjectApiKeys(supabaseConn.selectedProjectId).catch(console.error);
|
||||
}
|
||||
}, [isConnected, supabaseConn.selectedProjectId, supabaseConn.token]);
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<div className="flex border border-bolt-elements-borderColor rounded-md overflow-hidden mr-2 text-sm">
|
||||
|
||||
Reference in New Issue
Block a user