@flaredev/cli 0.4.0 → 0.5.0
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/dist/index.js +851 -405
- package/package.json +2 -2
- package/templates/app/app/dashboard/actions.ts +38 -5
- package/templates/app/app/dashboard/costs/page.tsx +93 -0
- package/templates/app/app/dashboard/page.tsx +4 -7
- package/templates/app/app/globals.css +0 -6
- package/templates/app/app/layout.tsx +37 -28
- package/templates/app/app/page.tsx +10 -0
- package/templates/app/components/dashboard/cost-estimator.tsx +77 -0
- package/templates/app/components/dashboard/fields/field-widget.tsx +237 -186
- package/templates/app/components/dashboard/fields/file-field.tsx +5 -1
- package/templates/app/components/dashboard/fields/relation-field.tsx +25 -3
- package/templates/app/components/dashboard/import-dialog.tsx +2 -2
- package/templates/app/components/dashboard/record-actions.tsx +9 -9
- package/templates/app/components/dashboard/record-detail.tsx +6 -3
- package/templates/app/components/dashboard/resource-form-page.tsx +64 -61
- package/templates/app/components/dashboard/resource-form-sheet.tsx +86 -0
- package/templates/app/components/dashboard/resource-form.tsx +261 -165
- package/templates/app/components/dashboard/resource-icon.tsx +87 -85
- package/templates/app/components/dashboard/resource-stats.tsx +10 -9
- package/templates/app/components/dashboard/resource-table-toolbar.tsx +2 -2
- package/templates/app/components/dashboard/resource-table.tsx +12 -9
- package/templates/app/components/dashboard/row-actions.tsx +5 -5
- package/templates/app/lib/costs.ts +138 -0
- package/templates/app/lib/dashboard-nav.ts +5 -1
- package/templates/app/lib/dashboard.ts +66 -61
- package/templates/app/lib/number.ts +33 -0
- package/templates/app/lib/site.ts +56 -56
- package/templates/app/lib/suggest.ts +35 -0
- package/templates/app/lib/usage.ts +32 -0
- package/templates/locks/package-lock.json +9 -9
- package/templates/locks/pnpm-lock.yaml +12 -12
- package/templates/locks/yarn.lock +3 -3
- package/templates/next/.env.example +21 -0
- package/templates/next/README.md +16 -0
- package/templates/next/app/api/health/route.ts +7 -0
- package/templates/next/app/dashboard/account/password/page.tsx +19 -0
- package/templates/next/app/dashboard/account/security/page.tsx +31 -0
- package/templates/next/app/dashboard/actions.ts +277 -0
- package/templates/next/app/dashboard/layout.tsx +64 -0
- package/templates/next/app/dashboard/page.tsx +127 -0
- package/templates/next/components/dashboard/resource-chart.tsx +86 -0
- package/templates/next/lib/analytics.ts +71 -0
- package/templates/next/lib/audit.ts +80 -0
- package/templates/next/lib/auth-emails.ts +92 -0
- package/templates/next/lib/auth.ts +156 -0
- package/templates/next/lib/dashboard.ts +161 -0
- package/templates/next/lib/db.ts +24 -0
- package/templates/next/lib/mail.ts +35 -0
- package/templates/next/lib/realtime.ts +23 -0
- package/templates/next/lib/redis.ts +17 -0
- package/templates/next/lib/storage.ts +57 -0
- package/templates/next/lib/theme.ts +83 -0
- package/templates/next/lib/views.ts +23 -0
- package/templates/next/next.config.ts +13 -0
- package/templates/next/prisma/schema/base.prisma +162 -0
- package/templates/next/prisma.config.ts +15 -0
- package/templates/next/tsconfig.json +24 -0
- package/templates/app/components/dashboard/resource-form-dialog.tsx +0 -80
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { PlusIcon } from "lucide-react";
|
|
5
|
-
import type { Resource } from "@flaredev/core";
|
|
6
|
-
import { Button } from "@/components/ui/button";
|
|
7
|
-
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
|
8
|
-
import type { RelationMeta } from "./fields/field-widget";
|
|
9
|
-
import { ResourceForm } from "./resource-form";
|
|
10
|
-
|
|
11
|
-
export type FormRelations = Record<string, RelationMeta & { initialTitle?: string }>;
|
|
12
|
-
|
|
13
|
-
interface Props {
|
|
14
|
-
resource: Resource;
|
|
15
|
-
relations: FormRelations;
|
|
16
|
-
listHref: string;
|
|
17
|
-
mode: "create" | "edit";
|
|
18
|
-
/** Edit: the record and its id. */
|
|
19
|
-
id?: string;
|
|
20
|
-
record?: Record<string, unknown> | null;
|
|
21
|
-
/** Controlled use (a row menu opens it); otherwise pass `trigger`. */
|
|
22
|
-
open?: boolean;
|
|
23
|
-
onOpenChange?: (open: boolean) => void;
|
|
24
|
-
trigger?: React.ReactNode;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The create/edit form in a dialog, so adding a record doesn't lose the list, its
|
|
29
|
-
* filters or the place in it. Apps that would rather have a page set
|
|
30
|
-
* `site.dashboard.forms` to "page" (lib/site.ts) and get the same form full width.
|
|
31
|
-
*/
|
|
32
|
-
export function ResourceFormDialog({ resource, relations, listHref, mode, id, record, open, onOpenChange, trigger }: Props) {
|
|
33
|
-
const [internalOpen, setInternalOpen] = useState(false);
|
|
34
|
-
const isOpen = open ?? internalOpen;
|
|
35
|
-
const setOpen = onOpenChange ?? setInternalOpen;
|
|
36
|
-
const noun = resource.label.toLowerCase();
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<Dialog open={isOpen} onOpenChange={setOpen}>
|
|
40
|
-
{trigger && <DialogTrigger asChild>{trigger}</DialogTrigger>}
|
|
41
|
-
<DialogContent className="sm:max-w-2xl">
|
|
42
|
-
<DialogHeader>
|
|
43
|
-
<DialogTitle>{mode === "create" ? `New ${noun}` : `Edit ${noun}`}</DialogTitle>
|
|
44
|
-
<DialogDescription>{mode === "create" ? `Fill this in and it appears in the list.` : "Changes save straight away."}</DialogDescription>
|
|
45
|
-
</DialogHeader>
|
|
46
|
-
{/* Remounting on open clears whatever was typed and abandoned last time. */}
|
|
47
|
-
{isOpen && (
|
|
48
|
-
<ResourceForm
|
|
49
|
-
key={`${mode}-${id ?? "new"}`}
|
|
50
|
-
resource={resource}
|
|
51
|
-
mode={mode}
|
|
52
|
-
id={id}
|
|
53
|
-
record={record}
|
|
54
|
-
relations={relations}
|
|
55
|
-
listHref={listHref}
|
|
56
|
-
onDone={() => setOpen(false)}
|
|
57
|
-
/>
|
|
58
|
-
)}
|
|
59
|
-
</DialogContent>
|
|
60
|
-
</Dialog>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** The list page's "New …" button, when forms open in a dialog. */
|
|
65
|
-
export function NewRecordButton({ resource, relations, listHref }: { resource: Resource; relations: FormRelations; listHref: string }) {
|
|
66
|
-
return (
|
|
67
|
-
<ResourceFormDialog
|
|
68
|
-
resource={resource}
|
|
69
|
-
relations={relations}
|
|
70
|
-
listHref={listHref}
|
|
71
|
-
mode="create"
|
|
72
|
-
trigger={
|
|
73
|
-
<Button>
|
|
74
|
-
<PlusIcon data-icon="inline-start" />
|
|
75
|
-
New {resource.label.toLowerCase()}
|
|
76
|
-
</Button>
|
|
77
|
-
}
|
|
78
|
-
/>
|
|
79
|
-
);
|
|
80
|
-
}
|