@rebasepro/cms 0.25.0 → 0.26.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/collection_editor/liveSchemaClient.d.ts +3 -3
- package/dist/collection_editor/liveSchemaClient.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +1 -1
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.d.ts +7 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +61 -50
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +22 -22
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +14 -14
- package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +24 -24
- package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -1
- package/dist/collection_editor/useLiveSchemaEditing.js +4 -1
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +1 -2
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +1 -2
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +2 -28
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.d.ts +12 -0
- package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js +33 -0
- package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js.map +1 -0
- package/dist/components/CollectionsScopeContext.d.ts +5 -1
- package/dist/components/CollectionsScopeContext.js +10 -2
- package/dist/components/CollectionsScopeContext.js.map +1 -1
- package/dist/components/DefaultAppBar.js +2 -1
- package/dist/components/DefaultAppBar.js.map +1 -1
- package/dist/components/DefaultDrawer.js +16 -4
- package/dist/components/DefaultDrawer.js.map +1 -1
- package/dist/components/DefaultMissingReference.d.ts +8 -0
- package/dist/components/DefaultMissingReference.js +13 -0
- package/dist/components/DefaultMissingReference.js.map +1 -0
- package/dist/components/DeleteEntityDialog.js +9 -9
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/EntityFormPanel.d.ts +7 -2
- package/dist/components/EntityFormPanel.js +72 -29
- package/dist/components/EntityFormPanel.js.map +1 -1
- package/dist/components/HomePage/ContentHomePage.js +4 -3
- package/dist/components/HomePage/ContentHomePage.js.map +1 -1
- package/dist/components/HomePage/HomePageDnD.js +3 -1
- package/dist/components/HomePage/HomePageDnD.js.map +1 -1
- package/dist/components/HomePage/SmallNavigationCard.js +25 -0
- package/dist/components/HomePage/SmallNavigationCard.js.map +1 -0
- package/dist/components/RebaseAuthGate.js +3 -2
- package/dist/components/RebaseAuthGate.js.map +1 -1
- package/dist/components/RebaseLayout.d.ts +4 -1
- package/dist/components/RebaseLayout.js +7 -1
- package/dist/components/RebaseLayout.js.map +1 -1
- package/dist/components/RebaseShell.d.ts +4 -1
- package/dist/components/RebaseShell.js.map +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.js +4 -3
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/RelationSelector.js +2 -2
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SideDialogs.js +10 -4
- package/dist/components/SideDialogs.js.map +1 -1
- package/dist/components/app/Scaffold.js +5 -1
- package/dist/components/app/Scaffold.js.map +1 -1
- package/dist/components/field_configs.js +1 -1
- package/dist/components/history/EntityHistoryView.js +6 -4
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/components/history/LastEditedByIndicator.d.ts +2 -1
- package/dist/data_export/export/export.d.ts +2 -13
- package/dist/data_export/export/export.js +1 -36
- package/dist/data_export/export/export.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +17 -13
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormBinding.d.ts +1 -1
- package/dist/form/EntityFormBinding.js +42 -4
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/PropertyFieldBinding.js +1 -1
- package/dist/form/components/FieldBlock.d.ts +8 -1
- package/dist/form/components/FieldBlock.js +16 -2
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FormSections.js +1 -1
- package/dist/form/components/FormSections.js.map +1 -1
- package/dist/form/components/LabelWithIcon.js +5 -2
- package/dist/form/components/LabelWithIcon.js.map +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.js +2 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js +28 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +7 -3
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js +63 -42
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.js +2 -1
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/TextFieldBinding.js +8 -6
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
- package/dist/form/form_utils.d.ts +18 -1
- package/dist/form/form_utils.js +38 -2
- package/dist/form/form_utils.js.map +1 -1
- package/dist/form/index.d.ts +1 -1
- package/dist/form/label_placement.d.ts +23 -0
- package/dist/form/label_placement.js +71 -0
- package/dist/form/label_placement.js.map +1 -0
- package/dist/form/resolve_form_properties.d.ts +35 -3
- package/dist/form/resolve_form_properties.js +67 -6
- package/dist/form/resolve_form_properties.js.map +1 -1
- package/dist/hooks/useHistory.d.ts +5 -0
- package/dist/hooks/useHistory.js +22 -6
- package/dist/hooks/useHistory.js.map +1 -1
- package/dist/index.d.ts +50 -0
- package/dist/index.js +34 -7
- package/dist/preview/components/ReferencePreview.js +1 -1
- package/dist/preview/components/ReferencePreview.js.map +1 -1
- package/dist/preview/components/RelationPreview.js +1 -1
- package/dist/preview/components/RelationPreview.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +11 -0
- package/package.json +11 -10
- package/recipes/README.md +131 -0
- package/recipes/bulk-set-status.tsx +62 -0
- package/recipes/calendar-view.tsx +123 -0
- package/recipes/custom-login.tsx +60 -0
- package/recipes/my-preferences.tsx +68 -0
- package/recipes/orders-dashboard.tsx +125 -0
- package/recipes/site-settings.tsx +63 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaChangeDialog.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/SchemaChangeDialog.tsx"],"sourcesContent":["/**\n * What a schema change would do, before it does it.\n *\n * The dialog exists because a schema change has three possible verdicts and two\n * of them are refusals. Without a preview, the only way to discover that a\n * change is refused is to press a button on a live database and read what comes\n * back — which is a fine way to learn and a poor way to work.\n *\n * ## What it shows, in the order somebody reads it\n *\n * The verdict first, in a sentence, because it decides whether the rest is\n * worth reading. Then the changes, each with what it does and — when it is\n * refused — what to do instead. Then the things that are easy to skip past and\n * expensive to have skipped: constraints the change asks for that the database\n * will not end up enforcing. The SQL and the file list come last, collapsed,\n * for the reader who wants them; they are the evidence, not the summary.\n *\n * ## Why the button says \"Commit and apply\"\n *\n * Because that is the order, and the order is the feature. The commit lands\n * first, so a failed apply leaves the repository ahead of the database — the\n * ordinary state of every project between an edit and a deploy, which the next\n * boot reconciles. A button labelled \"Save\" would be describing a different,\n * worse thing.\n */\nimport React from \"react\";\nimport {\n Alert,\n Button,\n Chip,\n CircularProgress,\n cls,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n ExpandablePanel,\n Typography\n} from \"@rebasepro/ui\";\n\nimport type { LiveSchemaPlan, LiveSchemaResult, WithheldConstraint } from \"../../liveSchemaClient\";\n\nexport interface SchemaChangeDialogProps {\n open: boolean;\n /** The collection being changed, for the title. */\n collectionId: string;\n /** `undefined` while the plan is still being fetched. */\n plan?: LiveSchemaPlan;\n /** Set when planning itself failed — a network error, a refusal, a 500. */\n planError?: string;\n /** Set once the change has been applied, which turns this into a receipt. */\n result?: LiveSchemaResult;\n applying: boolean;\n /** Set when the apply threw rather than returning a result. */\n applyError?: string;\n onConfirm: () => void;\n /**\n * Ask again, when planning failed.\n *\n * A dropped connection should cost a click, not the whole wizard. The form\n * is already filled in, and making somebody redo it for a transient failure\n * teaches them to distrust the preview rather than the network.\n */\n onRetry?: () => void;\n /**\n * Write the collection source and leave the database alone.\n *\n * Offered only when the change is refused, and it is what keeps the editor\n * usable while it is. Removing a property is the ordinary case: the ensure\n * path has no `DROP COLUMN`, so a removal can never be applied — and\n * refusing the whole save over it would mean a dev could no longer delete a\n * field from a collection they are still designing.\n *\n * This is exactly what the editor did before live editing existed, so it is\n * not a new hazard; the difference is that it now says what it leaves\n * behind instead of reporting success.\n */\n onSourceOnly?: () => void;\n onClose: () => void;\n /**\n * Why this caller may preview but not apply, when that is the case.\n *\n * A person signed in with an API key, most often. Shown next to a disabled\n * button so the refusal arrives while they are deciding rather than after\n * they have decided.\n */\n applyRefusedBecause?: string;\n /**\n * Where a confirmation would land — `owner/repo` and a branch.\n *\n * On screen before the button, not in the receipt after it. A commit is\n * going somewhere, and which branch it is going to is the one fact somebody\n * cannot recover from being wrong about.\n */\n target?: { repository?: string; branch?: string };\n}\n\ntype Verdict = LiveSchemaPlan[\"verdict\"];\n\n/** What the verdict means, in the words the reader needs rather than the enum's. */\n/**\n * What the verdict means, in the words the reader needs rather than the enum's.\n *\n * `safe` is written twice because the two cases are genuinely different, and\n * saying \"can be made against the running database\" when nothing will be run is\n * the kind of small lie that teaches people to stop reading. A document\n * database has no table to alter, and a change that needs no DDL on a\n * relational one is in the same position: the commit *is* the change.\n */\nconst VERDICT_COPY: Record<Verdict, { title: string; body: string; color: \"info\" | \"warning\" | \"error\" }> = {\n safe: {\n title: \"Ready to apply\",\n body: \"Every change here can be made against the running database.\",\n color: \"info\"\n },\n diverges: {\n title: \"This would leave the database out of step\",\n body: \"The change can be written, but the database will not end up matching it. \" +\n \"The details below say which part, and what would make it applicable.\",\n color: \"warning\"\n },\n \"needs-migration\": {\n title: \"This needs a migration\",\n body: \"Some of this cannot be done to a running database at all — it drops or rewrites \" +\n \"something, and that belongs in a migration somebody has read.\",\n color: \"error\"\n }\n};\n\nconst VERDICT_CHIP: Record<Verdict, { label: string; scheme: \"greenLighter\" | \"orangeLighter\" | \"redLighter\" }> = {\n safe: { label: \"safe\", scheme: \"greenLighter\" },\n diverges: { label: \"diverges\", scheme: \"orangeLighter\" },\n \"needs-migration\": { label: \"needs migration\", scheme: \"redLighter\" }\n};\n\nconst monospace = \"font-mono text-xs leading-relaxed\";\nconst codeBlock = cls(\n monospace,\n \"bg-surface-raised rounded-md p-3 overflow-x-auto whitespace-pre\"\n);\n\n/** A disclosure that starts closed. The evidence, for the reader who wants it. */\nfunction Details({ summary, count, children }: {\n summary: string;\n count: number;\n children: React.ReactNode;\n}) {\n if (count === 0) return null;\n return (\n <ExpandablePanel\n initiallyExpanded={false}\n titleClassName=\"!min-h-0 !py-2 px-3\"\n innerClassName=\"p-3\"\n title={<Typography variant=\"body2\" color=\"secondary\">{summary} ({count})</Typography>}\n >\n {children}\n </ExpandablePanel>\n );\n}\n\n/**\n * What still has to happen after this lands.\n *\n * Above the evidence and below the changes, because it is not a refusal and not\n * a detail: the change will apply, and something outside this dialog still has\n * to be done or a later environment will differ from this one.\n */\nfunction FollowUp({ items }: { items: string[] }) {\n if (items.length === 0) return null;\n return (\n <Alert color=\"info\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {items.length === 1 ? \"One thing to do afterwards\" : \"To do afterwards\"}\n </Typography>\n <ul className=\"space-y-2\">\n {items.map(item => (\n <li key={item} className=\"text-sm\">{item}</li>\n ))}\n </ul>\n </Alert>\n );\n}\n\n/**\n * The destination, short enough to read at a glance.\n *\n * A remote repository already reports itself as `owner/repo`, which is exactly\n * what somebody recognises. A local one reports an absolute path, and the\n * leading directories are the part nobody needs: what matters is which\n * checkout, and its name says that.\n */\nfunction repositoryLabel(repository: string): string {\n if (!repository.startsWith(\"/\")) return repository;\n return repository.split(\"/\").filter(Boolean).pop() ?? repository;\n}\n\nfunction WithheldConstraints({ constraints }: { constraints: WithheldConstraint[] }) {\n if (constraints.length === 0) return null;\n return (\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {constraints.length === 1\n ? \"One constraint will not be enforced\"\n : `${constraints.length} constraints will not be enforced`}\n </Typography>\n <ul className=\"space-y-2\">\n {constraints.map(constraint => (\n <li key={constraint.target} className=\"text-sm\">\n <Typography component=\"code\" variant=\"mono\" className=\"bg-surface-raised px-1 rounded-md\">\n {constraint.target}\n </Typography>\n <Typography variant=\"body2\" className=\"mt-1\">{constraint.reason}</Typography>\n <Typography variant=\"body2\" color=\"secondary\" className=\"mt-1\">\n {constraint.remedy}\n </Typography>\n </li>\n ))}\n </ul>\n </Alert>\n );\n}\n\n/**\n * How far a failed apply got, in a heading.\n *\n * The statements run one at a time with no transaction around them, so only\n * \"none ran\" means the database is as it was.\n */\nfunction partialApplyHeading(result: LiveSchemaResult): string {\n const ran = result.appliedStatements;\n if (ran === 0) return \"The database was not changed\";\n if (ran === undefined) return \"The database may have been changed in part\";\n return `${ran} of ${result.statements.length} statements ran, then one failed`;\n}\n\n/** The receipt. Shown in place of the plan once the change has been applied. */\nfunction Applied({ result }: { result: LiveSchemaResult }) {\n return (\n <div className=\"flex flex-col gap-4\">\n <Alert color={result.applied || result.sourceOnly ? \"success\" : \"warning\"}>\n <Typography variant=\"body2\">{result.summary}</Typography>\n </Alert>\n\n {!result.applied && !result.sourceOnly && result.applyError && (\n // Deliberately not an error state. The commit landed, which is\n // the durable half; the database is now behind the repository,\n // which is where every project sits between an edit and a\n // deploy, and boot reconciles it.\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {partialApplyHeading(result)}\n </Typography>\n <Typography variant=\"body2\">{result.applyError}</Typography>\n <Typography variant=\"body2\" className=\"mt-2\">\n The commit is on <Typography component=\"code\" variant=\"mono\">{result.committed.branch}</Typography> either way, so\n whatever did not run will be applied on the next boot.\n </Typography>\n </Alert>\n )}\n\n <WithheldConstraints constraints={result.withheldConstraints ?? []}/>\n <FollowUp items={result.followUp ?? []}/>\n\n <div>\n <Typography variant=\"label\" color=\"secondary\">Committed</Typography>\n <div className={cls(codeBlock, \"mt-1\")}>\n {result.committed.sha.slice(0, 9)} on {result.committed.branch}\n {\"\\n\"}\n {result.committed.files.map(file => ` ${file}`).join(\"\\n\")}\n </div>\n </div>\n </div>\n );\n}\n\nexport function SchemaChangeDialog({\n open,\n collectionId,\n plan,\n planError,\n result,\n applying,\n applyError,\n onConfirm,\n onRetry,\n onSourceOnly,\n onClose,\n applyRefusedBecause,\n target\n}: SchemaChangeDialogProps) {\n\n const verdict = plan?.verdict;\n const statements = plan?.statements.length ?? 0;\n\n // \"Commit\" only when we positively know there is nothing to apply: a plan\n // that is going ahead and has no statements. A *refused* plan also has none\n // — because it will not run — and labelling that button \"Commit\" would be\n // describing the change it is refusing to make. Unknown reads as the fuller\n // action, which is the safer way to be wrong about a label.\n const commitOnly = Boolean(plan?.applicable) && statements === 0;\n\n // Described from the plan rather than from an assumption about the engine.\n // A document database runs nothing; so does a relational change that only\n // moves source. Both are a commit, and calling either one \"apply\" would be\n // describing something that does not happen.\n // A plan with changes and no statements still changes something — a\n // security rule takes effect when the server next starts — so \"there is\n // no schema change to make\" is said only when there is none.\n const copy = verdict === \"safe\" && commitOnly\n ? {\n title: \"Ready to commit\",\n body: plan && plan.changes.length > 0\n ? \"Nothing runs against the database now. Each change below says what it does and \" +\n \"when it takes effect.\"\n : \"This changes what your project declares. Nothing runs against the database — \" +\n \"there is no schema change to make.\",\n color: \"info\" as const\n }\n : verdict\n ? VERDICT_COPY[verdict]\n : undefined;\n\n return (\n <Dialog open={open} onOpenChange={value => { if (!value) onClose(); }} maxWidth=\"3xl\">\n <DialogTitle className=\"flex items-center gap-2\">\n {result ? (result.sourceOnly ? \"Schema change committed\" : \"Schema change applied\") : \"Review schema change\"}\n <Typography component=\"code\" variant=\"mono\" color=\"secondary\">\n {collectionId}\n </Typography>\n </DialogTitle>\n\n <DialogContent className=\"flex flex-col gap-4\">\n {planError && (\n <Alert color=\"error\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n The change could not be planned\n </Typography>\n <Typography variant=\"body2\">{planError}</Typography>\n </Alert>\n )}\n\n {!plan && !planError && !result && (\n <div className=\"flex items-center gap-3 py-6\">\n <CircularProgress size=\"small\"/>\n <Typography variant=\"body2\" color=\"secondary\">\n Working out what this change would do…\n </Typography>\n </div>\n )}\n\n {result && <Applied result={result}/>}\n\n {plan && !result && copy && (\n <>\n <Alert color={copy.color}>\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {copy.title}\n </Typography>\n <Typography variant=\"body2\">{copy.body}</Typography>\n </Alert>\n\n {applyError && (\n <Alert color=\"error\">\n <Typography variant=\"body2\">{applyError}</Typography>\n </Alert>\n )}\n\n {plan.changes.length === 0 && (\n <Typography variant=\"body2\" color=\"secondary\">\n Nothing here changes the shape of your data. Only the collection\n source changes, and it is committed.\n </Typography>\n )}\n\n {!plan.applicable && onSourceOnly && (\n // Said per change: what a removal leaves behind is\n // not what a type change or a new required field\n // does, and the one that breaks every insert has to\n // be on screen before the button is pressed.\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n Edit source only: commit the collection, leave the database\n </Typography>\n <ul className=\"space-y-1\">\n {plan.changes.filter(change => change.verdict !== \"safe\" && change.sourceOnly).map((change, index) => (\n <li key={`${change.property ?? change.collection}.${index}`} className=\"text-sm\">\n {change.sourceOnly}\n </li>\n ))}\n </ul>\n </Alert>\n )}\n\n {plan.changes.length > 0 && (\n <ul className=\"flex flex-col gap-3\">\n {plan.changes.map((change, index) => (\n <li\n key={`${change.collection}.${change.property ?? \"\"}.${index}`}\n className=\"flex gap-3\"\n >\n <Chip\n size=\"smallest\"\n colorScheme={VERDICT_CHIP[change.verdict].scheme}\n className=\"shrink-0 mt-0.5\"\n >\n {VERDICT_CHIP[change.verdict].label}\n </Chip>\n <div className=\"min-w-0\">\n <Typography variant=\"body2\">{change.detail}</Typography>\n {change.remedy && (\n <Typography\n variant=\"body2\"\n color=\"secondary\"\n className=\"mt-1\"\n >\n {change.remedy}\n </Typography>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n\n <WithheldConstraints constraints={plan.withheldConstraints ?? []}/>\n <FollowUp items={plan.followUp ?? []}/>\n\n {applyRefusedBecause && (\n <Alert color=\"info\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n You can preview this change, but not apply it\n </Typography>\n <Typography variant=\"body2\">{applyRefusedBecause}</Typography>\n </Alert>\n )}\n\n <Details summary=\"Statements that will run\" count={plan.statements.length}>\n <div className={codeBlock}>{plan.statements.join(\"\\n\")}</div>\n </Details>\n\n <Details summary=\"Files that will be committed\" count={plan.files.length}>\n <div className={codeBlock}>{plan.files.join(\"\\n\")}</div>\n </Details>\n\n <Details summary=\"Commit message\" count={plan.message ? 1 : 0}>\n <div className={codeBlock}>{plan.message}</div>\n </Details>\n </>\n )}\n </DialogContent>\n\n <DialogActions>\n {!result && target?.repository && (\n <Typography variant=\"caption\" color=\"secondary\" className={cls(monospace, \"mr-auto truncate\")}>\n → {repositoryLabel(target.repository)}{target.branch ? ` · ${target.branch}` : \"\"}\n </Typography>\n )}\n <Button variant=\"text\" onClick={onClose} disabled={applying}>\n {result ? \"Close\" : \"Cancel\"}\n </Button>\n {!result && planError && onRetry && (\n <Button variant=\"outlined\" onClick={onRetry}>\n Try again\n </Button>\n )}\n {!result && plan && !plan.applicable && onSourceOnly && (\n <Button variant=\"outlined\" onClick={onSourceOnly} disabled={applying}>\n Edit source only\n </Button>\n )}\n {!result && (\n <Button\n variant=\"filled\"\n color=\"primary\"\n onClick={onConfirm}\n // `applicable` is the server's word, not a\n // re-derivation from the verdicts on screen:\n // `applySchemaChange` re-checks it before it writes\n // anything, so a button that disagreed would only\n // produce the same refusal one click later. The same\n // goes for the permission — `/apply` checks it too, and\n // this only saves somebody the round trip.\n disabled={!plan?.applicable || applying || Boolean(applyRefusedBecause)}\n >\n {applying\n ? (commitOnly ? \"Committing…\" : \"Applying…\")\n : (commitOnly ? \"Commit\" : \"Commit and apply\")}\n </Button>\n )}\n </DialogActions>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA6GA,IAAM,eAAsG;CACxG,MAAM;EACF,OAAO;EACP,MAAM;EACN,OAAO;CACX;CACA,UAAU;EACN,OAAO;EACP,MAAM;EAEN,OAAO;CACX;CACA,mBAAmB;EACf,OAAO;EACP,MAAM;EAEN,OAAO;CACX;AACJ;AAEA,IAAM,eAA4G;CAC9G,MAAM;EAAE,OAAO;EAAQ,QAAQ;CAAe;CAC9C,UAAU;EAAE,OAAO;EAAY,QAAQ;CAAgB;CACvD,mBAAmB;EAAE,OAAO;EAAmB,QAAQ;CAAa;AACxE;AAEA,IAAM,YAAY;AAClB,IAAM,YAAY,IACd,WACA,iEACJ;;AAGA,SAAS,QAAQ,EAAE,SAAS,OAAO,YAIhC;CACC,IAAI,UAAU,GAAG,OAAO;CACxB,OACI,oBAAC,iBAAD;EACI,mBAAmB;EACnB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AQ;KACR,OAAM;KACN,SAAS;KAQT,UAAU,CAAC,MAAM,cAAc,YAAY,QAAQ,mBAAmB;eAErE,WACM,aAAa,gBAAgB,cAC7B,aAAa,WAAW;IAC3B,CAAA;GAED,EAAA,CAAA;EACX;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"SchemaChangeDialog.js","names":[],"sources":["../../../../src/collection_editor/ui/collection_editor/SchemaChangeDialog.tsx"],"sourcesContent":["/**\n * What a schema change would do, before it does it.\n *\n * The dialog exists because a schema change has three possible verdicts and two\n * of them are refusals. Without a preview, the only way to discover that a\n * change is refused is to press a button on a live database and read what comes\n * back — which is a fine way to learn and a poor way to work.\n *\n * ## What it shows, in the order somebody reads it\n *\n * The verdict first, in a sentence, because it decides whether the rest is\n * worth reading. Then the changes, each with what it does and — when it is\n * refused — what to do instead. Then the things that are easy to skip past and\n * expensive to have skipped: constraints the change asks for that the database\n * will not end up enforcing. The SQL and the file list come last, collapsed,\n * for the reader who wants them; they are the evidence, not the summary.\n *\n * ## Why the button says \"Commit and apply\"\n *\n * Because that is the order, and the order is the feature. The commit lands\n * first, so a failed apply leaves the repository ahead of the database — the\n * ordinary state of every project between an edit and a deploy, which the next\n * boot reconciles. A button labelled \"Save\" would be describing a different,\n * worse thing.\n */\nimport React from \"react\";\nimport {\n Alert,\n Button,\n Chip,\n CircularProgress,\n cls,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n ExpandablePanel,\n Typography\n} from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\n\nimport type { LiveSchemaPlan, LiveSchemaResult, WithheldConstraint } from \"../../liveSchemaClient\";\n\nexport interface SchemaChangeDialogProps {\n open: boolean;\n /** The collection being changed, for the title. */\n collectionId: string;\n /** `undefined` while the plan is still being fetched. */\n plan?: LiveSchemaPlan;\n /** Set when planning itself failed — a network error, a refusal, a 500. */\n planError?: string;\n /** Set once the change has been applied, which turns this into a receipt. */\n result?: LiveSchemaResult;\n applying: boolean;\n /** Set when the apply threw rather than returning a result. */\n applyError?: string;\n onConfirm: () => void;\n /**\n * Ask again, when planning failed.\n *\n * A dropped connection should cost a click, not the whole wizard. The form\n * is already filled in, and making somebody redo it for a transient failure\n * teaches them to distrust the preview rather than the network.\n */\n onRetry?: () => void;\n /**\n * Write the collection source and leave the database alone.\n *\n * Offered only when the change is refused, and it is what keeps the editor\n * usable while it is. Removing a property is the ordinary case: the ensure\n * path has no `DROP COLUMN`, so a removal can never be applied — and\n * refusing the whole save over it would mean a dev could no longer delete a\n * field from a collection they are still designing.\n *\n * This is exactly what the editor did before live editing existed, so it is\n * not a new hazard; the difference is that it now says what it leaves\n * behind instead of reporting success.\n */\n onSourceOnly?: () => void;\n onClose: () => void;\n /**\n * Why this caller may preview but not apply, when that is the case.\n *\n * A person signed in with an API key, most often. Shown next to a disabled\n * button so the refusal arrives while they are deciding rather than after\n * they have decided.\n */\n applyRefusedBecause?: string;\n /**\n * The change can only be committed as source — the deployment applies\n * nothing to its database — so {@link onSourceOnly} is the main action,\n * labelled \"Commit\", and not refused by {@link applyRefusedBecause}.\n */\n sourceOnlyIsTheCommit?: boolean;\n /**\n * Where a confirmation would land — `owner/repo` and a branch.\n *\n * On screen before the button, not in the receipt after it. A commit is\n * going somewhere, and which branch it is going to is the one fact somebody\n * cannot recover from being wrong about.\n */\n target?: { repository?: string; branch?: string };\n}\n\ntype Verdict = LiveSchemaPlan[\"verdict\"];\n\ntype Translate = ReturnType<typeof useTranslation>[\"t\"];\n\n/**\n * What the verdict means, in the words the reader needs rather than the enum's.\n *\n * `safe` is written twice because the two cases are genuinely different, and\n * saying \"can be made against the running database\" when nothing will be run is\n * the kind of small lie that teaches people to stop reading. A document\n * database has no table to alter, and a change that needs no DDL on a\n * relational one is in the same position: the commit *is* the change.\n */\nconst VERDICT_COPY: Record<Verdict, { titleKey: string; bodyKey: string; color: \"info\" | \"warning\" | \"error\" }> = {\n safe: {\n titleKey: \"schema_change_verdict_safe_title\",\n bodyKey: \"schema_change_verdict_safe_body\",\n color: \"info\"\n },\n diverges: {\n titleKey: \"schema_change_verdict_diverges_title\",\n bodyKey: \"schema_change_verdict_diverges_body\",\n color: \"warning\"\n },\n \"needs-migration\": {\n titleKey: \"schema_change_verdict_migration_title\",\n bodyKey: \"schema_change_verdict_migration_body\",\n color: \"error\"\n }\n};\n\nconst VERDICT_CHIP: Record<Verdict, { labelKey: string; scheme: \"greenLighter\" | \"orangeLighter\" | \"redLighter\" }> = {\n safe: { labelKey: \"schema_change_chip_safe\", scheme: \"greenLighter\" },\n diverges: { labelKey: \"schema_change_chip_diverges\", scheme: \"orangeLighter\" },\n \"needs-migration\": { labelKey: \"schema_change_chip_migration\", scheme: \"redLighter\" }\n};\n\nconst monospace = \"font-mono text-xs leading-relaxed\";\nconst codeBlock = cls(\n monospace,\n \"bg-surface-raised rounded-md p-3 overflow-x-auto whitespace-pre\"\n);\n\n/** A disclosure that starts closed. The evidence, for the reader who wants it. */\nfunction Details({ summary, count, children }: {\n summary: string;\n count: number;\n children: React.ReactNode;\n}) {\n if (count === 0) return null;\n return (\n <ExpandablePanel\n initiallyExpanded={false}\n titleClassName=\"!min-h-0 !py-2 px-3\"\n innerClassName=\"p-3\"\n title={<Typography variant=\"body2\" color=\"secondary\">{summary} ({count})</Typography>}\n >\n {children}\n </ExpandablePanel>\n );\n}\n\n/**\n * What still has to happen after this lands.\n *\n * Above the evidence and below the changes, because it is not a refusal and not\n * a detail: the change will apply, and something outside this dialog still has\n * to be done or a later environment will differ from this one.\n */\nfunction FollowUp({ items }: { items: string[] }) {\n const { t } = useTranslation();\n if (items.length === 0) return null;\n return (\n <Alert color=\"info\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {items.length === 1 ? t(\"schema_change_follow_up_one\") : t(\"schema_change_follow_up\")}\n </Typography>\n <ul className=\"space-y-2\">\n {items.map(item => (\n <li key={item} className=\"text-sm\">{item}</li>\n ))}\n </ul>\n </Alert>\n );\n}\n\n/**\n * The destination, short enough to read at a glance.\n *\n * A remote repository already reports itself as `owner/repo`, which is exactly\n * what somebody recognises. A local one reports an absolute path, and the\n * leading directories are the part nobody needs: what matters is which\n * checkout, and its name says that.\n */\nfunction repositoryLabel(repository: string): string {\n if (!repository.startsWith(\"/\")) return repository;\n return repository.split(\"/\").filter(Boolean).pop() ?? repository;\n}\n\nfunction WithheldConstraints({ constraints }: { constraints: WithheldConstraint[] }) {\n const { t } = useTranslation();\n if (constraints.length === 0) return null;\n return (\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {constraints.length === 1\n ? t(\"schema_change_withheld_one\")\n : t(\"schema_change_withheld_many\", { count: constraints.length })}\n </Typography>\n <ul className=\"space-y-2\">\n {constraints.map(constraint => (\n <li key={constraint.target} className=\"text-sm\">\n <Typography component=\"code\" variant=\"mono\" className=\"bg-surface-raised px-1 rounded-md\">\n {constraint.target}\n </Typography>\n <Typography variant=\"body2\" className=\"mt-1\">{constraint.reason}</Typography>\n <Typography variant=\"body2\" color=\"secondary\" className=\"mt-1\">\n {constraint.remedy}\n </Typography>\n </li>\n ))}\n </ul>\n </Alert>\n );\n}\n\n/**\n * How far a failed apply got, in a heading.\n *\n * The statements run one at a time with no transaction around them, so only\n * \"none ran\" means the database is as it was.\n */\nfunction partialApplyHeading(result: LiveSchemaResult, t: Translate): string {\n const ran = result.appliedStatements;\n if (ran === 0) return t(\"schema_change_db_not_changed\");\n if (ran === undefined) return t(\"schema_change_db_maybe_changed\");\n return t(\"schema_change_statements_partial\", { ran, total: result.statements.length });\n}\n\n/** The receipt. Shown in place of the plan once the change has been applied. */\nfunction Applied({ result }: { result: LiveSchemaResult }) {\n const { t } = useTranslation();\n return (\n <div className=\"flex flex-col gap-4\">\n <Alert color={result.applied || result.sourceOnly ? \"success\" : \"warning\"}>\n <Typography variant=\"body2\">{result.summary}</Typography>\n </Alert>\n\n {!result.applied && !result.sourceOnly && result.applyError && (\n // Deliberately not an error state. The commit landed, which is\n // the durable half; the database is now behind the repository,\n // which is where every project sits between an edit and a\n // deploy, and boot reconciles it.\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {partialApplyHeading(result, t)}\n </Typography>\n <Typography variant=\"body2\">{result.applyError}</Typography>\n <Typography variant=\"body2\" className=\"mt-2\">\n {t(\"schema_change_commit_holds\", { branch: result.committed.branch })}\n </Typography>\n </Alert>\n )}\n\n <WithheldConstraints constraints={result.withheldConstraints ?? []}/>\n <FollowUp items={result.followUp ?? []}/>\n\n <div>\n <Typography variant=\"label\" color=\"secondary\">{t(\"schema_change_committed\")}</Typography>\n <div className={cls(codeBlock, \"mt-1\")}>\n {t(\"schema_change_committed_on\", { sha: result.committed.sha.slice(0, 9), branch: result.committed.branch })}\n {\"\\n\"}\n {result.committed.files.map(file => ` ${file}`).join(\"\\n\")}\n </div>\n </div>\n </div>\n );\n}\n\nexport function SchemaChangeDialog({\n open,\n collectionId,\n plan,\n planError,\n result,\n applying,\n applyError,\n onConfirm,\n onRetry,\n onSourceOnly,\n onClose,\n applyRefusedBecause,\n sourceOnlyIsTheCommit,\n target\n}: SchemaChangeDialogProps) {\n\n const { t } = useTranslation();\n const verdict = plan?.verdict;\n const statements = plan?.statements.length ?? 0;\n\n // \"Commit\" only when we positively know there is nothing to apply: a plan\n // that is going ahead and has no statements. A *refused* plan also has none\n // — because it will not run — and labelling that button \"Commit\" would be\n // describing the change it is refusing to make. Unknown reads as the fuller\n // action, which is the safer way to be wrong about a label.\n const commitOnly = Boolean(plan?.applicable) && statements === 0;\n\n // Described from the plan rather than from an assumption about the engine.\n // A document database runs nothing; so does a relational change that only\n // moves source. Both are a commit, and calling either one \"apply\" would be\n // describing something that does not happen.\n // A plan with changes and no statements still changes something — a\n // security rule takes effect when the server next starts — so \"there is\n // no schema change to make\" is said only when there is none.\n const copy = verdict === \"safe\" && commitOnly\n ? {\n title: t(\"schema_change_commit_only_title\"),\n body: plan && plan.changes.length > 0\n ? t(\"schema_change_commit_only_body\")\n : t(\"schema_change_commit_only_body_no_changes\"),\n color: \"info\" as const\n }\n : verdict\n ? {\n title: t(VERDICT_COPY[verdict].titleKey),\n body: t(VERDICT_COPY[verdict].bodyKey),\n color: VERDICT_COPY[verdict].color\n }\n : undefined;\n\n return (\n <Dialog open={open} onOpenChange={value => { if (!value) onClose(); }} maxWidth=\"3xl\">\n <DialogTitle className=\"flex items-center gap-2\">\n {result\n ? (result.sourceOnly ? t(\"schema_change_title_committed\") : t(\"schema_change_title_applied\"))\n : t(\"schema_change_title_review\")}\n <Typography component=\"code\" variant=\"mono\" color=\"secondary\">\n {collectionId}\n </Typography>\n </DialogTitle>\n\n <DialogContent className=\"flex flex-col gap-4\">\n {planError && (\n <Alert color=\"error\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {t(\"schema_change_plan_failed\")}\n </Typography>\n <Typography variant=\"body2\">{planError}</Typography>\n </Alert>\n )}\n\n {!plan && !planError && !result && (\n <div className=\"flex items-center gap-3 py-6\">\n <CircularProgress size=\"small\"/>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"schema_change_planning\")}\n </Typography>\n </div>\n )}\n\n {result && <Applied result={result}/>}\n\n {plan && !result && copy && (\n <>\n <Alert color={copy.color}>\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {copy.title}\n </Typography>\n <Typography variant=\"body2\">{copy.body}</Typography>\n </Alert>\n\n {applyError && (\n <Alert color=\"error\">\n <Typography variant=\"body2\">{applyError}</Typography>\n </Alert>\n )}\n\n {plan.changes.length === 0 && (\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"schema_change_source_only_changes\")}\n </Typography>\n )}\n\n {!plan.applicable && onSourceOnly && (\n // Said per change: what a removal leaves behind is\n // not what a type change or a new required field\n // does, and the one that breaks every insert has to\n // be on screen before the button is pressed.\n <Alert color=\"warning\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {t(\"schema_change_source_only_title\")}\n </Typography>\n <ul className=\"space-y-1\">\n {plan.changes.filter(change => change.verdict !== \"safe\" && change.sourceOnly).map((change, index) => (\n <li key={`${change.property ?? change.collection}.${index}`} className=\"text-sm\">\n {change.sourceOnly}\n </li>\n ))}\n </ul>\n </Alert>\n )}\n\n {plan.changes.length > 0 && (\n <ul className=\"flex flex-col gap-3\">\n {plan.changes.map((change, index) => (\n <li\n key={`${change.collection}.${change.property ?? \"\"}.${index}`}\n className=\"flex gap-3\"\n >\n <Chip\n size=\"smallest\"\n colorScheme={VERDICT_CHIP[change.verdict].scheme}\n className=\"shrink-0 mt-0.5\"\n >\n {t(VERDICT_CHIP[change.verdict].labelKey)}\n </Chip>\n <div className=\"min-w-0\">\n <Typography variant=\"body2\">{change.detail}</Typography>\n {change.remedy && (\n <Typography\n variant=\"body2\"\n color=\"secondary\"\n className=\"mt-1\"\n >\n {change.remedy}\n </Typography>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n\n <WithheldConstraints constraints={plan.withheldConstraints ?? []}/>\n <FollowUp items={plan.followUp ?? []}/>\n\n {applyRefusedBecause && (\n <Alert color=\"info\">\n <Typography variant=\"body2\" className=\"font-medium mb-1\">\n {t(\"schema_change_preview_only\")}\n </Typography>\n <Typography variant=\"body2\">{applyRefusedBecause}</Typography>\n </Alert>\n )}\n\n <Details summary={t(\"schema_change_statements\")} count={plan.statements.length}>\n <div className={codeBlock}>{plan.statements.join(\"\\n\")}</div>\n </Details>\n\n <Details summary={t(\"schema_change_files\")} count={plan.files.length}>\n <div className={codeBlock}>{plan.files.join(\"\\n\")}</div>\n </Details>\n\n <Details summary={t(\"schema_change_message\")} count={plan.message ? 1 : 0}>\n <div className={codeBlock}>{plan.message}</div>\n </Details>\n </>\n )}\n </DialogContent>\n\n <DialogActions>\n {!result && target?.repository && (\n <Typography variant=\"caption\" color=\"secondary\" className={cls(monospace, \"mr-auto truncate\")}>\n → {repositoryLabel(target.repository)}{target.branch ? ` · ${target.branch}` : \"\"}\n </Typography>\n )}\n <Button variant=\"text\" onClick={onClose} disabled={applying}>\n {result ? t(\"close\") : t(\"cancel\")}\n </Button>\n {!result && planError && onRetry && (\n <Button variant=\"outlined\" onClick={onRetry}>\n {t(\"retry\")}\n </Button>\n )}\n {!result && plan && !plan.applicable && onSourceOnly && (\n <Button variant=\"outlined\" onClick={onSourceOnly} disabled={applying}>\n {t(\"schema_change_edit_source_only\")}\n </Button>\n )}\n {!result && sourceOnlyIsTheCommit && onSourceOnly && (\n <Button variant=\"filled\" color=\"primary\" onClick={onSourceOnly} disabled={applying}>\n {applying ? t(\"schema_change_committing\") : t(\"schema_change_commit\")}\n </Button>\n )}\n {!result && !(sourceOnlyIsTheCommit && onSourceOnly) && (\n <Button\n variant=\"filled\"\n color=\"primary\"\n onClick={onConfirm}\n // `applicable` is the server's word, not a\n // re-derivation from the verdicts on screen:\n // `applySchemaChange` re-checks it before it writes\n // anything, so a button that disagreed would only\n // produce the same refusal one click later. The same\n // goes for the permission — `/apply` checks it too, and\n // this only saves somebody the round trip.\n disabled={!plan?.applicable || applying || Boolean(applyRefusedBecause)}\n >\n {applying\n ? (commitOnly ? t(\"schema_change_committing\") : t(\"schema_change_applying\"))\n : (commitOnly ? t(\"schema_change_commit\") : t(\"schema_change_commit_and_apply\"))}\n </Button>\n )}\n </DialogActions>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAqHA,IAAM,eAA4G;CAC9G,MAAM;EACF,UAAU;EACV,SAAS;EACT,OAAO;CACX;CACA,UAAU;EACN,UAAU;EACV,SAAS;EACT,OAAO;CACX;CACA,mBAAmB;EACf,UAAU;EACV,SAAS;EACT,OAAO;CACX;AACJ;AAEA,IAAM,eAA+G;CACjH,MAAM;EAAE,UAAU;EAA2B,QAAQ;CAAe;CACpE,UAAU;EAAE,UAAU;EAA+B,QAAQ;CAAgB;CAC7E,mBAAmB;EAAE,UAAU;EAAgC,QAAQ;CAAa;AACxF;AAEA,IAAM,YAAY;AAClB,IAAM,YAAY,IACd,WACA,iEACJ;;AAGA,SAAS,QAAQ,EAAE,SAAS,OAAO,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
211
|
switch (v) {
|
|
212
|
-
case "date_time": return "
|
|
213
|
-
case "date": return "
|
|
212
|
+
case "date_time": return t("datetime_mode_date_time");
|
|
213
|
+
case "date": return t("datetime_mode_date");
|
|
214
214
|
default: return "";
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
217
|
disabled,
|
|
218
218
|
children: [/* @__PURE__ */ jsx(SelectItem, {
|
|
219
219
|
value: "date_time",
|
|
220
|
-
children: "
|
|
220
|
+
children: t("datetime_mode_date_time")
|
|
221
221
|
}), /* @__PURE__ */ jsx(SelectItem, {
|
|
222
222
|
value: "date",
|
|
223
|
-
children: "
|
|
223
|
+
children: t("datetime_mode_date")
|
|
224
224
|
})]
|
|
225
225
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
226
226
|
error: Boolean(modeError),
|
|
@@ -230,13 +230,13 @@ function DateTimePropertyField({ disabled }) {
|
|
|
230
230
|
name: autoValuePath,
|
|
231
231
|
disabled,
|
|
232
232
|
fullWidth: true,
|
|
233
|
-
value: autoValueValue ?? "",
|
|
233
|
+
value: autoValueValue ?? "none",
|
|
234
234
|
onValueChange: (v) => setFieldValue(autoValuePath, v === "none" ? null : v),
|
|
235
235
|
renderValue: (v) => {
|
|
236
236
|
switch (v) {
|
|
237
|
-
case "on_create": return "
|
|
238
|
-
case "on_update": return "
|
|
239
|
-
default: return "
|
|
237
|
+
case "on_create": return t("datetime_auto_value_on_create");
|
|
238
|
+
case "on_update": return t("datetime_auto_value_on_update");
|
|
239
|
+
default: return t("datetime_auto_value_none");
|
|
240
240
|
}
|
|
241
241
|
},
|
|
242
242
|
error: Boolean(autoValueError),
|
|
@@ -244,20 +244,20 @@ function DateTimePropertyField({ disabled }) {
|
|
|
244
244
|
children: [
|
|
245
245
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
246
246
|
value: "none",
|
|
247
|
-
children: "
|
|
247
|
+
children: t("datetime_auto_value_none")
|
|
248
248
|
}),
|
|
249
249
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
250
250
|
value: "on_create",
|
|
251
|
-
children: "
|
|
251
|
+
children: t("datetime_auto_value_on_create")
|
|
252
252
|
}),
|
|
253
253
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
254
254
|
value: "on_update",
|
|
255
|
-
children: "
|
|
255
|
+
children: t("datetime_auto_value_on_update")
|
|
256
256
|
})
|
|
257
257
|
]
|
|
258
258
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
259
259
|
error: Boolean(autoValueError),
|
|
260
|
-
children: autoValueError ?? "
|
|
260
|
+
children: autoValueError ?? t("datetime_auto_value_caption")
|
|
261
261
|
})] }),
|
|
262
262
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs(Select, {
|
|
263
263
|
name: timezonePath,
|
|
@@ -266,21 +266,21 @@ function DateTimePropertyField({ disabled }) {
|
|
|
266
266
|
value: timezoneValue ?? "__local__",
|
|
267
267
|
onValueChange: (v) => setFieldValue(timezonePath, v === "__local__" ? void 0 : v),
|
|
268
268
|
renderValue: (v) => {
|
|
269
|
-
if (!v || v === "__local__") return "
|
|
270
|
-
return TIMEZONES.find((
|
|
269
|
+
if (!v || v === "__local__") return t("datetime_timezone_local");
|
|
270
|
+
return TIMEZONES.find((zone) => zone.value === v)?.label ?? v;
|
|
271
271
|
},
|
|
272
272
|
error: Boolean(timezoneError),
|
|
273
273
|
label: t("timezone"),
|
|
274
274
|
children: [/* @__PURE__ */ jsx(SelectItem, {
|
|
275
275
|
value: "__local__",
|
|
276
|
-
children: "
|
|
276
|
+
children: t("datetime_timezone_local")
|
|
277
277
|
}), TIMEZONES.map((tz) => /* @__PURE__ */ jsx(SelectItem, {
|
|
278
278
|
value: tz.value,
|
|
279
279
|
children: tz.label
|
|
280
280
|
}, tz.value))]
|
|
281
281
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
282
282
|
error: Boolean(timezoneError),
|
|
283
|
-
children: timezoneError ?? "
|
|
283
|
+
children: timezoneError ?? t("datetime_timezone_caption")
|
|
284
284
|
})] })
|
|
285
285
|
]
|
|
286
286
|
}),
|
|
@@ -294,11 +294,11 @@ function DateTimePropertyField({ disabled }) {
|
|
|
294
294
|
onValueChange: (v) => setFieldValue(columnTypePath, v === "_default_" ? void 0 : v),
|
|
295
295
|
renderValue: (v) => {
|
|
296
296
|
switch (v) {
|
|
297
|
-
case "timestamp": return "
|
|
297
|
+
case "timestamp": return t("column_type_timestamp");
|
|
298
298
|
case "date": return "date";
|
|
299
299
|
case "time": return "time";
|
|
300
|
-
case "_default_": return "
|
|
301
|
-
default: return "
|
|
300
|
+
case "_default_": return t("column_type_default", { type: "timestamp" });
|
|
301
|
+
default: return t("column_type_default", { type: "timestamp" });
|
|
302
302
|
}
|
|
303
303
|
},
|
|
304
304
|
error: Boolean(columnTypeError),
|
|
@@ -306,11 +306,11 @@ function DateTimePropertyField({ disabled }) {
|
|
|
306
306
|
children: [
|
|
307
307
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
308
308
|
value: "_default_",
|
|
309
|
-
children: "
|
|
309
|
+
children: t("column_type_default", { type: "timestamp" })
|
|
310
310
|
}),
|
|
311
311
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
312
312
|
value: "timestamp",
|
|
313
|
-
children: "
|
|
313
|
+
children: t("column_type_timestamp")
|
|
314
314
|
}),
|
|
315
315
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
316
316
|
value: "date",
|
|
@@ -323,7 +323,7 @@ function DateTimePropertyField({ disabled }) {
|
|
|
323
323
|
]
|
|
324
324
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
325
325
|
error: Boolean(columnTypeError),
|
|
326
|
-
children: columnTypeError ?? "
|
|
326
|
+
children: columnTypeError ?? t("column_type_caption_date")
|
|
327
327
|
})]
|
|
328
328
|
}),
|
|
329
329
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimePropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/DateTimePropertyField.tsx"],"sourcesContent":["import { FieldCaption } from \"../../../_cms_internals\";\nimport React from \"react\";\nimport { getIn, useFormex } from \"@rebasepro/forms\";\n;\nimport { NumberProperty, StringProperty } from \"@rebasepro/types\";\nimport { Select, SelectItem } from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { GeneralPropertyValidation } from \"./validation/GeneralPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\n\n// Common IANA timezones with human-readable labels\nconst TIMEZONES = [\n // UTC\n { value: \"UTC\",\nlabel: \"UTC (Coordinated Universal Time)\" },\n // Americas\n { value: \"America/New_York\",\nlabel: \"New York (US Eastern)\" },\n { value: \"America/Chicago\",\nlabel: \"Chicago (US Central)\" },\n { value: \"America/Denver\",\nlabel: \"Denver (US Mountain)\" },\n { value: \"America/Los_Angeles\",\nlabel: \"Los Angeles (US Pacific)\" },\n { value: \"America/Anchorage\",\nlabel: \"Anchorage (Alaska)\" },\n { value: \"America/Toronto\",\nlabel: \"Toronto (Canada Eastern)\" },\n { value: \"America/Vancouver\",\nlabel: \"Vancouver (Canada Pacific)\" },\n { value: \"America/Mexico_City\",\nlabel: \"Mexico City\" },\n { value: \"America/Sao_Paulo\",\nlabel: \"São Paulo (Brazil)\" },\n { value: \"America/Buenos_Aires\",\nlabel: \"Buenos Aires (Argentina)\" },\n // Europe\n { value: \"Europe/London\",\nlabel: \"London (UK)\" },\n { value: \"Europe/Paris\",\nlabel: \"Paris (France)\" },\n { value: \"Europe/Berlin\",\nlabel: \"Berlin (Germany)\" },\n { value: \"Europe/Madrid\",\nlabel: \"Madrid (Spain)\" },\n { value: \"Europe/Rome\",\nlabel: \"Rome (Italy)\" },\n { value: \"Europe/Amsterdam\",\nlabel: \"Amsterdam (Netherlands)\" },\n { value: \"Europe/Brussels\",\nlabel: \"Brussels (Belgium)\" },\n { value: \"Europe/Zurich\",\nlabel: \"Zurich (Switzerland)\" },\n { value: \"Europe/Stockholm\",\nlabel: \"Stockholm (Sweden)\" },\n { value: \"Europe/Vienna\",\nlabel: \"Vienna (Austria)\" },\n { value: \"Europe/Warsaw\",\nlabel: \"Warsaw (Poland)\" },\n { value: \"Europe/Prague\",\nlabel: \"Prague (Czech Republic)\" },\n { value: \"Europe/Athens\",\nlabel: \"Athens (Greece)\" },\n { value: \"Europe/Moscow\",\nlabel: \"Moscow (Russia)\" },\n { value: \"Europe/Istanbul\",\nlabel: \"Istanbul (Turkey)\" },\n // Asia\n { value: \"Asia/Dubai\",\nlabel: \"Dubai (UAE)\" },\n { value: \"Asia/Kolkata\",\nlabel: \"Mumbai / Delhi (India)\" },\n { value: \"Asia/Bangkok\",\nlabel: \"Bangkok (Thailand)\" },\n { value: \"Asia/Singapore\",\nlabel: \"Singapore\" },\n { value: \"Asia/Hong_Kong\",\nlabel: \"Hong Kong\" },\n { value: \"Asia/Shanghai\",\nlabel: \"Shanghai (China)\" },\n { value: \"Asia/Tokyo\",\nlabel: \"Tokyo (Japan)\" },\n { value: \"Asia/Seoul\",\nlabel: \"Seoul (South Korea)\" },\n { value: \"Asia/Jakarta\",\nlabel: \"Jakarta (Indonesia)\" },\n // Oceania\n { value: \"Australia/Sydney\",\nlabel: \"Sydney (Australia Eastern)\" },\n { value: \"Australia/Melbourne\",\nlabel: \"Melbourne (Australia)\" },\n { value: \"Australia/Brisbane\",\nlabel: \"Brisbane (Australia)\" },\n { value: \"Australia/Perth\",\nlabel: \"Perth (Australia Western)\" },\n { value: \"Pacific/Auckland\",\nlabel: \"Auckland (New Zealand)\" },\n // Africa\n { value: \"Africa/Cairo\",\nlabel: \"Cairo (Egypt)\" },\n { value: \"Africa/Johannesburg\",\nlabel: \"Johannesburg (South Africa)\" },\n { value: \"Africa/Lagos\",\nlabel: \"Lagos (Nigeria)\" }\n];\n\nexport function DateTimePropertyField({ disabled }: {\n disabled: boolean;\n}) {\n\n const {\n values,\n errors,\n touched,\n setFieldValue\n } = useFormex<StringProperty | NumberProperty>();\n const { t } = useTranslation();\n\n const modePath = \"mode\";\n const modeValue: string | undefined = getIn(values, modePath) as string | undefined;\n const modeError: string | undefined = (getIn(touched, modePath) && getIn(errors, modePath)) as string | undefined;\n\n const autoValuePath = \"autoValue\";\n const autoValueValue: string | undefined = getIn(values, autoValuePath) as string | undefined;\n const autoValueError: string | undefined = (getIn(touched, autoValuePath) && getIn(errors, autoValuePath)) as string | undefined;\n\n const timezonePath = \"timezone\";\n const timezoneValue: string | undefined = getIn(values, timezonePath) as string | undefined;\n const timezoneError: string | undefined = (getIn(touched, timezonePath) && getIn(errors, timezonePath)) as string | undefined;\n\n const columnTypePath = \"columnType\";\n const columnTypeValue: string | undefined = getIn(values, columnTypePath) as string | undefined;\n const columnTypeError: string | undefined = (getIn(touched, columnTypePath) && getIn(errors, columnTypePath)) as string | undefined;\n\n return (\n <>\n <div className={\"flex flex-col col-span-12 gap-2\"}>\n <div>\n <Select name={modePath}\n value={modeValue ?? \"date\"}\n error={Boolean(modeError)}\n onValueChange={(v) => setFieldValue(modePath, v)}\n label={t(\"mode\")}\n fullWidth={true}\n renderValue={(v) => {\n switch (v) {\n case \"date_time\":\n return \"Date/Time\";\n case \"date\":\n return \"Date\";\n default:\n return \"\";\n }\n }}\n disabled={disabled}>\n <SelectItem value={\"date_time\"}> Date/Time </SelectItem>\n <SelectItem value={\"date\"}> Date </SelectItem>\n </Select>\n <FieldCaption error={Boolean(modeError)}>\n {modeError}\n </FieldCaption>\n </div>\n <div>\n <Select name={autoValuePath}\n disabled={disabled}\n fullWidth={true}\n value={autoValueValue ?? \"\"}\n onValueChange={(v) => setFieldValue(autoValuePath, v === \"none\" ? null : v)}\n renderValue={(v) => {\n switch (v) {\n case \"on_create\":\n return \"On create\";\n case \"on_update\":\n return \"On any update\";\n default:\n return \"None\";\n }\n }}\n error={Boolean(autoValueError)}\n label={t(\"datetime_automatic_value\")}>\n <SelectItem value={\"none\"}> None </SelectItem>\n <SelectItem value={\"on_create\"}> On create </SelectItem>\n <SelectItem value={\"on_update\"}> On any update </SelectItem>\n </Select>\n <FieldCaption error={Boolean(autoValueError)}>\n {autoValueError ?? \"Update this field automatically when creating or updating the entity\"}\n </FieldCaption>\n </div>\n <div>\n <Select name={timezonePath}\n disabled={disabled}\n fullWidth={true}\n value={timezoneValue ?? \"__local__\"}\n onValueChange={(v) => setFieldValue(timezonePath, v === \"__local__\" ? undefined : v)}\n renderValue={(v) => {\n if (!v || v === \"__local__\") return \"Local timezone\";\n const tz = TIMEZONES.find(t => t.value === v);\n return tz?.label ?? v;\n }}\n error={Boolean(timezoneError)}\n label={t(\"timezone\")}>\n <SelectItem value={\"__local__\"}> Local timezone </SelectItem>\n {TIMEZONES.map((tz) => (\n <SelectItem key={tz.value} value={tz.value}>\n {tz.label}\n </SelectItem>\n ))}\n </Select>\n <FieldCaption error={Boolean(timezoneError)}>\n {timezoneError ?? \"Timezone for displaying and inputting dates. Values are always stored in UTC.\"}\n </FieldCaption>\n </div>\n\n </div>\n\n <div className={\"col-span-12\"}>\n <Select name={columnTypePath}\n disabled={disabled}\n fullWidth={true}\n value={columnTypeValue ?? \"_default_\"}\n onValueChange={(v) => setFieldValue(columnTypePath, v === \"_default_\" ? undefined : v)}\n renderValue={(v) => {\n switch (v) {\n case \"timestamp\": return \"timestamp (with timezone)\";\n case \"date\": return \"date\";\n case \"time\": return \"time\";\n case \"_default_\": return \"Default (timestamp)\";\n default: return \"Default (timestamp)\";\n }\n }}\n error={Boolean(columnTypeError)}\n label={t(\"db_column_type\")}>\n <SelectItem value={\"_default_\"}> Default (timestamp) </SelectItem>\n <SelectItem value={\"timestamp\"}> timestamp (with timezone) </SelectItem>\n <SelectItem value={\"date\"}> date </SelectItem>\n <SelectItem value={\"time\"}> time </SelectItem>\n </Select>\n <FieldCaption error={Boolean(columnTypeError)}>\n {columnTypeError ?? \"Optional database override for this date field.\"}\n </FieldCaption>\n </div>\n\n <div className={\"col-span-12\"}>\n <ValidationPanel>\n <GeneralPropertyValidation disabled={disabled}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C5B,OAAO,EAAE,UAAU;eAXvB,CAYI,oBAAC,YAAD;MAAY,OAAO;gBAAa;KAA4B,CAAA,GAC3D,UAAU,KAAK,OACZ,oBAAC,YAAD;MAA2B,OAAO,GAAG;gBAChC,GAAG;KACI,GAFK,GAAG,KAER,CACf,CACG;QACR,oBAAC,cAAD;KAAc,OAAO,QAAQ,aAAa;eACrC,iBAAiB;IACR,CAAA,CACb,EAAA,CAAA;GAEJ;;EAEL,qBAAC,OAAD;GAAK,WAAW;aAAhB,CACI,qBAAC,QAAD;IAAQ,MAAM;IACA;IACV,WAAW;IACX,OAAO,mBAAmB;IAC1B,gBAAgB,MAAM,cAAc,gBAAgB,MAAM,cAAc,KAAA,IAAY,CAAC;IACrF,cAAc,MAAM;KAChB,QAAQ,GAAR;MACI,KAAK,aAAa,OAAO;MACzB,KAAK,QAAQ,OAAO;MACpB,KAAK,QAAQ,OAAO;MACpB,KAAK,aAAa,OAAO;MACzB,SAAS,OAAO;KACpB;IACJ;IACA,OAAO,QAAQ,eAAe;IAC9B,OAAO,EAAE,gBAAgB;cAf7B;KAgBI,oBAAC,YAAD;MAAY,OAAO;gBAAa;KAAiC,CAAA;KACjE,oBAAC,YAAD;MAAY,OAAO;gBAAa;KAAuC,CAAA;KACvE,oBAAC,YAAD;MAAY,OAAO;gBAAQ;KAAkB,CAAA;KAC7C,oBAAC,YAAD;MAAY,OAAO;gBAAQ;KAAkB,CAAA;IACzC;OACR,oBAAC,cAAD;IAAc,OAAO,QAAQ,eAAe;cACvC,mBAAmB;GACV,CAAA,CACb;;EAEL,oBAAC,OAAD;GAAK,WAAW;aACZ,oBAAC,iBAAD,EAAA,UACI,oBAAC,2BAAD,EAAqC,SAAU,CAAA,EAClC,CAAA;EAChB,CAAA;CACP,EAAA,CAAA;AAEV"}
|
|
1
|
+
{"version":3,"file":"DateTimePropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/DateTimePropertyField.tsx"],"sourcesContent":["import { FieldCaption } from \"../../../_cms_internals\";\nimport React from \"react\";\nimport { getIn, useFormex } from \"@rebasepro/forms\";\n;\nimport { NumberProperty, StringProperty } from \"@rebasepro/types\";\nimport { Select, SelectItem } from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { GeneralPropertyValidation } from \"./validation/GeneralPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\n\n// Common IANA timezones with human-readable labels\nconst TIMEZONES = [\n // UTC\n { value: \"UTC\",\nlabel: \"UTC (Coordinated Universal Time)\" },\n // Americas\n { value: \"America/New_York\",\nlabel: \"New York (US Eastern)\" },\n { value: \"America/Chicago\",\nlabel: \"Chicago (US Central)\" },\n { value: \"America/Denver\",\nlabel: \"Denver (US Mountain)\" },\n { value: \"America/Los_Angeles\",\nlabel: \"Los Angeles (US Pacific)\" },\n { value: \"America/Anchorage\",\nlabel: \"Anchorage (Alaska)\" },\n { value: \"America/Toronto\",\nlabel: \"Toronto (Canada Eastern)\" },\n { value: \"America/Vancouver\",\nlabel: \"Vancouver (Canada Pacific)\" },\n { value: \"America/Mexico_City\",\nlabel: \"Mexico City\" },\n { value: \"America/Sao_Paulo\",\nlabel: \"São Paulo (Brazil)\" },\n { value: \"America/Buenos_Aires\",\nlabel: \"Buenos Aires (Argentina)\" },\n // Europe\n { value: \"Europe/London\",\nlabel: \"London (UK)\" },\n { value: \"Europe/Paris\",\nlabel: \"Paris (France)\" },\n { value: \"Europe/Berlin\",\nlabel: \"Berlin (Germany)\" },\n { value: \"Europe/Madrid\",\nlabel: \"Madrid (Spain)\" },\n { value: \"Europe/Rome\",\nlabel: \"Rome (Italy)\" },\n { value: \"Europe/Amsterdam\",\nlabel: \"Amsterdam (Netherlands)\" },\n { value: \"Europe/Brussels\",\nlabel: \"Brussels (Belgium)\" },\n { value: \"Europe/Zurich\",\nlabel: \"Zurich (Switzerland)\" },\n { value: \"Europe/Stockholm\",\nlabel: \"Stockholm (Sweden)\" },\n { value: \"Europe/Vienna\",\nlabel: \"Vienna (Austria)\" },\n { value: \"Europe/Warsaw\",\nlabel: \"Warsaw (Poland)\" },\n { value: \"Europe/Prague\",\nlabel: \"Prague (Czech Republic)\" },\n { value: \"Europe/Athens\",\nlabel: \"Athens (Greece)\" },\n { value: \"Europe/Moscow\",\nlabel: \"Moscow (Russia)\" },\n { value: \"Europe/Istanbul\",\nlabel: \"Istanbul (Turkey)\" },\n // Asia\n { value: \"Asia/Dubai\",\nlabel: \"Dubai (UAE)\" },\n { value: \"Asia/Kolkata\",\nlabel: \"Mumbai / Delhi (India)\" },\n { value: \"Asia/Bangkok\",\nlabel: \"Bangkok (Thailand)\" },\n { value: \"Asia/Singapore\",\nlabel: \"Singapore\" },\n { value: \"Asia/Hong_Kong\",\nlabel: \"Hong Kong\" },\n { value: \"Asia/Shanghai\",\nlabel: \"Shanghai (China)\" },\n { value: \"Asia/Tokyo\",\nlabel: \"Tokyo (Japan)\" },\n { value: \"Asia/Seoul\",\nlabel: \"Seoul (South Korea)\" },\n { value: \"Asia/Jakarta\",\nlabel: \"Jakarta (Indonesia)\" },\n // Oceania\n { value: \"Australia/Sydney\",\nlabel: \"Sydney (Australia Eastern)\" },\n { value: \"Australia/Melbourne\",\nlabel: \"Melbourne (Australia)\" },\n { value: \"Australia/Brisbane\",\nlabel: \"Brisbane (Australia)\" },\n { value: \"Australia/Perth\",\nlabel: \"Perth (Australia Western)\" },\n { value: \"Pacific/Auckland\",\nlabel: \"Auckland (New Zealand)\" },\n // Africa\n { value: \"Africa/Cairo\",\nlabel: \"Cairo (Egypt)\" },\n { value: \"Africa/Johannesburg\",\nlabel: \"Johannesburg (South Africa)\" },\n { value: \"Africa/Lagos\",\nlabel: \"Lagos (Nigeria)\" }\n];\n\nexport function DateTimePropertyField({ disabled }: {\n disabled: boolean;\n}) {\n\n const {\n values,\n errors,\n touched,\n setFieldValue\n } = useFormex<StringProperty | NumberProperty>();\n const { t } = useTranslation();\n\n const modePath = \"mode\";\n const modeValue: string | undefined = getIn(values, modePath) as string | undefined;\n const modeError: string | undefined = (getIn(touched, modePath) && getIn(errors, modePath)) as string | undefined;\n\n const autoValuePath = \"autoValue\";\n const autoValueValue: string | undefined = getIn(values, autoValuePath) as string | undefined;\n const autoValueError: string | undefined = (getIn(touched, autoValuePath) && getIn(errors, autoValuePath)) as string | undefined;\n\n const timezonePath = \"timezone\";\n const timezoneValue: string | undefined = getIn(values, timezonePath) as string | undefined;\n const timezoneError: string | undefined = (getIn(touched, timezonePath) && getIn(errors, timezonePath)) as string | undefined;\n\n const columnTypePath = \"columnType\";\n const columnTypeValue: string | undefined = getIn(values, columnTypePath) as string | undefined;\n const columnTypeError: string | undefined = (getIn(touched, columnTypePath) && getIn(errors, columnTypePath)) as string | undefined;\n\n return (\n <>\n <div className={\"flex flex-col col-span-12 gap-2\"}>\n <div>\n <Select name={modePath}\n value={modeValue ?? \"date\"}\n error={Boolean(modeError)}\n onValueChange={(v) => setFieldValue(modePath, v)}\n label={t(\"mode\")}\n fullWidth={true}\n renderValue={(v) => {\n switch (v) {\n case \"date_time\":\n return t(\"datetime_mode_date_time\");\n case \"date\":\n return t(\"datetime_mode_date\");\n default:\n return \"\";\n }\n }}\n disabled={disabled}>\n <SelectItem value={\"date_time\"}>{t(\"datetime_mode_date_time\")}</SelectItem>\n <SelectItem value={\"date\"}>{t(\"datetime_mode_date\")}</SelectItem>\n </Select>\n <FieldCaption error={Boolean(modeError)}>\n {modeError}\n </FieldCaption>\n </div>\n <div>\n <Select name={autoValuePath}\n disabled={disabled}\n fullWidth={true}\n // No automatic value is stored as null, and shown as\n // the \"none\" item: an empty value would leave the\n // closed select blank.\n value={autoValueValue ?? \"none\"}\n onValueChange={(v) => setFieldValue(autoValuePath, v === \"none\" ? null : v)}\n renderValue={(v) => {\n switch (v) {\n case \"on_create\":\n return t(\"datetime_auto_value_on_create\");\n case \"on_update\":\n return t(\"datetime_auto_value_on_update\");\n default:\n return t(\"datetime_auto_value_none\");\n }\n }}\n error={Boolean(autoValueError)}\n label={t(\"datetime_automatic_value\")}>\n <SelectItem value={\"none\"}>{t(\"datetime_auto_value_none\")}</SelectItem>\n <SelectItem value={\"on_create\"}>{t(\"datetime_auto_value_on_create\")}</SelectItem>\n <SelectItem value={\"on_update\"}>{t(\"datetime_auto_value_on_update\")}</SelectItem>\n </Select>\n <FieldCaption error={Boolean(autoValueError)}>\n {autoValueError ?? t(\"datetime_auto_value_caption\")}\n </FieldCaption>\n </div>\n <div>\n <Select name={timezonePath}\n disabled={disabled}\n fullWidth={true}\n value={timezoneValue ?? \"__local__\"}\n onValueChange={(v) => setFieldValue(timezonePath, v === \"__local__\" ? undefined : v)}\n renderValue={(v) => {\n if (!v || v === \"__local__\") return t(\"datetime_timezone_local\");\n const tz = TIMEZONES.find(zone => zone.value === v);\n return tz?.label ?? v;\n }}\n error={Boolean(timezoneError)}\n label={t(\"timezone\")}>\n <SelectItem value={\"__local__\"}>{t(\"datetime_timezone_local\")}</SelectItem>\n {TIMEZONES.map((tz) => (\n <SelectItem key={tz.value} value={tz.value}>\n {tz.label}\n </SelectItem>\n ))}\n </Select>\n <FieldCaption error={Boolean(timezoneError)}>\n {timezoneError ?? t(\"datetime_timezone_caption\")}\n </FieldCaption>\n </div>\n\n </div>\n\n <div className={\"col-span-12\"}>\n <Select name={columnTypePath}\n disabled={disabled}\n fullWidth={true}\n value={columnTypeValue ?? \"_default_\"}\n onValueChange={(v) => setFieldValue(columnTypePath, v === \"_default_\" ? undefined : v)}\n renderValue={(v) => {\n switch (v) {\n case \"timestamp\": return t(\"column_type_timestamp\");\n case \"date\": return \"date\";\n case \"time\": return \"time\";\n case \"_default_\": return t(\"column_type_default\", { type: \"timestamp\" });\n default: return t(\"column_type_default\", { type: \"timestamp\" });\n }\n }}\n error={Boolean(columnTypeError)}\n label={t(\"db_column_type\")}>\n <SelectItem value={\"_default_\"}>{t(\"column_type_default\", { type: \"timestamp\" })}</SelectItem>\n <SelectItem value={\"timestamp\"}>{t(\"column_type_timestamp\")}</SelectItem>\n <SelectItem value={\"date\"}> date </SelectItem>\n <SelectItem value={\"time\"}> time </SelectItem>\n </Select>\n <FieldCaption error={Boolean(columnTypeError)}>\n {columnTypeError ?? t(\"column_type_caption_date\")}\n </FieldCaption>\n </div>\n\n <div className={\"col-span-12\"}>\n <ValidationPanel>\n <GeneralPropertyValidation disabled={disabled}/>\n </ValidationPanel>\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,IAAM,YAAY;CAEd;EAAE,OAAO;EACb,OAAO;CAAmC;CAEtC;EAAE,OAAO;EACb,OAAO;CAAwB;CAC3B;EAAE,OAAO;EACb,OAAO;CAAuB;CAC1B;EAAE,OAAO;EACb,OAAO;CAAuB;CAC1B;EAAE,OAAO;EACb,OAAO;CAA2B;CAC9B;EAAE,OAAO;EACb,OAAO;CAAqB;CACxB;EAAE,OAAO;EACb,OAAO;CAA2B;CAC9B;EAAE,OAAO;EACb,OAAO;CAA6B;CAChC;EAAE,OAAO;EACb,OAAO;CAAc;CACjB;EAAE,OAAO;EACb,OAAO;CAAqB;CACxB;EAAE,OAAO;EACb,OAAO;CAA2B;CAE9B;EAAE,OAAO;EACb,OAAO;CAAc;CACjB;EAAE,OAAO;EACb,OAAO;CAAiB;CACpB;EAAE,OAAO;EACb,OAAO;CAAmB;CACtB;EAAE,OAAO;EACb,OAAO;CAAiB;CACpB;EAAE,OAAO;EACb,OAAO;CAAe;CAClB;EAAE,OAAO;EACb,OAAO;CAA0B;CAC7B;EAAE,OAAO;EACb,OAAO;CAAqB;CACxB;EAAE,OAAO;EACb,OAAO;CAAuB;CAC1B;EAAE,OAAO;EACb,OAAO;CAAqB;CACxB;EAAE,OAAO;EACb,OAAO;CAAmB;CACtB;EAAE,OAAO;EACb,OAAO;CAAkB;CACrB;EAAE,OAAO;EACb,OAAO;CAA0B;CAC7B;EAAE,OAAO;EACb,OAAO;CAAkB;CACrB;EAAE,OAAO;EACb,OAAO;CAAkB;CACrB;EAAE,OAAO;EACb,OAAO;CAAoB;C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AAuB,EAAE,MAAM,YAAY,CAAC;KAAc,CAAA;KAC7F,oBAAC,YAAD;MAAY,OAAO;gBAAc,EAAE,uBAAuB;KAAc,CAAA;KACxE,oBAAC,YAAD;MAAY,OAAO;gBAAQ;KAAkB,CAAA;KAC7C,oBAAC,YAAD;MAAY,OAAO;gBAAQ;KAAkB,CAAA;IACzC;OACR,oBAAC,cAAD;IAAc,OAAO,QAAQ,eAAe;cACvC,mBAAmB,EAAE,0BAA0B;GACtC,CAAA,CACb;;EAEL,oBAAC,OAAD;GAAK,WAAW;aACZ,oBAAC,iBAAD,EAAA,UACI,oBAAC,2BAAD,EAAqC,SAAU,CAAA,EAClC,CAAA;EAChB,CAAA;CACP,EAAA,CAAA;AAEV"}
|
|
@@ -38,8 +38,8 @@ function NumberPropertyField({ disabled }) {
|
|
|
38
38
|
case "bigint": return "bigint";
|
|
39
39
|
case "serial": return "serial";
|
|
40
40
|
case "bigserial": return "bigserial";
|
|
41
|
-
case "_default_": return "
|
|
42
|
-
default: return "
|
|
41
|
+
case "_default_": return t("column_type_default", { type: "integer/numeric" });
|
|
42
|
+
default: return t("column_type_default", { type: "integer/numeric" });
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
error: Boolean(columnTypeError),
|
|
@@ -47,7 +47,7 @@ function NumberPropertyField({ disabled }) {
|
|
|
47
47
|
children: [
|
|
48
48
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
49
49
|
value: "_default_",
|
|
50
|
-
children: "
|
|
50
|
+
children: t("column_type_default", { type: "integer/numeric" })
|
|
51
51
|
}),
|
|
52
52
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
53
53
|
value: "integer",
|
|
@@ -80,7 +80,7 @@ function NumberPropertyField({ disabled }) {
|
|
|
80
80
|
]
|
|
81
81
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
82
82
|
error: Boolean(columnTypeError),
|
|
83
|
-
children: columnTypeError ?? "
|
|
83
|
+
children: columnTypeError ?? t("column_type_caption_number")
|
|
84
84
|
})]
|
|
85
85
|
}),
|
|
86
86
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -97,12 +97,12 @@ function NumberPropertyField({ disabled }) {
|
|
|
97
97
|
},
|
|
98
98
|
renderValue: (v) => {
|
|
99
99
|
switch (v) {
|
|
100
|
-
case "true": return "
|
|
101
|
-
case "increment": return "
|
|
102
|
-
case "manual": return "
|
|
100
|
+
case "true": return t("primary_key_identity");
|
|
101
|
+
case "increment": return t("primary_key_increment");
|
|
102
|
+
case "manual": return t("primary_key_manual");
|
|
103
103
|
case "false":
|
|
104
|
-
case "_default_": return "
|
|
105
|
-
default: return
|
|
104
|
+
case "_default_": return t("no");
|
|
105
|
+
default: return t("primary_key_strategy", { strategy: v });
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
108
|
error: Boolean(isIdError),
|
|
@@ -110,24 +110,24 @@ function NumberPropertyField({ disabled }) {
|
|
|
110
110
|
children: [
|
|
111
111
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
112
112
|
value: "_default_",
|
|
113
|
-
children: "
|
|
113
|
+
children: t("no")
|
|
114
114
|
}),
|
|
115
115
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
116
116
|
value: "manual",
|
|
117
|
-
children: "
|
|
117
|
+
children: t("primary_key_manual")
|
|
118
118
|
}),
|
|
119
119
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
120
120
|
value: "true",
|
|
121
|
-
children: "
|
|
121
|
+
children: t("primary_key_identity")
|
|
122
122
|
}),
|
|
123
123
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
124
124
|
value: "increment",
|
|
125
|
-
children: "
|
|
125
|
+
children: t("primary_key_increment")
|
|
126
126
|
})
|
|
127
127
|
]
|
|
128
128
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
129
129
|
error: Boolean(isIdError),
|
|
130
|
-
children: isIdError ?? "
|
|
130
|
+
children: isIdError ?? t("primary_key_caption")
|
|
131
131
|
})]
|
|
132
132
|
}),
|
|
133
133
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberPropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/NumberPropertyField.tsx"],"sourcesContent":["import { FieldCaption } from \"../../../_cms_internals\";\nimport React from \"react\";\nimport { NumberPropertyValidation } from \"./validation/NumberPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\n;\nimport { Select, SelectItem, TextField } from \"@rebasepro/ui\";\nimport { getIn, useFormex } from \"@rebasepro/forms\";\nimport { useTranslation } from \"@rebasepro/app\";\n\nexport function NumberPropertyField({ disabled }: {\n disabled: boolean;\n}) {\n\n const { values, setFieldValue, touched, errors } = useFormex();\n const { t } = useTranslation();\n\n const columnTypePath = \"columnType\";\n const columnTypeValue: string | undefined = getIn(values, columnTypePath) as string | undefined;\n const columnTypeError: string | undefined = (getIn(touched, columnTypePath) && getIn(errors, columnTypePath)) as string | undefined;\n\n const isIdPath = \"isId\";\n const isIdValue: string | boolean | undefined = getIn(values, isIdPath) as string | boolean | undefined;\n const isIdError: string | undefined = (getIn(touched, isIdPath) && getIn(errors, isIdPath)) as string | undefined;\n\n return (\n <>\n\n <div className={\"col-span-12\"}>\n\n <ValidationPanel>\n <NumberPropertyValidation disabled={disabled}/>\n </ValidationPanel>\n\n </div>\n\n <div className={\"col-span-12\"}>\n <Select name={columnTypePath}\n disabled={disabled || Boolean(isIdValue)}\n fullWidth={true}\n value={columnTypeValue ?? \"_default_\"}\n onValueChange={(v) => setFieldValue(columnTypePath, v === \"_default_\" ? undefined : v)}\n renderValue={(v) => {\n switch (v) {\n case \"integer\": return \"integer\";\n case \"real\": return \"real (float4)\";\n case \"double precision\": return \"double precision (float8)\";\n case \"numeric\": return \"numeric / decimal\";\n case \"bigint\": return \"bigint\";\n case \"serial\": return \"serial\";\n case \"bigserial\": return \"bigserial\";\n case \"_default_\": return \"
|
|
1
|
+
{"version":3,"file":"NumberPropertyField.js","names":[],"sources":["../../../../../src/collection_editor/ui/collection_editor/properties/NumberPropertyField.tsx"],"sourcesContent":["import { FieldCaption } from \"../../../_cms_internals\";\nimport React from \"react\";\nimport { NumberPropertyValidation } from \"./validation/NumberPropertyValidation\";\nimport { ValidationPanel } from \"./validation/ValidationPanel\";\n;\nimport { Select, SelectItem, TextField } from \"@rebasepro/ui\";\nimport { getIn, useFormex } from \"@rebasepro/forms\";\nimport { useTranslation } from \"@rebasepro/app\";\n\nexport function NumberPropertyField({ disabled }: {\n disabled: boolean;\n}) {\n\n const { values, setFieldValue, touched, errors } = useFormex();\n const { t } = useTranslation();\n\n const columnTypePath = \"columnType\";\n const columnTypeValue: string | undefined = getIn(values, columnTypePath) as string | undefined;\n const columnTypeError: string | undefined = (getIn(touched, columnTypePath) && getIn(errors, columnTypePath)) as string | undefined;\n\n const isIdPath = \"isId\";\n const isIdValue: string | boolean | undefined = getIn(values, isIdPath) as string | boolean | undefined;\n const isIdError: string | undefined = (getIn(touched, isIdPath) && getIn(errors, isIdPath)) as string | undefined;\n\n return (\n <>\n\n <div className={\"col-span-12\"}>\n\n <ValidationPanel>\n <NumberPropertyValidation disabled={disabled}/>\n </ValidationPanel>\n\n </div>\n\n <div className={\"col-span-12\"}>\n <Select name={columnTypePath}\n disabled={disabled || Boolean(isIdValue)}\n fullWidth={true}\n value={columnTypeValue ?? \"_default_\"}\n onValueChange={(v) => setFieldValue(columnTypePath, v === \"_default_\" ? undefined : v)}\n renderValue={(v) => {\n switch (v) {\n case \"integer\": return \"integer\";\n case \"real\": return \"real (float4)\";\n case \"double precision\": return \"double precision (float8)\";\n case \"numeric\": return \"numeric / decimal\";\n case \"bigint\": return \"bigint\";\n case \"serial\": return \"serial\";\n case \"bigserial\": return \"bigserial\";\n case \"_default_\": return t(\"column_type_default\", { type: \"integer/numeric\" });\n default: return t(\"column_type_default\", { type: \"integer/numeric\" });\n }\n }}\n error={Boolean(columnTypeError)}\n label={t(\"db_column_type\")}>\n <SelectItem value={\"_default_\"}>{t(\"column_type_default\", { type: \"integer/numeric\" })}</SelectItem>\n <SelectItem value={\"integer\"}> integer </SelectItem>\n <SelectItem value={\"real\"}> real (float4) </SelectItem>\n <SelectItem value={\"double precision\"}> double precision (float8) </SelectItem>\n <SelectItem value={\"numeric\"}> numeric / decimal </SelectItem>\n <SelectItem value={\"bigint\"}> bigint </SelectItem>\n <SelectItem value={\"serial\"}> serial </SelectItem>\n <SelectItem value={\"bigserial\"}> bigserial </SelectItem>\n </Select>\n <FieldCaption error={Boolean(columnTypeError)}>\n {columnTypeError ?? t(\"column_type_caption_number\")}\n </FieldCaption>\n </div>\n\n <div className={\"col-span-12\"}>\n <Select name={isIdPath}\n disabled={disabled}\n fullWidth={true}\n value={isIdValue === true ? \"true\" : (isIdValue === false ? \"false\" : (isIdValue ?? \"_default_\"))}\n onValueChange={(v) => {\n if (v === \"_default_\" || v === \"false\") setFieldValue(isIdPath, undefined);\n else if (v === \"true\") setFieldValue(isIdPath, true);\n else setFieldValue(isIdPath, v);\n }}\n renderValue={(v) => {\n switch (v) {\n case \"true\": return t(\"primary_key_identity\");\n case \"increment\": return t(\"primary_key_increment\");\n case \"manual\": return t(\"primary_key_manual\");\n case \"false\":\n case \"_default_\": return t(\"no\");\n default: return t(\"primary_key_strategy\", { strategy: v });\n }\n }}\n error={Boolean(isIdError)}\n label={t(\"primary_key_unique_id\")}>\n <SelectItem value={\"_default_\"}>{t(\"no\")}</SelectItem>\n <SelectItem value={\"manual\"}>{t(\"primary_key_manual\")}</SelectItem>\n <SelectItem value={\"true\"}>{t(\"primary_key_identity\")}</SelectItem>\n <SelectItem value={\"increment\"}>{t(\"primary_key_increment\")}</SelectItem>\n </Select>\n <FieldCaption error={Boolean(isIdError)}>\n {isIdError ?? t(\"primary_key_caption\")}\n </FieldCaption>\n </div>\n\n <div className={\"col-span-12\"}>\n\n <TextField name={\"defaultValue\"}\n disabled={disabled}\n type={\"number\"}\n onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setFieldValue(\"defaultValue\", e.target.value === \"\" ? undefined : parseFloat(e.target.value));\n }}\n label={t(\"default_value\")}\n value={(getIn(values, \"defaultValue\") as string | number | undefined) ?? \"\"}/>\n\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,oBAAoB,EAAE,YAEnC;CAEC,MAAM,EAAE,QAAQ,eAAe,SAAS,WAAW,UAAU;CAC7D,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,iBAAiB;CACvB,MAAM,kBAAsC,MAAM,QAAQ,cAAc;CACxE,MAAM,kBAAuC,MAAM,SAAS,cAAc,KAAK,MAAM,QAAQ,cAAc;CAE3G,MAAM,WAAW;CACjB,MAAM,YAA0C,MAAM,QAAQ,QAAQ;CACtE,MAAM,YAAiC,MAAM,SAAS,QAAQ,KAAK,MAAM,QAAQ,QAAQ;CAEzF,OACI,qBAAA,UAAA,EAAA,UAAA;EAEI,oBAAC,OAAD;GAAK,WAAW;aAEZ,oBAAC,iBAAD,EAAA,UACI,oBAAC,0BAAD,EAAoC,SAAU,CAAA,EACjC,CAAA;EAEhB,CAAA;EAEL,qBAAC,OAAD;GAAK,WAAW;aAAhB,CACI,qBAAC,QAAD;IAAQ,MAAM;IACV,UAAU,YAAY,QAAQ,SAAS;IACvC,WAAW;IACX,OAAO,mBAAmB;IAC1B,gBAAgB,MAAM,cAAc,gBAAgB,MAAM,cAAc,KAAA,IAAY,CAAC;IACrF,cAAc,MAAM;KAChB,QAAQ,GAAR;MACI,KAAK,WAAW,OAAO;MACvB,KAAK,QAAQ,OAAO;MACpB,KAAK,oBAAoB,OAAO;MAChC,KAAK,WAAW,OAAO;MACvB,KAAK,UAAU,OAAO;MACtB,KAAK,UAAU,OAAO;MACtB,KAAK,aAAa,OAAO;MACzB,KAAK,aAAa,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;MAC7E,SAAS,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAA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B,OAAO,EAAE,uBAAuB;cApBpC;KAqBI,oBAAC,YAAD;MAAY,OAAO;gBAAc,EAAE,IAAI;KAAc,CAAA;KACrD,oBAAC,YAAD;MAAY,OAAO;gBAAW,EAAE,oBAAoB;KAAc,CAAA;KAClE,oBAAC,YAAD;MAAY,OAAO;gBAAS,EAAE,sBAAsB;KAAc,CAAA;KAClE,oBAAC,YAAD;MAAY,OAAO;gBAAc,EAAE,uBAAuB;KAAc,CAAA;IACpE;OACR,oBAAC,cAAD;IAAc,OAAO,QAAQ,SAAS;cACjC,aAAa,EAAE,qBAAqB;GAC3B,CAAA,CACb;;EAEL,oBAAC,OAAD;GAAK,WAAW;aAEZ,oBAAC,WAAD;IAAW,MAAM;IACH;IACV,MAAM;IACN,WAAW,MAAiE;KACxE,cAAc,gBAAgB,EAAE,OAAO,UAAU,KAAK,KAAA,IAAY,WAAW,EAAE,OAAO,KAAK,CAAC;IAChG;IACA,OAAO,EAAE,eAAe;IACxB,OAAQ,MAAM,QAAQ,cAAc,KAAqC;GAAI,CAAA;EAEhF,CAAA;CACP,EAAA,CAAA;AAEV"}
|
|
@@ -63,13 +63,13 @@ function StringPropertyField({ widgetId, disabled, showErrors }) {
|
|
|
63
63
|
value: isIdValue === "uuid" ? "uuid" : columnTypeValue ?? "_default_",
|
|
64
64
|
onValueChange: (v) => setFieldValue(columnTypePath, v === "_default_" ? void 0 : v),
|
|
65
65
|
renderValue: (v) => {
|
|
66
|
-
if (isIdValue === "uuid") return "
|
|
66
|
+
if (isIdValue === "uuid") return t("column_type_uuid_forced");
|
|
67
67
|
switch (v) {
|
|
68
|
-
case "text": return "
|
|
69
|
-
case "char": return "
|
|
70
|
-
case "varchar": return "
|
|
71
|
-
case "_default_": return "
|
|
72
|
-
default: return "
|
|
68
|
+
case "text": return t("column_type_text");
|
|
69
|
+
case "char": return t("column_type_char");
|
|
70
|
+
case "varchar": return t("column_type_varchar");
|
|
71
|
+
case "_default_": return t("column_type_default", { type: "text" });
|
|
72
|
+
default: return t("column_type_default", { type: "text" });
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
error: Boolean(columnTypeError),
|
|
@@ -77,28 +77,28 @@ function StringPropertyField({ widgetId, disabled, showErrors }) {
|
|
|
77
77
|
children: [
|
|
78
78
|
isIdValue === "uuid" && /* @__PURE__ */ jsx(SelectItem, {
|
|
79
79
|
value: "uuid",
|
|
80
|
-
children: "
|
|
80
|
+
children: t("column_type_uuid_forced")
|
|
81
81
|
}),
|
|
82
82
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
83
83
|
value: "_default_",
|
|
84
|
-
children: "
|
|
84
|
+
children: t("column_type_default", { type: "text" })
|
|
85
85
|
}),
|
|
86
86
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
87
87
|
value: "varchar",
|
|
88
|
-
children: "
|
|
88
|
+
children: t("column_type_varchar")
|
|
89
89
|
}),
|
|
90
90
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
91
91
|
value: "text",
|
|
92
|
-
children: "
|
|
92
|
+
children: t("column_type_text")
|
|
93
93
|
}),
|
|
94
94
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
95
95
|
value: "char",
|
|
96
|
-
children: "
|
|
96
|
+
children: t("column_type_char")
|
|
97
97
|
})
|
|
98
98
|
]
|
|
99
99
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
100
100
|
error: Boolean(columnTypeError),
|
|
101
|
-
children: columnTypeError ?? "
|
|
101
|
+
children: columnTypeError ?? t("column_type_caption_string")
|
|
102
102
|
})]
|
|
103
103
|
}),
|
|
104
104
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -115,13 +115,13 @@ function StringPropertyField({ widgetId, disabled, showErrors }) {
|
|
|
115
115
|
},
|
|
116
116
|
renderValue: (v) => {
|
|
117
117
|
switch (v) {
|
|
118
|
-
case "true": return "
|
|
119
|
-
case "manual": return "
|
|
120
|
-
case "uuid": return "
|
|
121
|
-
case "cuid": return "
|
|
118
|
+
case "true": return t("primary_key_generated_string");
|
|
119
|
+
case "manual": return t("primary_key_manual");
|
|
120
|
+
case "uuid": return t("primary_key_strategy", { strategy: "UUID" });
|
|
121
|
+
case "cuid": return t("primary_key_strategy", { strategy: "CUID" });
|
|
122
122
|
case "false":
|
|
123
|
-
case "_default_": return "
|
|
124
|
-
default: return
|
|
123
|
+
case "_default_": return t("no");
|
|
124
|
+
default: return t("primary_key_strategy", { strategy: v });
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
127
|
error: Boolean(isIdError),
|
|
@@ -129,28 +129,28 @@ function StringPropertyField({ widgetId, disabled, showErrors }) {
|
|
|
129
129
|
children: [
|
|
130
130
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
131
131
|
value: "_default_",
|
|
132
|
-
children: "
|
|
132
|
+
children: t("no")
|
|
133
133
|
}),
|
|
134
134
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
135
135
|
value: "manual",
|
|
136
|
-
children: "
|
|
136
|
+
children: t("primary_key_manual")
|
|
137
137
|
}),
|
|
138
138
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
139
139
|
value: "true",
|
|
140
|
-
children: "
|
|
140
|
+
children: t("primary_key_generated_string")
|
|
141
141
|
}),
|
|
142
142
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
143
143
|
value: "uuid",
|
|
144
|
-
children: "
|
|
144
|
+
children: t("primary_key_strategy", { strategy: "UUID" })
|
|
145
145
|
}),
|
|
146
146
|
/* @__PURE__ */ jsx(SelectItem, {
|
|
147
147
|
value: "cuid",
|
|
148
|
-
children: "
|
|
148
|
+
children: t("primary_key_strategy", { strategy: "CUID" })
|
|
149
149
|
})
|
|
150
150
|
]
|
|
151
151
|
}), /* @__PURE__ */ jsx(FieldCaption, {
|
|
152
152
|
error: Boolean(isIdError),
|
|
153
|
-
children: isIdError ?? "
|
|
153
|
+
children: isIdError ?? t("primary_key_caption")
|
|
154
154
|
})]
|
|
155
155
|
}),
|
|
156
156
|
/* @__PURE__ */ jsx("div", {
|