@tscircuit/fake-snippets 0.0.101 → 0.0.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/generated-index.js +23 -1
- package/bun.lock +2 -2
- package/dist/bundle.js +530 -367
- package/dist/index.d.ts +29 -2
- package/dist/index.js +18 -1
- package/dist/schema.d.ts +94 -1
- package/dist/schema.js +17 -1
- package/fake-snippets-api/lib/db/db-client.ts +6 -1
- package/fake-snippets-api/lib/db/schema.ts +15 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package.ts +2 -0
- package/fake-snippets-api/routes/api/github/installations/create_new_installation_redirect.ts +75 -0
- package/fake-snippets-api/routes/api/github/repos/list_available.ts +91 -0
- package/fake-snippets-api/routes/api/packages/update.ts +4 -0
- package/package.json +2 -2
- package/src/App.tsx +10 -1
- package/src/components/CreateReleaseDialog.tsx +124 -0
- package/src/components/FileSidebar.tsx +128 -23
- package/src/components/PackageBuildsPage/package-build-header.tsx +9 -1
- package/src/components/PageSearchComponent.tsx +2 -2
- package/src/components/SearchComponent.tsx +2 -2
- package/src/components/SuspenseRunFrame.tsx +2 -2
- package/src/components/TrendingPackagesCarousel.tsx +2 -2
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +1 -0
- package/src/components/ViewPackagePage/components/sidebar-about-section.tsx +1 -0
- package/src/components/dialogs/GitHubRepositorySelector.tsx +123 -0
- package/src/components/dialogs/create-use-dialog.tsx +8 -2
- package/src/components/dialogs/edit-package-details-dialog.tsx +22 -3
- package/src/components/dialogs/view-ts-files-dialog.tsx +178 -33
- package/src/components/package-port/CodeAndPreview.tsx +4 -1
- package/src/components/package-port/CodeEditor.tsx +42 -35
- package/src/components/package-port/CodeEditorHeader.tsx +6 -4
- package/src/components/package-port/EditorNav.tsx +94 -37
- package/src/components/preview/BuildsList.tsx +238 -0
- package/src/components/preview/ConnectedRepoDashboard.tsx +258 -0
- package/src/components/preview/ConnectedRepoOverview.tsx +454 -0
- package/src/components/preview/ConnectedRepoSettings.tsx +343 -0
- package/src/components/preview/ConnectedReposCards.tsx +191 -0
- package/src/components/preview/index.tsx +207 -0
- package/src/components/ui/tree-view.tsx +23 -6
- package/src/hooks/use-axios.ts +2 -2
- package/src/hooks/use-create-release-dialog.ts +160 -0
- package/src/hooks/use-package-details-form.ts +7 -0
- package/src/hooks/use-packages-base-api-url.ts +1 -1
- package/src/hooks/use-sign-in.ts +2 -2
- package/src/hooks/useFileManagement.ts +22 -2
- package/src/index.css +4 -0
- package/src/lib/utils/formatTimeAgo.ts +10 -0
- package/src/lib/utils/isValidFileName.ts +15 -3
- package/src/pages/dashboard.tsx +2 -2
- package/src/pages/dev-login.tsx +2 -2
- package/src/pages/latest.tsx +2 -2
- package/src/pages/preview-build.tsx +380 -0
- package/src/pages/search.tsx +2 -2
- package/src/pages/trending.tsx +2 -2
- package/src/pages/user-profile.tsx +32 -24
- package/src/pages/view-connected-repo.tsx +24 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
import { Button } from "@/components/ui/button"
|
|
3
|
+
import { Badge } from "@/components/ui/badge"
|
|
4
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
|
5
|
+
import {
|
|
6
|
+
DropdownMenu,
|
|
7
|
+
DropdownMenuContent,
|
|
8
|
+
DropdownMenuItem,
|
|
9
|
+
DropdownMenuTrigger,
|
|
10
|
+
} from "@/components/ui/dropdown-menu"
|
|
11
|
+
import {
|
|
12
|
+
Activity,
|
|
13
|
+
Settings,
|
|
14
|
+
List,
|
|
15
|
+
Github,
|
|
16
|
+
MoreHorizontal,
|
|
17
|
+
Zap,
|
|
18
|
+
Clock,
|
|
19
|
+
GitBranch,
|
|
20
|
+
Hash,
|
|
21
|
+
User,
|
|
22
|
+
Eye,
|
|
23
|
+
} from "lucide-react"
|
|
24
|
+
import { useLocation } from "wouter"
|
|
25
|
+
import { ConnectedRepoOverview } from "./ConnectedRepoOverview"
|
|
26
|
+
import { BuildsList } from "./BuildsList"
|
|
27
|
+
import { ConnectedRepoSettings } from "./ConnectedRepoSettings"
|
|
28
|
+
import Header from "../Header"
|
|
29
|
+
import { formatTimeAgo } from "@/lib/utils/formatTimeAgo"
|
|
30
|
+
import { getBuildStatus, PackageBuild, MOCK_DEPLOYMENTS } from "."
|
|
31
|
+
|
|
32
|
+
interface ConnectedRepoDashboardProps {
|
|
33
|
+
projectName?: string
|
|
34
|
+
builds?: PackageBuild[]
|
|
35
|
+
selectedBuild?: PackageBuild
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const ConnectedRepoDashboard = ({
|
|
39
|
+
projectName = "tscircuit-project",
|
|
40
|
+
builds = MOCK_DEPLOYMENTS,
|
|
41
|
+
selectedBuild,
|
|
42
|
+
}: ConnectedRepoDashboardProps) => {
|
|
43
|
+
const [activeTab, setActiveTab] = useState("overview")
|
|
44
|
+
const [currentBuild, setCurrentBuild] = useState<PackageBuild | undefined>(
|
|
45
|
+
selectedBuild || builds[0],
|
|
46
|
+
)
|
|
47
|
+
const [, setLocation] = useLocation()
|
|
48
|
+
|
|
49
|
+
const handleSelectBuild = (build: PackageBuild) => {
|
|
50
|
+
setLocation(`/build/${build.package_build_id}`)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const latestBuild = builds[0]
|
|
54
|
+
const { status, label } = getBuildStatus(latestBuild)
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<>
|
|
58
|
+
<Header />
|
|
59
|
+
<div className="min-h-screen bg-white">
|
|
60
|
+
{/* Project Header */}
|
|
61
|
+
<div className="bg-gray-50 border-b md:py-10">
|
|
62
|
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
|
|
63
|
+
<div className="flex flex-col lg:flex-row lg:items-center lg:justify-between gap-6">
|
|
64
|
+
<div className="flex flex-col sm:flex-row sm:items-center gap-4">
|
|
65
|
+
<div className="w-12 hidden md:block h-12 rounded-lg overflow-hidden flex-shrink-0">
|
|
66
|
+
<img
|
|
67
|
+
src="https://github.com/tscircuit.png"
|
|
68
|
+
alt="tscircuit logo"
|
|
69
|
+
className="w-full h-full object-cover"
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
<div className="min-w-0 flex-1">
|
|
73
|
+
<div className="flex flex-col sm:flex-row sm:items-center gap-3">
|
|
74
|
+
<h1 className="text-2xl font-bold text-gray-900 truncate">
|
|
75
|
+
{projectName}
|
|
76
|
+
</h1>
|
|
77
|
+
<Badge
|
|
78
|
+
variant={
|
|
79
|
+
status === "success"
|
|
80
|
+
? "default"
|
|
81
|
+
: status === "error"
|
|
82
|
+
? "destructive"
|
|
83
|
+
: "secondary"
|
|
84
|
+
}
|
|
85
|
+
className="flex items-center gap-1 w-fit"
|
|
86
|
+
>
|
|
87
|
+
<div
|
|
88
|
+
className={`w-2 h-2 rounded-full ${
|
|
89
|
+
status === "success"
|
|
90
|
+
? "bg-green-500"
|
|
91
|
+
: status === "error"
|
|
92
|
+
? "bg-red-500"
|
|
93
|
+
: status === "building"
|
|
94
|
+
? "bg-blue-500 animate-pulse"
|
|
95
|
+
: "bg-gray-500"
|
|
96
|
+
}`}
|
|
97
|
+
/>
|
|
98
|
+
{label}
|
|
99
|
+
</Badge>
|
|
100
|
+
</div>
|
|
101
|
+
<div className="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-2 text-sm text-gray-600">
|
|
102
|
+
<div className="flex items-center gap-1">
|
|
103
|
+
<GitBranch className="w-4 h-4 flex-shrink-0" />
|
|
104
|
+
<span className="truncate">
|
|
105
|
+
{latestBuild.branch_name || "main"}
|
|
106
|
+
</span>
|
|
107
|
+
</div>
|
|
108
|
+
<div className="flex items-center gap-1">
|
|
109
|
+
<Clock className="w-4 h-4 flex-shrink-0" />
|
|
110
|
+
<span>
|
|
111
|
+
Last deployed {formatTimeAgo(latestBuild.created_at)}
|
|
112
|
+
</span>
|
|
113
|
+
</div>
|
|
114
|
+
<div className="flex items-center gap-1">
|
|
115
|
+
<User className="w-4 h-4 flex-shrink-0" />
|
|
116
|
+
<span className="truncate">
|
|
117
|
+
{latestBuild.commit_author || "Unknown"}
|
|
118
|
+
</span>
|
|
119
|
+
</div>
|
|
120
|
+
<div className="flex items-center gap-1">
|
|
121
|
+
<Hash className="w-4 h-4 flex-shrink-0" />
|
|
122
|
+
<span className="font-mono text-xs truncate">
|
|
123
|
+
{latestBuild.package_build_id?.slice(-8) || "N/A"}
|
|
124
|
+
</span>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-2">
|
|
131
|
+
<Button
|
|
132
|
+
variant="outline"
|
|
133
|
+
size="sm"
|
|
134
|
+
className="flex items-center gap-2 justify-center min-w-[120px] h-9"
|
|
135
|
+
onClick={() =>
|
|
136
|
+
window.open(
|
|
137
|
+
`https://github.com/${latestBuild.commit_author}/${projectName}`,
|
|
138
|
+
"_blank",
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
>
|
|
142
|
+
<Github className="w-4 h-4" />
|
|
143
|
+
<span className="hidden sm:inline">Repository</span>
|
|
144
|
+
<span className="sm:hidden">Repository</span>
|
|
145
|
+
</Button>
|
|
146
|
+
{latestBuild.preview_url && (
|
|
147
|
+
<Button
|
|
148
|
+
variant="outline"
|
|
149
|
+
size="sm"
|
|
150
|
+
className="flex items-center gap-2 justify-center min-w-[120px] h-9"
|
|
151
|
+
onClick={() =>
|
|
152
|
+
window.open(
|
|
153
|
+
`/build/${latestBuild.package_build_id}/preview`,
|
|
154
|
+
"_blank",
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
>
|
|
158
|
+
<Eye className="w-4 h-4" />
|
|
159
|
+
<span className="hidden sm:inline">Preview</span>
|
|
160
|
+
<span className="sm:hidden">Preview</span>
|
|
161
|
+
</Button>
|
|
162
|
+
)}
|
|
163
|
+
<Button
|
|
164
|
+
size="sm"
|
|
165
|
+
className="flex items-center gap-2 justify-center min-w-[120px] h-9 bg-black text-white"
|
|
166
|
+
>
|
|
167
|
+
<Zap className="w-4 h-4" />
|
|
168
|
+
<span className="hidden sm:inline">Redeploy</span>
|
|
169
|
+
<span className="sm:hidden">Redeploy</span>
|
|
170
|
+
</Button>
|
|
171
|
+
<DropdownMenu>
|
|
172
|
+
<DropdownMenuTrigger asChild>
|
|
173
|
+
<Button
|
|
174
|
+
variant="outline"
|
|
175
|
+
size="sm"
|
|
176
|
+
className="w-full h-9 sm:w-9 p-0"
|
|
177
|
+
>
|
|
178
|
+
<MoreHorizontal className="w-4 h-4" />
|
|
179
|
+
</Button>
|
|
180
|
+
</DropdownMenuTrigger>
|
|
181
|
+
<DropdownMenuContent align="end">
|
|
182
|
+
<DropdownMenuItem asChild>
|
|
183
|
+
<a
|
|
184
|
+
href={`https://github.com/${latestBuild.commit_author}`}
|
|
185
|
+
target="_blank"
|
|
186
|
+
rel="noopener noreferrer"
|
|
187
|
+
>
|
|
188
|
+
View Source
|
|
189
|
+
</a>
|
|
190
|
+
</DropdownMenuItem>
|
|
191
|
+
<DropdownMenuItem asChild>
|
|
192
|
+
<a href="#" download>
|
|
193
|
+
Download Build
|
|
194
|
+
</a>
|
|
195
|
+
</DropdownMenuItem>
|
|
196
|
+
<DropdownMenuItem
|
|
197
|
+
onClick={() => {
|
|
198
|
+
if (navigator.share) {
|
|
199
|
+
navigator.share({
|
|
200
|
+
title: projectName,
|
|
201
|
+
url: window.location.href,
|
|
202
|
+
})
|
|
203
|
+
} else {
|
|
204
|
+
navigator.clipboard.writeText(window.location.href)
|
|
205
|
+
}
|
|
206
|
+
}}
|
|
207
|
+
>
|
|
208
|
+
Share Project
|
|
209
|
+
</DropdownMenuItem>
|
|
210
|
+
</DropdownMenuContent>
|
|
211
|
+
</DropdownMenu>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
{/* Main Content */}
|
|
218
|
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
219
|
+
<Tabs
|
|
220
|
+
value={activeTab}
|
|
221
|
+
onValueChange={setActiveTab}
|
|
222
|
+
className="space-y-6"
|
|
223
|
+
>
|
|
224
|
+
<TabsList className="grid w-full grid-cols-3 lg:w-auto lg:grid-cols-3">
|
|
225
|
+
<TabsTrigger value="overview" className="flex items-center gap-2">
|
|
226
|
+
<Activity className="w-4 h-4" />
|
|
227
|
+
Overview
|
|
228
|
+
</TabsTrigger>
|
|
229
|
+
<TabsTrigger value="builds" className="flex items-center gap-2">
|
|
230
|
+
<List className="w-4 h-4" />
|
|
231
|
+
Builds
|
|
232
|
+
</TabsTrigger>
|
|
233
|
+
<TabsTrigger value="settings" className="flex items-center gap-2">
|
|
234
|
+
<Settings className="w-4 h-4" />
|
|
235
|
+
Settings
|
|
236
|
+
</TabsTrigger>
|
|
237
|
+
</TabsList>
|
|
238
|
+
|
|
239
|
+
<TabsContent value="overview" className="space-y-6">
|
|
240
|
+
{currentBuild && <ConnectedRepoOverview build={currentBuild} />}
|
|
241
|
+
</TabsContent>
|
|
242
|
+
|
|
243
|
+
<TabsContent value="builds" className="space-y-6">
|
|
244
|
+
<BuildsList builds={builds} onSelectBuild={handleSelectBuild} />
|
|
245
|
+
</TabsContent>
|
|
246
|
+
|
|
247
|
+
<TabsContent value="settings" className="space-y-6">
|
|
248
|
+
<ConnectedRepoSettings
|
|
249
|
+
projectName={projectName}
|
|
250
|
+
onSave={(settings) => console.log("Settings saved:", settings)}
|
|
251
|
+
/>
|
|
252
|
+
</TabsContent>
|
|
253
|
+
</Tabs>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
</>
|
|
257
|
+
)
|
|
258
|
+
}
|