Skip to content

Commit

Permalink
chore: update version to 1.1.3 and enhance project management features
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
mamertofabian committed Dec 27, 2024
1 parent 5e60f3d commit 43ea8fb
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 133 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/lib/components/GitHubSettings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,14 @@
<Button
type="submit"
class="w-full bg-blue-600 hover:bg-blue-700 text-white"
disabled={!isSettingsValid || buttonDisabled || isValidatingToken || isTokenValid === false}
disabled={buttonDisabled || isValidatingToken || !githubToken || !repoOwner || !repoName || !branch || isTokenValid === false}
>
{#if isValidatingToken}
Validating...
{:else if buttonDisabled}
{status}
{:else}
{status ? status : "Save Settings"}
Save Settings
{/if}
</Button>
</form>
Expand Down
157 changes: 109 additions & 48 deletions src/lib/components/ProjectsList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,61 @@
const githubService = new GitHubService(githubToken);
let commitCounts: Record<string, number> = {};
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,
Expand All @@ -50,7 +90,36 @@
</script>

<div class="space-y-2">
{#if Object.keys(projectSettings).length === 0}
<div class="flex items-center gap-2 mb-4">
<div class="flex-1 relative">
<input
type="text"
bind:value={searchQuery}
placeholder="Search projects..."
class="w-full bg-transparent border border-slate-800 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-slate-700"
/>
{#if searchQuery}
<Button
variant="ghost"
size="icon"
class="absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7"
on:click={() => searchQuery = ''}
>
<X class="h-4 w-4" />
</Button>
{/if}
</div>
<label class="flex items-center gap-2 text-sm text-slate-400">
<input
type="checkbox"
bind:checked={showPublicRepos}
class="w-4 h-4 rounded border-slate-800 bg-transparent"
/>
Show Public Repos
</label>
</div>

{#if filteredProjects.length === 0}
<div class="flex flex-col items-center justify-center p-4 text-center space-y-6">
<div class="space-y-2">
<p class="text-sm text-slate-400 text-orange-400">No projects found. Create or load an existing project to get started.</p>
Expand All @@ -66,49 +135,39 @@
{/if}
</div>
{:else}
<div class="flex items-center gap-2 mb-4">
<div class="flex-1 relative">
<input
type="text"
bind:value={searchQuery}
placeholder="Search projects..."
class="w-full bg-transparent border border-slate-800 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-slate-700"
/>
{#if searchQuery}
<Button
variant="ghost"
size="icon"
class="absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7"
on:click={() => searchQuery = ''}
>
<X class="h-4 w-4" />
</Button>
{/if}
</div>
</div>

{#each filteredProjects as [projectId, settings]}
<div class="border border-slate-800 rounded-lg p-3 hover:bg-slate-800/50 transition-colors group {currentlyLoadedProjectId === projectId ? 'bg-slate-800/30 border-slate-700' : ''}">
{#each filteredProjects as project}
<div class="border border-slate-800 rounded-lg p-3 hover:bg-slate-800/50 transition-colors group {project.projectId === currentlyLoadedProjectId ? 'bg-slate-800/30 border-slate-700' : ''}">
<div class="flex items-center justify-between">
<div class="space-y-0.5">
<h3 class="font-medium">
{settings.repoName} ({settings.branch})
{#if currentlyLoadedProjectId === projectId}
{project.repoName} {project.branch ? `(${project.branch})` : ''}
{#if project.projectId === currentlyLoadedProjectId}
<span class="text-xs text-emerald-500 ml-2">(Current)</span>
{/if}
{#if project.isPublicOnly}
<span class="text-xs text-blue-500 ml-2">(Public Repo)</span>
{/if}
</h3>
<div class="flex gap-2 text-xs text-slate-400">
<p>Bolt ID: {projectId} ({commitCounts[projectId] ?? '...'} commits)</p>
<div class="flex flex-col gap-1 text-xs text-slate-400">
{#if project.projectId}
<p>Bolt ID: {project.projectId} ({commitCounts[project.projectId] ?? '...'} commits)</p>
{/if}
{#if project.description}
<p>{project.description}</p>
{/if}
{#if project.language}
<p>Language: {project.language}</p>
{/if}
</div>
</div>
<div class="flex gap-1">
{#if currentlyLoadedProjectId !== projectId}
{#if project.projectId && project.projectId !== currentlyLoadedProjectId}
<Button
variant="ghost"
size="icon"
title="Open in Bolt"
class="h-8 w-8 opacity-70 group-hover:opacity-100"
on:click={() => openBoltProject(projectId)}
on:click={() => project.projectId && openBoltProject(project.projectId)}
>
<Zap class="h-5 w-5" />
</Button>
Expand All @@ -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)}
>
<Github class="h-5 w-5" />
</Button>
<Button
variant="ghost"
size="icon"
title="Import from GitHub to Bolt"
class="h-8 w-8 opacity-70 group-hover:opacity-100"
on:click={() => importFromGitHub(repoOwner, settings.repoName)}
>
<Import class="h-5 w-5" />
</Button>
{#if !project.projectId}
<Button
variant="ghost"
size="icon"
title="Import from GitHub to Bolt"
class="h-8 w-8 opacity-70 group-hover:opacity-100"
on:click={() => importFromGitHub(repoOwner, project.repoName)}
>
<Import class="h-5 w-5" />
</Button>
{/if}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 43ea8fb

Please sign in to comment.