From 19137c934b3ae847c7ec0797dbe3ef34bc87a0c4 Mon Sep 17 00:00:00 2001 From: KevIsDev Date: Tue, 25 Feb 2025 00:41:44 +0000 Subject: [PATCH] add: various improvements to connections - improved organisation of connections (collapsibles) - improved deploy button - improved unique chat deployments --- .../tabs/connections/ConnectionsTab.tsx | 67 ----------- .../tabs/connections/GithubConnection.tsx | 59 +++++----- .../tabs/connections/NetlifyConnection.tsx | 12 +- .../header/HeaderActionButtons.client.tsx | 109 +++++++++--------- app/lib/persistence/db.ts | 2 +- 5 files changed, 95 insertions(+), 154 deletions(-) diff --git a/app/components/@settings/tabs/connections/ConnectionsTab.tsx b/app/components/@settings/tabs/connections/ConnectionsTab.tsx index ac55f2cd..450d241a 100644 --- a/app/components/@settings/tabs/connections/ConnectionsTab.tsx +++ b/app/components/@settings/tabs/connections/ConnectionsTab.tsx @@ -1,73 +1,8 @@ -import React, { useState, useEffect } from 'react'; -import { logStore } from '~/lib/stores/logs'; import { motion } from 'framer-motion'; -import { toast } from 'react-toastify'; import { GithubConnection } from './GithubConnection'; import { NetlifyConnection } from './NetlifyConnection'; -interface GitHubUserResponse { - login: string; - avatar_url: string; - html_url: string; - name: string; - bio: string; - public_repos: number; - followers: number; - following: number; - created_at: string; - public_gists: number; -} - -interface GitHubRepoInfo { - name: string; - full_name: string; - html_url: string; - description: string; - stargazers_count: number; - forks_count: number; - default_branch: string; - updated_at: string; - languages_url: string; -} - -interface GitHubOrganization { - login: string; - avatar_url: string; - html_url: string; -} - -interface GitHubEvent { - id: string; - type: string; - repo: { - name: string; - }; - created_at: string; -} - -interface GitHubLanguageStats { - [language: string]: number; -} - -interface GitHubStats { - repos: GitHubRepoInfo[]; - totalStars: number; - totalForks: number; - organizations: GitHubOrganization[]; - recentActivity: GitHubEvent[]; - languages: GitHubLanguageStats; - totalGists: number; -} - -interface GitHubConnection { - user: GitHubUserResponse | null; - token: string; - tokenType: 'classic' | 'fine-grained'; - stats?: GitHubStats; -} - export default function ConnectionsTab() { - return (
{/* Header */} @@ -85,9 +20,7 @@ export default function ConnectionsTab() {

- {/* GitHub Connection */} - {/* Netlify Connection */}
diff --git a/app/components/@settings/tabs/connections/GithubConnection.tsx b/app/components/@settings/tabs/connections/GithubConnection.tsx index 771eabdb..c6142834 100644 --- a/app/components/@settings/tabs/connections/GithubConnection.tsx +++ b/app/components/@settings/tabs/connections/GithubConnection.tsx @@ -73,7 +73,6 @@ export function GithubConnection() { }); const [isLoading, setIsLoading] = useState(true); const [isConnecting, setIsConnecting] = useState(false); - const [isFetchingStats, setIsFetchingStats] = useState(false); const [expandedSections, setExpandedSections] = useState({ organizations: false, languages: false, @@ -82,16 +81,14 @@ export function GithubConnection() { }); const toggleSection = (section: keyof typeof expandedSections) => { - setExpandedSections(prev => ({ + setExpandedSections((prev) => ({ ...prev, - [section]: !prev[section] + [section]: !prev[section], })); }; const fetchGitHubStats = async (token: string) => { try { - setIsFetchingStats(true); - const reposResponse = await fetch( 'https://api.github.com/user/repos?sort=updated&per_page=10&affiliation=owner,organization_member,collaborator', { @@ -168,7 +165,6 @@ export function GithubConnection() { logStore.logError('Failed to fetch GitHub stats', { error }); toast.error('Failed to fetch GitHub statistics'); } finally { - setIsFetchingStats(false); } }; @@ -188,6 +184,7 @@ export function GithubConnection() { fetchGitHubStats(parsed.token); } } + setIsLoading(false); }, []); @@ -401,16 +398,18 @@ export function GithubConnection() { {/* Organizations Section */} {connection.stats.organizations.length > 0 && (
- {expandedSections.organizations && (
@@ -433,16 +432,18 @@ export function GithubConnection() { {/* Languages Section */}
- {expandedSections.languages && (
@@ -463,16 +464,18 @@ export function GithubConnection() { {/* Recent Activity Section */}
- {expandedSections.recentActivity && (
@@ -503,16 +506,18 @@ export function GithubConnection() { {/* Repositories Section */}
- {expandedSections.repositories && (
@@ -574,4 +579,4 @@ function LoadingSpinner() {
); -} \ No newline at end of file +} diff --git a/app/components/@settings/tabs/connections/NetlifyConnection.tsx b/app/components/@settings/tabs/connections/NetlifyConnection.tsx index 920bf646..490cb2d1 100644 --- a/app/components/@settings/tabs/connections/NetlifyConnection.tsx +++ b/app/components/@settings/tabs/connections/NetlifyConnection.tsx @@ -214,16 +214,18 @@ export function NetlifyConnection() {
) : (
- {isSitesExpanded && connection.stats?.sites?.length ? (
diff --git a/app/components/header/HeaderActionButtons.client.tsx b/app/components/header/HeaderActionButtons.client.tsx index d4ccb181..34a1e42c 100644 --- a/app/components/header/HeaderActionButtons.client.tsx +++ b/app/components/header/HeaderActionButtons.client.tsx @@ -33,6 +33,7 @@ export function HeaderActionButtons({}: HeaderActionButtonsProps) { } } document.addEventListener('mousedown', handleClickOutside); + return () => document.removeEventListener('mousedown', handleClickOutside); }, []); @@ -109,6 +110,7 @@ export function HeaderActionButtons({}: HeaderActionButtonsProps) { } const fileContents = await getAllFiles(buildPath); + // Use chatId instead of artifact.id const existingSiteId = localStorage.getItem(`netlify-site-${currentChatId}`); @@ -209,65 +211,64 @@ export function HeaderActionButtons({}: HeaderActionButtonsProps) { className="px-4 hover:bg-bolt-elements-item-backgroundActive flex items-center gap-2" > {isDeploying ? 'Deploying...' : 'Deploy'} -
+
{isDropdownOpen && (
- - - + + +
)}
diff --git a/app/lib/persistence/db.ts b/app/lib/persistence/db.ts index ca46ef5d..57b23b87 100644 --- a/app/lib/persistence/db.ts +++ b/app/lib/persistence/db.ts @@ -5,7 +5,7 @@ import type { ChatHistoryItem } from './useChatHistory'; export interface IChatMetadata { gitUrl: string; gitBranch?: string; - netlifySiteId?: string; // Add this field + netlifySiteId?: string; } const logger = createScopedLogger('ChatHistory');