Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat: implement GitHub issues import functionality

Andrej Acevskief1bb636dc18
diff --git a/apps/api/src/github-integration/controllers/import-issues.ts b/apps/api/src/github-integration/controllers/import-issues.ts
new file mode 100644
index 000000000..cacc8cf91
--- /dev/null
+++ b/apps/api/src/github-integration/controllers/import-issues.ts
@@ -0,0 +1,56 @@
+import { and, eq, notLike } from "drizzle-orm";
+import db from "../../database";
+import { githubIntegrationTable, taskTable } from "../../database/schema";
+import createGithubApp from "../utils/create-github-app";
+
+const githubApp = createGithubApp();
+
+export async function importIssues(projectId: string) {
+ const githubIntegration = await db.query.githubIntegrationTable.findFirst({
+ where: eq(githubIntegrationTable.projectId, projectId),
+ });
+
+ if (!githubIntegration) {
+ return { error: "GitHub integration not found" };
+ }
+
+ const installationOctokit = await githubApp?.getInstallationOctokit(
+ githubIntegration.installationId ?? 0,
+ );
+
+ if (!installationOctokit) {
+ return { error: "GitHub app not found" };
+ }
+
+ const { data: issues } = await installationOctokit.rest.issues.listForRepo({
+ owner: githubIntegration.repositoryOwner,
+ repo: githubIntegration.repositoryName,
+ });
+
+ for (const issue of issues ?? []) {
+ const task = await db.query.taskTable.findFirst({
+ where: and(
+ eq(taskTable.number, issue.number),
+ eq(taskTable.projectId, projectId),
+ notLike(taskTable.title, "[Kaneo]%"),
+ ),
+ });
+
+ if (task) {
+ continue;
+ }
+
+ await db.insert(taskTable).values({
+ title: issue.title,
+ description: issue.body,
+ projectId,
+ number: issue.number,
+ status: "to-do",
+ priority: "low",
+ position: 0,
+ createdAt: new Date(issue.created_at),
+ });
+ }
+
+ return { success: true, message: "Issues imported" };
+}
diff --git a/apps/api/src/github-integration/index.ts b/apps/api/src/github-integration/index.ts
index a258a6f3c..8feec1774 100644
--- a/apps/api/src/github-integration/index.ts
+++ b/apps/api/src/github-integration/index.ts
@@ -5,6 +5,7 @@ import { subscribeToEvent } from "../events";
import createGithubIntegration from "./controllers/create-github-integration";
import deleteGithubIntegration from "./controllers/delete-github-integration";
import getGithubIntegration from "./controllers/get-github-integration";
+import { importIssues } from "./controllers/import-issues";
import listUserRepositories from "./controllers/list-user-repositories";
import verifyGithubInstallation from "./controllers/verify-github-installation";
import createGithubApp from "./utils/create-github-app";
@@ -99,6 +100,15 @@ const githubIntegration = new Hono()
return c.json(result);
},
)
+ .post(
+ "/import-issues",
+ zValidator("json", z.object({ projectId: z.string() })),
+ async (c) => {
+ const { projectId } = c.req.valid("json");
+ const result = await importIssues(projectId);
+ return c.json(result);
+ },
+ )
.post("/webhook", async (c) => {
try {
if (!githubApp) {
diff --git a/apps/web/src/components/project/github-integration-settings.tsx b/apps/web/src/components/project/github-integration-settings.tsx
index 88ede9959..d8234dd0a 100644
--- a/apps/web/src/components/project/github-integration-settings.tsx
+++ b/apps/web/src/components/project/github-integration-settings.tsx
@@ -1,5 +1,13 @@
import { RepositoryBrowserModal } from "@/components/project/repository-browser-modal";
+import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card";
import {
Form,
FormControl,
@@ -16,17 +24,21 @@ import {
useDeleteGithubIntegration,
useVerifyGithubInstallation,
} from "@/hooks/mutations/github-integration/use-create-github-integration";
+import useImportGithubIssues from "@/hooks/mutations/github-integration/use-import-github-issues";
import useGetGithubIntegration from "@/hooks/queries/github-integration/use-get-github-integration";
import { cn } from "@/lib/cn";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
import {
AlertTriangle,
CheckCircle,
+ Download,
ExternalLink,
GitBranch,
Github,
+ Import,
Link,
RefreshCw,
+ Settings,
Unlink,
XCircle,
} from "lucide-react";
@@ -58,6 +70,8 @@ export function GitHubIntegrationSettings({
useDeleteGithubIntegration();
const { mutateAsync: verifyInstallation, isPending: isVerifying } =
useVerifyGithubInstallation();
+ const { mutateAsync: importIssues, isPending: isImporting } =
+ useImportGithubIssues();
const [verificationResult, setVerificationResult] =
React.useState<VerifyGithubInstallationResponse | null>(null);
@@ -194,20 +208,53 @@ export function GitHubIntegrationSettings({
}
};
+ const handleImportIssues = async () => {
+ try {
+ await importIssues({ projectId });
+ toast.success("Issues imported successfully");
+ } catch (error) {
+ toast.error(
+ error instanceof Error ? error.message : "Failed to import issues",
+ );
+ }
+ };
+
if (isLoading) {
return (
- <div className="space-y-4">
- <div className="h-4 bg-gray-200 rounded animate-pulse" />
- <div className="h-10 bg-gray-200 rounded animate-pulse" />
- <div className="h-10 bg-gray-200 rounded animate-pulse" />
+ <div className="space-y-6">
+ <Card>
+ <CardHeader>
+ <div className="flex items-center gap-3">
+ <div className="p-2 bg-gray-100 dark:bg-gray-800 rounded-lg">
+ <Github className="w-6 h-6" />
+ </div>
+ <div>
+ <div className="h-5 bg-gray-200 rounded animate-pulse w-40" />
+ <div className="h-4 bg-gray-200 rounded animate-pulse w-64 mt-2" />
+ </div>
+ </div>
+ </CardHeader>
+ <CardContent>
+ <div className="space-y-4">
+ <div className="h-4 bg-gray-200 rounded animate-pulse" />
+ <div className="h-10 bg-gray-200 rounded animate-pulse" />
+ <div className="h-10 bg-gray-200 rounded animate-pulse" />
+ </div>
+ </CardContent>
+ </Card>
</div>
);
}
const isConnected = !!integration && integration.isActive;
+ const canImport =
+ isConnected &&
+ verificationResult?.isInstalled &&
+ verificationResult?.hasRequiredPermissions;
return (
<div className="space-y-6">
+ {/* Header */}
<div className="flex items-start gap-4">
<div className="p-2 bg-gray-100 dark:bg-gray-800 rounded-lg">
<Github className="w-6 h-6" />
@@ -215,244 +262,334 @@ export function GitHubIntegrationSettings({
<div className="flex-1">
<h3 className="text-lg font-semibold">GitHub Integration</h3>
<p className="text-sm text-gray-600 dark:text-gray-400">
- Connect this project to a GitHub repository to automatically create
- issues when tasks are created in Kaneo.
+ Connect this project to a GitHub repository to sync issues and
+ tasks.
</p>
</div>
</div>
- {isConnected && (
- <div className="flex items-center gap-2 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg">
- <CheckCircle className="w-4 h-4 text-green-600 dark:text-green-400" />
- <span className="text-sm text-green-700 dark:text-green-300">
- Connected to{" "}
- <code className="px-1 py-0.5 bg-green-100 dark:bg-green-800 rounded text-xs">
- {integration.repositoryOwner}/{integration.repositoryName}
- </code>
- </span>
- </div>
- )}
+ {/* Status Card */}
+ <Card>
+ <CardHeader className="pb-3">
+ <div className="flex items-center justify-between">
+ <CardTitle className="text-base">Connection Status</CardTitle>
+ {isConnected && (
+ <Badge variant="secondary" className="gap-1">
+ <CheckCircle className="w-3 h-3" />
+ Connected
+ </Badge>
+ )}
+ </div>
+ </CardHeader>
+ <CardContent>
+ {isConnected ? (
+ <div className="space-y-3">
+ <div className="flex items-center gap-2 text-sm">
+ <Github className="w-4 h-4" />
+ <span className="font-medium">
+ {integration.repositoryOwner}/{integration.repositoryName}
+ </span>
+ <a
+ href={`https://github.com/${integration.repositoryOwner}/${integration.repositoryName}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-blue-600 hover:text-blue-800"
+ >
+ <ExternalLink className="w-3 h-3" />
+ </a>
+ </div>
- {verificationResult && (
- <div
- className={cn(
- "flex items-start gap-2 p-3 border rounded-lg",
- verificationResult.isInstalled &&
- verificationResult.hasRequiredPermissions
- ? "bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800"
- : verificationResult.isInstalled
- ? "bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800"
- : verificationResult.repositoryExists
- ? "bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800"
- : "bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800",
- )}
- >
- {verificationResult.isInstalled &&
- verificationResult.hasRequiredPermissions ? (
- <CheckCircle className="w-4 h-4 text-green-600 dark:text-green-400 mt-0.5 flex-shrink-0" />
- ) : verificationResult.isInstalled ||
- verificationResult.repositoryExists ? (
- <AlertTriangle className="w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0" />
+ {verificationResult && (
+ <div className="flex items-center gap-2 text-sm">
+ {verificationResult.isInstalled &&
+ verificationResult.hasRequiredPermissions ? (
+ <>
+ <CheckCircle className="w-4 h-4 text-green-600" />
+ <span className="text-green-700">
+ App properly configured
+ </span>
+ </>
+ ) : verificationResult.isInstalled ? (
+ <>
+ <AlertTriangle className="w-4 h-4 text-amber-600" />
+ <span className="text-amber-700">
+ Missing permissions
+ </span>
+ </>
+ ) : (
+ <>
+ <XCircle className="w-4 h-4 text-red-600" />
+ <span className="text-red-700">App not installed</span>
+ </>
+ )}
+ </div>
+ )}
+ </div>
) : (
- <XCircle className="w-4 h-4 text-red-600 dark:text-red-400 mt-0.5 flex-shrink-0" />
+ <p className="text-sm text-gray-600 dark:text-gray-400">
+ No repository connected. Configure a repository below to get
+ started.
+ </p>
)}
- <div
- className={cn(
- "text-sm flex-1",
- verificationResult.isInstalled &&
- verificationResult.hasRequiredPermissions
- ? "text-green-700 dark:text-green-300"
- : verificationResult.isInstalled ||
- verificationResult.repositoryExists
- ? "text-amber-700 dark:text-amber-300"
- : "text-red-700 dark:text-red-300",
- )}
- >
- <p className="font-medium">{verificationResult.message}</p>
-
- {verificationResult.isInstalled &&
- !verificationResult.hasRequiredPermissions &&
- verificationResult.missingPermissions && (
- <div className="mt-2">
- <p className="text-xs mb-2">
- Missing permissions:{" "}
- <strong>
- {verificationResult.missingPermissions.join(", ")}
- </strong>
- </p>
- <div className="flex gap-2">
- {verificationResult.settingsUrl && (
- <Button
- variant="outline"
- size="sm"
- onClick={() =>
- window.open(verificationResult.settingsUrl, "_blank")
- }
- className="gap-2"
- >
- <ExternalLink className="w-3 h-3" />
- Update Permissions
- </Button>
+ </CardContent>
+ </Card>
+
+ {/* Configuration Card */}
+ <Card>
+ <CardHeader>
+ <CardTitle className="text-base flex items-center gap-2">
+ <Settings className="w-4 h-4" />
+ Repository Configuration
+ </CardTitle>
+ <CardDescription>
+ Connect to a GitHub repository to enable issue synchronization
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <Form {...form}>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
+ <div className="grid grid-cols-2 gap-4">
+ <FormField
+ control={form.control}
+ name="repositoryOwner"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Repository Owner</FormLabel>
+ <FormControl>
+ <Input
+ placeholder="e.g., octocat"
+ {...field}
+ disabled={isCreating || isDeleting}
+ />
+ </FormControl>
+ <FormDescription>
+ GitHub username or organization
+ </FormDescription>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <FormField
+ control={form.control}
+ name="repositoryName"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Repository Name</FormLabel>
+ <FormControl>
+ <Input
+ placeholder="e.g., my-project"
+ {...field}
+ disabled={isCreating || isDeleting}
+ />
+ </FormControl>
+ <FormDescription>The repository name</FormDescription>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+
+ <div className="flex flex-wrap gap-2">
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => setShowRepositoryBrowser(true)}
+ className="gap-2"
+ >
+ <GitBranch className="w-4 h-4" />
+ Browse
+ </Button>
+
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => handleVerifyInstallation(form.getValues())}
+ disabled={isVerifying || !form.formState.isValid}
+ className="gap-2"
+ >
+ <RefreshCw
+ className={cn("w-4 h-4", isVerifying && "animate-spin")}
+ />
+ Verify
+ </Button>
+
+ <Button
+ type="submit"
+ size="sm"
+ disabled={
+ isCreating ||
+ isDeleting ||
+ !form.formState.isValid ||
+ (verificationResult
+ ? !verificationResult.isInstalled ||
+ !verificationResult.hasRequiredPermissions
+ : false)
+ }
+ className="gap-2"
+ >
+ <Link className="w-4 h-4" />
+ {isConnected ? "Update" : "Connect"}
+ </Button>
+
+ {isConnected && (
+ <Button
+ type="button"
+ variant="destructive"
+ size="sm"
+ onClick={handleDelete}
+ disabled={isCreating || isDeleting}
+ className="gap-2"
+ >
+ <Unlink className="w-4 h-4" />
+ Disconnect
+ </Button>
+ )}
+ </div>
+ </form>
+ </Form>
+
+ {/* Verification Results */}
+ {verificationResult && (
+ <div className="mt-4">
+ <div
+ className={cn(
+ "flex items-start gap-3 p-3 border rounded-lg text-sm",
+ verificationResult.isInstalled &&
+ verificationResult.hasRequiredPermissions
+ ? "bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800"
+ : verificationResult.isInstalled
+ ? "bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800"
+ : verificationResult.repositoryExists
+ ? "bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800"
+ : "bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800",
+ )}
+ >
+ {verificationResult.isInstalled &&
+ verificationResult.hasRequiredPermissions ? (
+ <CheckCircle className="w-4 h-4 text-green-600 dark:text-green-400 mt-0.5 flex-shrink-0" />
+ ) : verificationResult.isInstalled ||
+ verificationResult.repositoryExists ? (
+ <AlertTriangle className="w-4 h-4 text-amber-600 dark:text-amber-400 mt-0.5 flex-shrink-0" />
+ ) : (
+ <XCircle className="w-4 h-4 text-red-600 dark:text-red-400 mt-0.5 flex-shrink-0" />
+ )}
+ <div className="flex-1">
+ <p className="font-medium">{verificationResult.message}</p>
+
+ {verificationResult.isInstalled &&
+ !verificationResult.hasRequiredPermissions &&
+ verificationResult.missingPermissions && (
+ <div className="mt-2">
+ <p className="text-xs mb-2">
+ Missing permissions:{" "}
+ <strong>
+ {verificationResult.missingPermissions.join(", ")}
+ </strong>
+ </p>
+ <div className="flex gap-2">
+ {verificationResult.settingsUrl && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() =>
+ window.open(
+ verificationResult.settingsUrl,
+ "_blank",
+ )
+ }
+ className="gap-2"
+ >
+ <ExternalLink className="w-3 h-3" />
+ Update Permissions
+ </Button>
+ )}
+ </div>
+ </div>
)}
- {verificationResult.installationUrl && (
- <Button
- variant="outline"
- size="sm"
- onClick={() =>
- window.open(
- verificationResult.installationUrl,
- "_blank",
- )
- }
- className="gap-2"
- >
- <ExternalLink className="w-3 h-3" />
- Reinstall App
- </Button>
+
+ {!verificationResult.isInstalled &&
+ verificationResult.repositoryExists && (
+ <div className="mt-2">
+ {verificationResult.installationUrl && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() =>
+ window.open(
+ verificationResult.installationUrl,
+ "_blank",
+ )
+ }
+ className="gap-2"
+ >
+ <ExternalLink className="w-3 h-3" />
+ Install GitHub App
+ </Button>
+ )}
+ </div>
)}
- </div>
</div>
- )}
+ </div>
+ </div>
+ )}
+ </CardContent>
+ </Card>
- {!verificationResult.isInstalled &&
- verificationResult.repositoryExists && (
- <div className="mt-2 flex gap-2">
- {verificationResult.installationUrl && (
- <Button
- variant="outline"
- size="sm"
- onClick={() =>
- window.open(
- verificationResult.installationUrl,
- "_blank",
- )
- }
- className="gap-2"
- >
- <ExternalLink className="w-3 h-3" />
- Install GitHub App
- </Button>
- )}
- {verificationResult.settingsUrl && (
- <Button
- variant="outline"
- size="sm"
- onClick={() =>
- window.open(verificationResult.settingsUrl, "_blank")
- }
- className="gap-2"
- >
- <ExternalLink className="w-3 h-3" />
- View App Details
- </Button>
+ {/* Actions Card */}
+ {isConnected && (
+ <Card>
+ <CardHeader>
+ <CardTitle className="text-base flex items-center gap-2">
+ <Download className="w-4 h-4" />
+ Actions
+ </CardTitle>
+ <CardDescription>
+ Import existing issues from GitHub or manage your integration
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <div className="space-y-4">
+ <div className="flex items-start gap-4 p-4 border border-zinc-200 dark:border-zinc-800 rounded-lg bg-zinc-50/50 dark:bg-zinc-800/20 hover:bg-zinc-50 dark:hover:bg-zinc-800/30 transition-colors">
+ <div className="p-2 bg-zinc-100 dark:bg-zinc-800/50 rounded-lg">
+ <Import className="w-5 h-5 text-zinc-600 dark:text-zinc-400" />
+ </div>
+ <div className="flex-1">
+ <h4 className="font-medium mb-1 text-zinc-900 dark:text-zinc-100">
+ Import GitHub Issues
+ </h4>
+ <p className="text-sm text-zinc-600 dark:text-zinc-400 mb-3">
+ Import existing issues from your GitHub repository as tasks
+ in this project.
+ </p>
+ <Button
+ onClick={handleImportIssues}
+ disabled={isImporting || !canImport}
+ className="gap-2"
+ size="sm"
+ >
+ {isImporting ? (
+ <RefreshCw className="w-4 h-4 animate-spin" />
+ ) : (
+ <Import className="w-4 h-4" />
+ )}
+ {isImporting ? "Importing..." : "Import Issues"}
+ </Button>
+ {!canImport && (
+ <p className="text-xs text-zinc-500 dark:text-zinc-500 mt-2">
+ Complete the repository configuration above to enable
+ importing
+ </p>
)}
</div>
- )}
- </div>
- </div>
+ </div>
+ </div>
+ </CardContent>
+ </Card>
)}
- <Form {...form}>
- <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
- <div className="grid grid-cols-2 gap-4">
- <FormField
- control={form.control}
- name="repositoryOwner"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Repository Owner</FormLabel>
- <FormControl>
- <Input
- placeholder="e.g., octocat"
- {...field}
- disabled={isCreating || isDeleting}
- />
- </FormControl>
- <FormDescription>
- The GitHub username or organization name
- </FormDescription>
- <FormMessage />
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="repositoryName"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Repository Name</FormLabel>
- <FormControl>
- <Input
- placeholder="e.g., my-project"
- {...field}
- disabled={isCreating || isDeleting}
- />
- </FormControl>
- <FormDescription>The repository name</FormDescription>
- <FormMessage />
- </FormItem>
- )}
- />
- </div>
-
- <div className="flex items-center gap-2">
- <Button
- type="button"
- variant="outline"
- onClick={() => setShowRepositoryBrowser(true)}
- className="flex items-center gap-2"
- >
- <GitBranch className="w-4 h-4" />
- Browse Repositories
- </Button>
-
- <Button
- type="button"
- variant="outline"
- onClick={() => handleVerifyInstallation(form.getValues())}
- disabled={isVerifying || !form.formState.isValid}
- className="flex items-center gap-2"
- >
- <RefreshCw
- className={cn("w-4 h-4", isVerifying && "animate-spin")}
- />
- Verify Installation
- </Button>
-
- <Button
- type="submit"
- disabled={
- isCreating ||
- isDeleting ||
- !form.formState.isValid ||
- (verificationResult
- ? !verificationResult.isInstalled ||
- !verificationResult.hasRequiredPermissions
- : false)
- }
- className="flex items-center gap-2"
- >
- <Link className="w-4 h-4" />
- {isConnected ? "Update Integration" : "Connect Repository"}
- </Button>
-
- {isConnected && (
- <Button
- type="button"
- variant="destructive"
- onClick={handleDelete}
- disabled={isCreating || isDeleting}
- className="flex items-center gap-2"
- >
- <Unlink className="w-4 h-4" />
- Disconnect
- </Button>
- )}
- </div>
- </form>
- </Form>
-
<RepositoryBrowserModal
open={showRepositoryBrowser}
onOpenChange={setShowRepositoryBrowser}
@@ -463,85 +600,6 @@ export function GitHubIntegrationSettings({
: undefined
}
/>
-
- {!verificationResult?.isInstalled &&
- repositoryOwner &&
- repositoryName && (
- <div className="p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg">
- <div className="flex items-start gap-3">
- <Github className="w-5 h-5 text-blue-600 dark:text-blue-400 mt-0.5" />
- <div className="text-sm text-blue-700 dark:text-blue-300">
- <p className="font-medium mb-2">
- Need to install the GitHub App?
- </p>
- <p className="mb-3">
- To use this integration, you need to install the Kaneo GitHub
- App on your repository. This gives Kaneo permission to create
- issues when tasks are created.
- </p>
- <div className="space-y-2">
- <p className="text-xs">Steps to install:</p>
- <ol className="list-decimal list-inside space-y-1 text-xs">
- <li>Click "Install GitHub App" if available above</li>
- <li>Or go to your GitHub App settings</li>
- <li>
- Select the repository:{" "}
- <code className="px-1 py-0.5 bg-blue-100 dark:bg-blue-800 rounded">
- {repositoryOwner}/{repositoryName}
- </code>
- </li>
- <li>Grant necessary permissions (Issues: Write)</li>
- <li>Come back and click "Verify Installation"</li>
- </ol>
- </div>
- </div>
- </div>
- </div>
- )}
-
- {verificationResult?.isInstalled &&
- !verificationResult.hasRequiredPermissions && (
- <div className="p-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg">
- <div className="flex items-start gap-3">
- <AlertTriangle className="w-5 h-5 text-amber-600 dark:text-amber-400 mt-0.5" />
- <div className="text-sm text-amber-700 dark:text-amber-300">
- <p className="font-medium mb-2">
- App installed but permissions need updating
- </p>
- <p className="mb-3">
- The GitHub App is installed on your repository but doesn't
- have the required permissions to create issues. You need to
- update the app permissions.
- </p>
- <div className="space-y-2">
- <p className="text-xs">Required permissions:</p>
- <ul className="list-disc list-inside space-y-1 text-xs">
- <li>
- Issues: <strong>Write</strong> (to create and update
- issues)
- </li>
- <li>
- Metadata: <strong>Read</strong> (to access repository
- information)
- </li>
- </ul>
- <p className="text-xs mt-2">
- Click "Update Permissions" above or visit your
- <a
- href="https://github.com/settings/installations"
- target="_blank"
- rel="noopener noreferrer"
- className="underline hover:no-underline ml-1"
- >
- GitHub App settings
- </a>
- to modify permissions.
- </p>
- </div>
- </div>
- </div>
- </div>
- )}
</div>
);
}
diff --git a/apps/web/src/components/ui/card.tsx b/apps/web/src/components/ui/card.tsx
new file mode 100644
index 000000000..e48139021
--- /dev/null
+++ b/apps/web/src/components/ui/card.tsx
@@ -0,0 +1,85 @@
+import { cn } from "@/lib/cn";
+import * as React from "react";
+
+const Card = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn(
+ "rounded-lg border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-sm",
+ className,
+ )}
+ {...props}
+ />
+));
+Card.displayName = "Card";
+
+const CardHeader = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn("flex flex-col space-y-1.5 p-4 md:p-6", className)}
+ {...props}
+ />
+));
+CardHeader.displayName = "CardHeader";
+
+const CardTitle = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLHeadingElement>
+>(({ className, ...props }, ref) => (
+ <h3
+ ref={ref}
+ className={cn(
+ "text-lg font-semibold leading-none tracking-tight text-zinc-900 dark:text-zinc-100",
+ className,
+ )}
+ {...props}
+ />
+));
+CardTitle.displayName = "CardTitle";
+
+const CardDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLParagraphElement>
+>(({ className, ...props }, ref) => (
+ <p
+ ref={ref}
+ className={cn("text-sm text-zinc-600 dark:text-zinc-400", className)}
+ {...props}
+ />
+));
+CardDescription.displayName = "CardDescription";
+
+const CardContent = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
+));
+CardContent.displayName = "CardContent";
+
+const CardFooter = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn("flex items-center p-6 pt-0", className)}
+ {...props}
+ />
+));
+CardFooter.displayName = "CardFooter";
+
+export {
+ Card,
+ CardHeader,
+ CardFooter,
+ CardTitle,
+ CardDescription,
+ CardContent,
+};
diff --git a/apps/web/src/fetchers/github-integration/import-github-issues.ts b/apps/web/src/fetchers/github-integration/import-github-issues.ts
new file mode 100644
index 000000000..f2897bebf
--- /dev/null
+++ b/apps/web/src/fetchers/github-integration/import-github-issues.ts
@@ -0,0 +1,22 @@
+import { client } from "@kaneo/libs";
+import type { InferRequestType } from "hono";
+
+export type ImportGithubIssuesRequest = InferRequestType<
+ (typeof client)["github-integration"]["import-issues"]["$post"]
+>["json"];
+
+async function importGithubIssues(data: ImportGithubIssuesRequest) {
+ const response = await client["github-integration"]["import-issues"].$post({
+ json: data,
+ });
+
+ if (!response.ok) {
+ const error = await response.text();
+ throw new Error(error);
+ }
+
+ const result = await response.json();
+ return result;
+}
+
+export default importGithubIssues;
diff --git a/apps/web/src/hooks/mutations/github-integration/use-import-github-issues.ts b/apps/web/src/hooks/mutations/github-integration/use-import-github-issues.ts
new file mode 100644
index 000000000..7944ec95e
--- /dev/null
+++ b/apps/web/src/hooks/mutations/github-integration/use-import-github-issues.ts
@@ -0,0 +1,14 @@
+import importGithubIssues from "@/fetchers/github-integration/import-github-issues";
+import queryClient from "@/query-client";
+import { useMutation } from "@tanstack/react-query";
+
+function useImportGithubIssues() {
+ return useMutation({
+ mutationFn: importGithubIssues,
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: ["tasks"] });
+ },
+ });
+}
+
+export default useImportGithubIssues;