Skip to content

feat: perform checks and import repo #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"pre-commit": "lint-staged"
},
"dependencies": {
"@radix-ui/react-alert-dialog": "^1.1.14",
"@radix-ui/react-avatar": "^1.1.10",
"@radix-ui/react-dropdown-menu": "^2.1.15",
"@radix-ui/react-select": "^2.2.5",
Expand All @@ -26,8 +27,10 @@
"lucide-react": "^0.513.0",
"next": "15.3.3",
"next-auth": "5.0.0-beta.28",
"next-themes": "^0.4.6",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"sonner": "^2.0.5",
"tailwind-merge": "^3.3.0"
},
"devDependencies": {
Expand Down
93 changes: 93 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions src/app/(app)/[repo]/_components/create-config-alert-dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { DEFAULT_CONFIG } from '@/constants';
import { createContent } from '@/lib/api/github';
import { useSession } from 'next-auth/react';
import { Dispatch, SetStateAction, useState } from 'react';

interface Props {
open: boolean;
setOpen: Dispatch<SetStateAction<boolean>>;
repo: string;
}

export default function CreateConfigAlertDialog({ open, setOpen, repo }: Props) {
const { data: session } = useSession();
const [isCreating, setIsCreating] = useState(false);

async function handleCreateConfig() {
try {
setIsCreating(true);
const created = await createContent({
accessToken: session?.accessToken,
username: session?.user?.username,
repo,
path: '.gitloom/config.json',
message: 'chore: create .gitloom/config.json',
content: DEFAULT_CONFIG,
});

console.log('config created: ', created);
} finally {
setIsCreating(false);
setOpen(false);
}
}

return (
<AlertDialog open={open}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Configuration File Required</AlertDialogTitle>
<AlertDialogDescription>
We noticed your repository doesn&apos;t have a{' '}
<code className="font-mono text-sm">.gitloom/config.json</code> file. This file helps
Gitloom understand your project structure and workflows.
</AlertDialogDescription>
<div className="bg-secondary/25 mt-2 flex gap-4 rounded-md border p-4">
<Avatar className="size-6">
<AvatarImage src={session?.user?.image ?? undefined} />
<AvatarFallback>{session?.user?.name?.[0] ?? 'U'}</AvatarFallback>
</Avatar>
<div className="flex-1">
<p className="text-sm font-medium">Auto-generated configuration</p>
<p className="text-muted-foreground text-sm">Will create default config with:</p>
<ul className="text-muted-foreground mt-1 ml-4 list-disc text-sm">
<li>Latest version</li>
<li>Contents and its locations</li>
</ul>
</div>
<span className="text-muted-foreground text-xs">Just now</span>
</div>
</AlertDialogHeader>
<AlertDialogFooter className="gap-4">
<AlertDialogCancel onClick={() => setOpen(false)} disabled={isCreating}>
Cancel
</AlertDialogCancel>
<AlertDialogAction
className="bg-primary hover:bg-primary/90"
onClick={handleCreateConfig}
disabled={isCreating}
>
Create Config
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Loading