Skip to content

Commit b0a5f1c

Browse files
committed
chore: moving to API routes
1 parent 94595ef commit b0a5f1c

19 files changed

+759
-361
lines changed

packages/cta-engine/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type {
4747
FrameworkDefinition,
4848
Mode,
4949
Options,
50+
SerializedOptions,
5051
StarterCompiled,
5152
} from './types.js'
5253
export type { PersistedOptions } from './config-file.js'

packages/cta-engine/src/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ export interface Options {
130130
starter?: Starter | undefined
131131
}
132132

133+
export type SerializedOptions = Omit<
134+
Options,
135+
'chosenAddOns' | 'starter' | 'framework'
136+
> & {
137+
chosenAddOns: Array<string>
138+
starter?: string | undefined
139+
framework?: string | undefined
140+
}
141+
133142
type ProjectEnvironment = {
134143
startRun: () => void
135144
finishRun: () => void

packages/cta-ui/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"@radix-ui/react-accordion": "^1.2.3",
1717
"@radix-ui/react-checkbox": "^1.1.4",
1818
"@radix-ui/react-dialog": "^1.1.10",
19+
"@radix-ui/react-dropdown-menu": "^2.1.11",
20+
"@radix-ui/react-label": "^2.1.4",
21+
"@radix-ui/react-popover": "^1.1.10",
1922
"@radix-ui/react-separator": "^1.1.4",
2023
"@radix-ui/react-slot": "^1.2.0",
2124
"@radix-ui/react-tabs": "^1.1.3",

packages/cta-ui/src/components/applied-add-on.tsx

Lines changed: 0 additions & 149 deletions
This file was deleted.

packages/cta-ui/src/components/file-navigator.tsx

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
11
import { useState } from 'react'
22
import { useStore } from '@tanstack/react-store'
3+
import { FilterIcon } from 'lucide-react'
34

45
import FileViewer from './file-viewer'
56
import FileTree from './file-tree'
67

8+
import { Button } from '@/components/ui/button'
9+
import { Label } from '@/components/ui/label'
10+
import { Checkbox } from '@/components/ui/checkbox'
11+
import {
12+
Popover,
13+
PopoverContent,
14+
PopoverTrigger,
15+
} from '@/components/ui/popover'
16+
717
import { projectFiles, projectLocalFiles } from '@/store/project'
818

19+
export function DropdownMenuDemo() {
20+
return (
21+
<Popover>
22+
<PopoverTrigger asChild>
23+
<Button variant="outline">
24+
<FilterIcon />
25+
Filter
26+
</Button>
27+
</PopoverTrigger>
28+
<PopoverContent className="w-80 backdrop-blur-lg bg-opacity-50">
29+
<div className="grid gap-4">
30+
<div className="space-y-2">
31+
<h4 className="font-medium leading-none">File Filters</h4>
32+
</div>
33+
<div className="flex flex-col gap-2">
34+
<div className="flex flex-row items-center gap-2">
35+
<Checkbox id="width" checked={true} className="w-6 h-6" />
36+
<Label htmlFor="width" className="text-lg">
37+
All Files
38+
</Label>
39+
</div>
40+
</div>
41+
</div>
42+
</PopoverContent>
43+
</Popover>
44+
)
45+
}
46+
947
export default function FileNavigator() {
1048
const [selectedFile, setSelectedFile] = useState<string | null>(null)
1149
const [originalFileContents, setOriginalFileContents] = useState<string>()
@@ -16,27 +54,30 @@ export default function FileNavigator() {
1654

1755
return (
1856
<div className="flex flex-row w-[calc(100vw-450px)]">
19-
<FileTree
20-
prefix="./"
21-
tree={output.files}
22-
originalTree={originalOutput.files}
23-
localTree={localFiles}
24-
onFileSelected={(file) => {
25-
setSelectedFile(file)
26-
if (localFiles[file]) {
27-
if (!output.files[file]) {
28-
setOriginalFileContents(undefined)
29-
setModifiedFileContents(localFiles[file])
57+
<div className="w-1/4 max-w-1/4 pr-2">
58+
<DropdownMenuDemo />
59+
<FileTree
60+
prefix="./"
61+
tree={output.files}
62+
originalTree={originalOutput.files}
63+
localTree={localFiles}
64+
onFileSelected={(file) => {
65+
setSelectedFile(file)
66+
if (localFiles[file]) {
67+
if (!output.files[file]) {
68+
setOriginalFileContents(undefined)
69+
setModifiedFileContents(localFiles[file])
70+
} else {
71+
setOriginalFileContents(localFiles[file])
72+
setModifiedFileContents(output.files[file])
73+
}
3074
} else {
31-
setOriginalFileContents(localFiles[file])
75+
setOriginalFileContents(originalOutput.files[file])
3276
setModifiedFileContents(output.files[file])
3377
}
34-
} else {
35-
setOriginalFileContents(originalOutput.files[file])
36-
setModifiedFileContents(output.files[file])
37-
}
38-
}}
39-
/>
78+
}}
79+
/>
80+
</div>
4081
<div className="max-w-3/4 w-3/4 pl-2">
4182
{selectedFile && modifiedFileContents ? (
4283
<FileViewer

packages/cta-ui/src/components/file-tree.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export default function FileTree({
108108
data={computedTree}
109109
defaultNodeIcon={() => <Folder className="w-4 h-4 mr-2" />}
110110
defaultLeafIcon={() => <FileText className="w-4 h-4 mr-2" />}
111-
className="max-w-1/4 w-1/4 pr-2"
112111
/>
113112
)
114113
}

packages/cta-ui/src/components/sidebar-items/run-add-ons.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
import { useStore } from '@tanstack/react-store'
2+
13
import { Button } from '@/components/ui/button'
2-
import { closeApp } from '@/lib/add-to-app-server-fn'
34
import { selectedAddOns } from '@/store/project'
45

56
export default function RunAddOns() {
7+
const currentlySelectedAddOns = useStore(selectedAddOns)
8+
69
return (
710
<div>
811
<Button
9-
variant="outline"
12+
variant="default"
1013
onClick={async () => {
11-
await fetch('/api/add-add-ons', {
14+
await fetch('/api/add-to-app', {
1215
method: 'POST',
1316
body: JSON.stringify({
1417
addOns: selectedAddOns.state.map((addOn) => addOn.id),
@@ -20,6 +23,8 @@ export default function RunAddOns() {
2023
// await closeApp()
2124
// window.close()
2225
}}
26+
disabled={currentlySelectedAddOns.length === 0}
27+
className="w-full"
2328
>
2429
Run Add-Ons
2530
</Button>

0 commit comments

Comments
 (0)