From 43ea8fb8d34a4e11cfbe6bd4691b5f27cc32036c Mon Sep 17 00:00:00 2001 From: Mamerto Fabian Jr Date: Fri, 27 Dec 2024 14:35:45 +0800 Subject: [PATCH] chore: update version to 1.1.3 and enhance project management features - Bumped the version number from 1.1.2 to 1.1.3 in manifest.json to reflect the latest release. - Improved the GitHubSettings component by refining the button's disabled state logic for better user experience. - Enhanced the ProjectsList component to support loading and displaying public repositories, including a search feature and toggle for showing public repos. - Added a new method in GitHubService to fetch public repositories, improving integration with GitHub's API. - Refactored the App component to streamline project management and improve the layout for better usability. --- manifest.json | 2 +- src/lib/components/GitHubSettings.svelte | 6 +- src/lib/components/ProjectsList.svelte | 157 +++++++++++++++------- src/popup/App.svelte | 158 +++++++++++------------ src/services/GitHubService.ts | 31 +++++ 5 files changed, 221 insertions(+), 133 deletions(-) diff --git a/manifest.json b/manifest.json index 0f81927..0a86ba4 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Bolt to GitHub", - "version": "1.1.2", + "version": "1.1.3", "description": "Automatically process your Bolt project zip files and upload them to your GitHub repository.", "icons": { "16": "assets/icons/icon16.png", diff --git a/src/lib/components/GitHubSettings.svelte b/src/lib/components/GitHubSettings.svelte index daa9815..3dccacd 100644 --- a/src/lib/components/GitHubSettings.svelte +++ b/src/lib/components/GitHubSettings.svelte @@ -266,12 +266,14 @@ diff --git a/src/lib/components/ProjectsList.svelte b/src/lib/components/ProjectsList.svelte index 102fc81..c1ee005 100644 --- a/src/lib/components/ProjectsList.svelte +++ b/src/lib/components/ProjectsList.svelte @@ -12,21 +12,61 @@ const githubService = new GitHubService(githubToken); let commitCounts: Record = {}; + let publicRepos: Array<{ + name: string; + description: string | null; + html_url: string; + created_at: string; + updated_at: string; + language: string | null; + }> = []; let searchQuery = ''; - let filteredProjects: [string, { repoName: string; branch: string }][] = []; + let showPublicRepos = true; + let filteredProjects: Array<{ + projectId?: string; + repoName: string; + branch?: string; + isPublicOnly?: boolean; + description?: string | null; + language?: string | null; + }> = []; + + async function loadPublicRepos() { + console.log('Loading public repos for', repoOwner); + try { + publicRepos = await githubService.listPublicRepos(repoOwner); + } catch (error) { + console.error('Failed to load public repos:', error); + } + } $: { - filteredProjects = Object.entries(projectSettings) - .filter(([projectId, settings]) => { - // Only apply search filter - const matchesSearch = settings.repoName.toLowerCase().includes(searchQuery.toLowerCase()); - return matchesSearch; - }); + const existingProjects = Object.entries(projectSettings).map(([projectId, settings]) => ({ + projectId, + repoName: settings.repoName, + branch: settings.branch, + isPublicOnly: false + })); + + const publicOnlyRepos = showPublicRepos ? publicRepos + .filter(repo => !Object.values(projectSettings).some(s => s.repoName === repo.name)) + .map(repo => ({ + repoName: repo.name, + isPublicOnly: true, + description: repo.description, + language: repo.language + })) : []; + + filteredProjects = [...existingProjects, ...publicOnlyRepos] + .filter(project => project.repoName.toLowerCase().includes(searchQuery.toLowerCase())); } onMount(async () => { - // Fetch commit counts for all projects + // Load public repos + await loadPublicRepos(); + + // Fetch commit counts for projects that have IDs for (const [projectId, settings] of Object.entries(projectSettings)) { commitCounts[projectId] = await githubService.getCommitCount( repoOwner, @@ -50,7 +90,36 @@
- {#if Object.keys(projectSettings).length === 0} +
+
+ + {#if searchQuery} + + {/if} +
+ +
+ + {#if filteredProjects.length === 0}

No projects found. Create or load an existing project to get started.

@@ -66,49 +135,39 @@ {/if}
{:else} -
-
- - {#if searchQuery} - - {/if} -
-
- - {#each filteredProjects as [projectId, settings]} -
+ {#each filteredProjects as project} +

- {settings.repoName} ({settings.branch}) - {#if currentlyLoadedProjectId === projectId} + {project.repoName} {project.branch ? `(${project.branch})` : ''} + {#if project.projectId === currentlyLoadedProjectId} (Current) {/if} + {#if project.isPublicOnly} + (Public Repo) + {/if}

-
-

Bolt ID: {projectId} ({commitCounts[projectId] ?? '...'} commits)

+
+ {#if project.projectId} +

Bolt ID: {project.projectId} ({commitCounts[project.projectId] ?? '...'} commits)

+ {/if} + {#if project.description} +

{project.description}

+ {/if} + {#if project.language} +

Language: {project.language}

+ {/if}
- {#if currentlyLoadedProjectId !== projectId} + {#if project.projectId && project.projectId !== currentlyLoadedProjectId} @@ -118,19 +177,21 @@ size="icon" title="Open GitHub Repository" class="h-8 w-8 opacity-70 group-hover:opacity-100" - on:click={() => openGitHubRepo(repoOwner, settings.repoName)} + on:click={() => openGitHubRepo(repoOwner, project.repoName)} > - + {#if !project.projectId} + + {/if}
diff --git a/src/popup/App.svelte b/src/popup/App.svelte index 8ec891e..35190c8 100644 --- a/src/popup/App.svelte +++ b/src/popup/App.svelte @@ -17,6 +17,7 @@ import type { GitHubSettingsInterface } from "$lib/types"; import ProjectsList from "$lib/components/ProjectsList.svelte"; import { GitHubService } from "../services/GitHubService"; + import { Button } from "$lib/components/ui/button"; let githubToken: string = ""; let repoOwner = ""; @@ -63,6 +64,8 @@ } } + $: console.log('repoOwner', repoOwner); + onMount(async () => { // Add dark mode to the document document.documentElement.classList.add('dark'); @@ -172,86 +175,6 @@
- {#if isBoltSite && parsedProjectId} - -
- - - - - - Bolt to GitHub - Bolt to GitHub v{version} - - - Upload and sync your Bolt projects to GitHub - - - - - - - -
- -
-
-
- - - - - - - Projects - - Manage your Bolt projects and their GitHub repositories - - - - - - - - - - - - GitHub Settings - - Configure your GitHub repository settings - - - - - - - - - {:else} @@ -263,11 +186,82 @@ - + {#if isBoltSite && parsedProjectId} + +
+ + + + + + +
+ +
+
+ + + + + + + + + GitHub Settings + + Configure your GitHub repository settings + + + + + + + + + {:else if repoOwner} + + {:else} +
+
+

No projects found. Create or load an existing project to get started.

+ {#if !isBoltSite} + + {/if} +
+
+ {/if}
- {/if}