@firecms/core 3.0.0-canary.98 → 3.0.0-rc.1
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/README.md +2 -2
- package/dist/app/Drawer.d.ts +0 -1
- package/dist/app/Scaffold.d.ts +4 -0
- package/dist/components/ArrayContainer.d.ts +31 -12
- package/dist/components/{DeleteConfirmationDialog.d.ts → ConfirmationDialog.d.ts} +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +3 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +17 -3
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
- package/dist/components/EntityCollectionTable/index.d.ts +1 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +6 -3
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +8 -0
- package/dist/components/EntityCollectionView/utils.d.ts +3 -0
- package/dist/components/EntityJsonPreview.d.ts +3 -0
- package/dist/components/EntityPreview.d.ts +8 -6
- package/dist/components/HomePage/DefaultHomePage.d.ts +2 -15
- package/dist/components/HomePage/HomePageDnD.d.ts +76 -0
- package/dist/components/HomePage/NavigationCard.d.ts +3 -1
- package/dist/components/HomePage/NavigationCardBinding.d.ts +3 -2
- package/dist/components/HomePage/NavigationGroup.d.ts +8 -1
- package/dist/components/HomePage/RenameGroupDialog.d.ts +9 -0
- package/dist/components/PropertyConfigBadge.d.ts +2 -1
- package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
- package/dist/components/SelectableTable/SelectableTable.d.ts +13 -3
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +1 -1
- package/dist/components/UnsavedChangesDialog.d.ts +8 -0
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +11 -2
- package/dist/components/common/default_entity_actions.d.ts +0 -2
- package/dist/components/common/index.d.ts +1 -1
- package/dist/components/common/useColumnsIds.d.ts +1 -0
- package/dist/components/common/{useDataSourceEntityCollectionTableController.d.ts → useDataSourceTableController.d.ts} +10 -2
- package/dist/components/common/useDebouncedCallback.d.ts +1 -0
- package/dist/components/common/useScrollRestoration.d.ts +14 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/contexts/BreacrumbsContext.d.ts +8 -0
- package/dist/core/DefaultAppBar.d.ts +8 -2
- package/dist/core/DrawerNavigationItem.d.ts +2 -1
- package/dist/core/EntityEditView.d.ts +40 -22
- package/dist/core/EntityEditViewFormActions.d.ts +2 -0
- package/dist/core/FireCMS.d.ts +2 -2
- package/dist/core/FireCMSRouter.d.ts +4 -0
- package/dist/core/NavigationRoutes.d.ts +0 -1
- package/dist/core/SideDialogs.d.ts +4 -2
- package/dist/core/field_configs.d.ts +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/form/EntityForm.d.ts +50 -0
- package/dist/form/EntityFormActions.d.ts +21 -0
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/FormEntry.d.ts +6 -0
- package/dist/form/components/FormLayout.d.ts +5 -0
- package/dist/form/components/LabelWithIcon.d.ts +1 -1
- package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
- package/dist/form/components/index.d.ts +3 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
- package/dist/form/field_bindings/{MultiSelectBinding.d.ts → MultiSelectFieldBinding.d.ts} +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReferenceAsStringFieldBinding.d.ts +9 -0
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +4 -10
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -2
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/index.d.ts +17 -16
- package/dist/form/useClearRestoreValue.d.ts +2 -2
- package/dist/hooks/data/delete.d.ts +4 -4
- package/dist/hooks/data/save.d.ts +3 -3
- package/dist/hooks/data/useCollectionFetch.d.ts +1 -1
- package/dist/hooks/data/useEntityFetch.d.ts +4 -3
- package/dist/hooks/useAuthController.d.ts +1 -1
- package/dist/hooks/useBreadcrumbsController.d.ts +26 -0
- package/dist/hooks/useBuildNavigationController.d.ts +57 -12
- package/dist/hooks/useFireCMSContext.d.ts +1 -1
- package/dist/hooks/useModeController.d.ts +1 -2
- package/dist/hooks/useProjectLog.d.ts +7 -1
- package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
- package/dist/hooks/useValidateAuthenticator.d.ts +3 -3
- package/dist/index.es.js +20108 -14471
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +20039 -14407
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +3 -2
- package/dist/internal/useBuildSideEntityController.d.ts +3 -3
- package/dist/internal/useUnsavedChangesDialog.d.ts +7 -9
- package/dist/preview/PropertyPreviewProps.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +2 -2
- package/dist/preview/util.d.ts +3 -3
- package/dist/routes/CustomCMSRoute.d.ts +4 -0
- package/dist/routes/FireCMSRoute.d.ts +1 -0
- package/dist/routes/HomePageRoute.d.ts +3 -0
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/auth.d.ts +7 -9
- package/dist/types/collections.d.ts +86 -25
- package/dist/types/customization_controller.d.ts +8 -0
- package/dist/types/datasource.d.ts +19 -17
- package/dist/types/dialogs_controller.d.ts +7 -3
- package/dist/types/entities.d.ts +2 -1
- package/dist/types/entity_actions.d.ts +58 -8
- package/dist/types/entity_callbacks.d.ts +16 -16
- package/dist/types/entity_overrides.d.ts +2 -2
- package/dist/types/export_import.d.ts +4 -4
- package/dist/types/fields.d.ts +43 -17
- package/dist/types/firecms.d.ts +16 -3
- package/dist/types/firecms_context.d.ts +1 -1
- package/dist/types/navigation.d.ts +60 -17
- package/dist/types/permissions.d.ts +4 -4
- package/dist/types/plugins.d.ts +42 -9
- package/dist/types/properties.d.ts +65 -22
- package/dist/types/property_config.d.ts +1 -3
- package/dist/types/roles.d.ts +3 -0
- package/dist/types/side_dialogs_controller.d.ts +10 -0
- package/dist/types/side_entity_controller.d.ts +14 -1
- package/dist/types/storage.d.ts +75 -0
- package/dist/types/user.d.ts +1 -0
- package/dist/util/builders.d.ts +3 -3
- package/dist/util/callbacks.d.ts +2 -0
- package/dist/util/createFormexStub.d.ts +2 -0
- package/dist/util/entities.d.ts +2 -2
- package/dist/util/entity_actions.d.ts +2 -0
- package/dist/util/entity_cache.d.ts +23 -0
- package/dist/util/icon_synonyms.d.ts +0 -1
- package/dist/util/icons.d.ts +5 -2
- package/dist/util/index.d.ts +3 -0
- package/dist/util/navigation_from_path.d.ts +10 -1
- package/dist/util/navigation_utils.d.ts +13 -1
- package/dist/util/objects.d.ts +2 -1
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/property_utils.d.ts +4 -4
- package/dist/util/references.d.ts +2 -2
- package/dist/util/resolutions.d.ts +30 -6
- package/dist/util/storage.d.ts +1 -1
- package/dist/util/useStorageUploadController.d.ts +2 -2
- package/package.json +133 -125
- package/src/app/Drawer.tsx +0 -1
- package/src/app/Scaffold.tsx +33 -29
- package/src/components/ArrayContainer.tsx +447 -229
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/ClearFilterSortButton.tsx +1 -1
- package/src/components/{DeleteConfirmationDialog.tsx → ConfirmationDialog.tsx} +12 -11
- package/src/components/DeleteEntityDialog.tsx +13 -20
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +59 -25
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +23 -17
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +20 -3
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +35 -9
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +21 -16
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +6 -12
- package/src/components/EntityCollectionTable/index.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +6 -6
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +35 -26
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +20 -8
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +132 -101
- package/src/components/EntityCollectionTable/internal/popup_field/useDraggable.tsx +9 -9
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +178 -85
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +7 -4
- package/src/components/EntityCollectionView/useSelectionController.tsx +5 -4
- package/src/components/EntityCollectionView/utils.ts +19 -0
- package/src/components/EntityJsonPreview.tsx +66 -0
- package/src/components/EntityPreview.tsx +75 -57
- package/src/components/EntityView.tsx +8 -5
- package/src/components/ErrorView.tsx +3 -3
- package/src/components/FireCMSLogo.tsx +7 -51
- package/src/components/HomePage/DefaultHomePage.tsx +522 -160
- package/src/components/HomePage/FavouritesView.tsx +9 -14
- package/src/components/HomePage/HomePageDnD.tsx +642 -0
- package/src/components/HomePage/NavigationCard.tsx +47 -38
- package/src/components/HomePage/NavigationCardBinding.tsx +16 -15
- package/src/components/HomePage/NavigationGroup.tsx +144 -30
- package/src/components/HomePage/RenameGroupDialog.tsx +117 -0
- package/src/components/HomePage/SmallNavigationCard.tsx +1 -2
- package/src/components/NotFoundPage.tsx +2 -2
- package/src/components/PropertyConfigBadge.tsx +9 -3
- package/src/components/PropertyIdCopyTooltip.tsx +47 -0
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +22 -13
- package/src/components/SearchIconsView.tsx +2 -2
- package/src/components/SelectableTable/SelectableTable.tsx +154 -142
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +4 -2
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +10 -8
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +59 -10
- package/src/components/UnsavedChangesDialog.tsx +46 -0
- package/src/components/VirtualTable/VirtualTable.tsx +65 -44
- package/src/components/VirtualTable/VirtualTableCell.tsx +0 -8
- package/src/components/VirtualTable/VirtualTableHeader.tsx +8 -8
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +1 -1
- package/src/components/VirtualTable/VirtualTableProps.tsx +12 -2
- package/src/components/VirtualTable/VirtualTableRow.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +4 -4
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -2
- package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +16 -28
- package/src/components/common/default_entity_actions.tsx +62 -42
- package/src/components/common/index.ts +1 -1
- package/src/components/common/useColumnsIds.tsx +1 -1
- package/src/components/common/useDataSourceTableController.tsx +420 -0
- package/src/components/common/useDebouncedCallback.tsx +20 -0
- package/src/components/common/useScrollRestoration.tsx +68 -0
- package/src/components/common/useTableSearchHelper.ts +1 -0
- package/src/components/index.tsx +4 -1
- package/src/contexts/BreacrumbsContext.tsx +38 -0
- package/src/contexts/DialogsProvider.tsx +3 -2
- package/src/contexts/ModeController.tsx +1 -3
- package/src/contexts/SnackbarProvider.tsx +2 -0
- package/src/core/DefaultAppBar.tsx +124 -85
- package/src/core/DefaultDrawer.tsx +30 -22
- package/src/core/DrawerNavigationItem.tsx +32 -28
- package/src/core/EntityEditView.tsx +388 -995
- package/src/core/EntityEditViewFormActions.tsx +329 -0
- package/src/core/EntitySidePanel.tsx +88 -20
- package/src/core/FireCMS.tsx +46 -25
- package/src/core/FireCMSRouter.tsx +17 -0
- package/src/core/NavigationRoutes.tsx +23 -32
- package/src/core/SideDialogs.tsx +22 -12
- package/src/core/field_configs.tsx +24 -10
- package/src/core/index.tsx +4 -2
- package/src/form/EntityForm.tsx +814 -0
- package/src/form/EntityFormActions.tsx +211 -0
- package/src/form/PropertyFieldBinding.tsx +55 -41
- package/src/form/components/CustomIdField.tsx +9 -3
- package/src/form/components/FieldHelperText.tsx +1 -1
- package/src/form/components/FormEntry.tsx +22 -0
- package/src/form/components/FormLayout.tsx +16 -0
- package/src/form/components/LabelWithIcon.tsx +30 -19
- package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
- package/src/form/components/StorageItemPreview.tsx +5 -4
- package/src/form/components/StorageUploadProgress.tsx +2 -3
- package/src/form/components/index.tsx +3 -1
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +30 -18
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +47 -36
- package/src/form/field_bindings/BlockFieldBinding.tsx +55 -33
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +18 -14
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +19 -15
- package/src/form/field_bindings/MapFieldBinding.tsx +72 -62
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +159 -0
- package/src/form/field_bindings/{MultiSelectBinding.tsx → MultiSelectFieldBinding.tsx} +26 -21
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +10 -8
- package/src/form/field_bindings/ReferenceAsStringFieldBinding.tsx +135 -0
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +28 -19
- package/src/form/field_bindings/RepeatFieldBinding.tsx +56 -32
- package/src/form/field_bindings/SelectFieldBinding.tsx +22 -13
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +247 -168
- package/src/form/field_bindings/SwitchFieldBinding.tsx +29 -24
- package/src/form/field_bindings/TextFieldBinding.tsx +28 -24
- package/src/form/index.tsx +17 -37
- package/src/form/useClearRestoreValue.tsx +2 -2
- package/src/form/validation.ts +12 -6
- package/src/hooks/data/delete.ts +6 -5
- package/src/hooks/data/save.ts +26 -35
- package/src/hooks/data/useCollectionFetch.tsx +3 -3
- package/src/hooks/data/useDataSource.tsx +10 -2
- package/src/hooks/data/useEntityFetch.tsx +10 -6
- package/src/hooks/useAuthController.tsx +1 -1
- package/src/hooks/useBreadcrumbsController.tsx +31 -0
- package/src/hooks/useBrowserTitleAndIcon.tsx +1 -1
- package/src/hooks/useBuildModeController.tsx +15 -28
- package/src/hooks/useBuildNavigationController.tsx +386 -124
- package/src/hooks/useFireCMSContext.tsx +3 -33
- package/src/hooks/useLargeLayout.tsx +0 -35
- package/src/hooks/useModeController.tsx +1 -2
- package/src/hooks/useProjectLog.tsx +16 -5
- package/src/hooks/useResolvedNavigationFrom.tsx +9 -11
- package/src/hooks/useValidateAuthenticator.tsx +3 -3
- package/src/internal/useBuildDataSource.ts +67 -80
- package/src/internal/useBuildSideDialogsController.tsx +4 -2
- package/src/internal/useBuildSideEntityController.tsx +149 -86
- package/src/internal/useUnsavedChangesDialog.tsx +127 -91
- package/src/preview/PropertyPreview.tsx +28 -12
- package/src/preview/PropertyPreviewProps.tsx +1 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EmptyValue.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +10 -9
- package/src/preview/components/ReferencePreview.tsx +6 -16
- package/src/preview/components/UrlComponentPreview.tsx +20 -21
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +6 -5
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +5 -4
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +5 -3
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -3
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +6 -4
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +5 -3
- package/src/preview/property_previews/MapPropertyPreview.tsx +7 -6
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +13 -13
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/preview/util.ts +10 -10
- package/src/routes/CustomCMSRoute.tsx +21 -0
- package/src/routes/FireCMSRoute.tsx +246 -0
- package/src/routes/HomePageRoute.tsx +17 -0
- package/src/types/analytics.ts +3 -0
- package/src/types/auth.tsx +8 -12
- package/src/types/collections.ts +101 -28
- package/src/types/customization_controller.tsx +9 -0
- package/src/types/datasource.ts +21 -20
- package/src/types/dialogs_controller.tsx +7 -3
- package/src/types/entities.ts +3 -1
- package/src/types/entity_actions.tsx +71 -8
- package/src/types/entity_callbacks.ts +18 -18
- package/src/types/entity_overrides.tsx +2 -2
- package/src/types/export_import.ts +4 -4
- package/src/types/fields.tsx +52 -19
- package/src/types/firecms.tsx +18 -4
- package/src/types/firecms_context.tsx +1 -1
- package/src/types/navigation.ts +76 -22
- package/src/types/permissions.ts +5 -5
- package/src/types/plugins.tsx +50 -9
- package/src/types/properties.ts +74 -22
- package/src/types/property_config.tsx +1 -2
- package/src/types/roles.ts +3 -0
- package/src/types/side_dialogs_controller.tsx +15 -0
- package/src/types/side_entity_controller.tsx +16 -1
- package/src/types/storage.ts +82 -0
- package/src/types/user.ts +2 -0
- package/src/util/builders.ts +10 -8
- package/src/util/callbacks.ts +119 -0
- package/src/util/createFormexStub.tsx +62 -0
- package/src/util/entities.ts +5 -3
- package/src/util/entity_actions.ts +28 -0
- package/src/util/entity_cache.ts +204 -0
- package/src/util/icon_list.ts +1 -1
- package/src/util/icon_synonyms.ts +0 -1
- package/src/util/icons.tsx +36 -11
- package/src/util/index.ts +3 -0
- package/src/util/join_collections.ts +9 -2
- package/src/util/make_properties_editable.ts +13 -5
- package/src/util/navigation_from_path.ts +33 -12
- package/src/util/navigation_utils.ts +135 -19
- package/src/util/objects.ts +74 -14
- package/src/util/parent_references_from_path.ts +3 -3
- package/src/util/permissions.ts +8 -8
- package/src/util/property_utils.tsx +17 -6
- package/src/util/references.ts +19 -8
- package/src/util/resolutions.ts +93 -24
- package/src/util/storage.ts +6 -2
- package/src/util/useStorageUploadController.tsx +74 -29
- package/dist/components/EntityCollectionTable/internal/popup_field/ElementResizeListener.d.ts +0 -5
- package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
- package/dist/form/PropertiesForm.d.ts +0 -8
- package/dist/form/components/FormikArrayContainer.d.ts +0 -18
- package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
- package/src/components/EntityCollectionTable/internal/popup_field/ElementResizeListener.tsx +0 -59
- package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +0 -236
- package/src/form/PropertiesForm.tsx +0 -81
- package/src/form/components/FormikArrayContainer.tsx +0 -44
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +0 -695
- /package/src/util/{common.tsx → common.ts} +0 -0
|
@@ -4,15 +4,28 @@ import { Entity } from "./entities";
|
|
|
4
4
|
import { EntityCollection, SelectionController } from "./collections";
|
|
5
5
|
import { User } from "./user";
|
|
6
6
|
import { SideEntityController } from "./side_entity_controller";
|
|
7
|
+
import { FormContext } from "./fields";
|
|
7
8
|
/**
|
|
8
9
|
* An entity action is a custom action that can be performed on an entity.
|
|
9
10
|
* They are displayed in the entity view and in the collection view.
|
|
10
11
|
*/
|
|
11
|
-
export type EntityAction<M extends object = any,
|
|
12
|
+
export type EntityAction<M extends object = any, USER extends User = User> = {
|
|
12
13
|
/**
|
|
13
14
|
* Title of the action
|
|
14
15
|
*/
|
|
15
16
|
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Key of the action. You only need to provide this if you want to
|
|
19
|
+
* override the default actions, or if you are not passing the action
|
|
20
|
+
* directly to the `entityActions` prop of a collection.
|
|
21
|
+
* You can define your actions at the app level, in which case you
|
|
22
|
+
* must provide a key.
|
|
23
|
+
* The default actions are:
|
|
24
|
+
* - edit
|
|
25
|
+
* - delete
|
|
26
|
+
* - copy
|
|
27
|
+
*/
|
|
28
|
+
key?: string;
|
|
16
29
|
/**
|
|
17
30
|
* Icon of the action
|
|
18
31
|
*/
|
|
@@ -21,7 +34,12 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
|
|
|
21
34
|
* Callback when the action is clicked
|
|
22
35
|
* @param props
|
|
23
36
|
*/
|
|
24
|
-
onClick: (props: EntityActionClickProps<M,
|
|
37
|
+
onClick: (props: EntityActionClickProps<M, USER>) => Promise<void> | void;
|
|
38
|
+
/**
|
|
39
|
+
* Optional callback in case you want to disable the action
|
|
40
|
+
* @param props
|
|
41
|
+
*/
|
|
42
|
+
isEnabled?: (props: EntityActionClickProps<M, USER>) => boolean;
|
|
25
43
|
/**
|
|
26
44
|
* Show this action collapsed in the menu of the collection view.
|
|
27
45
|
* Defaults to true
|
|
@@ -33,17 +51,49 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
|
|
|
33
51
|
*/
|
|
34
52
|
includeInForm?: boolean;
|
|
35
53
|
};
|
|
36
|
-
export type EntityActionClickProps<M extends object,
|
|
37
|
-
entity
|
|
38
|
-
context: FireCMSContext<
|
|
54
|
+
export type EntityActionClickProps<M extends object, USER extends User = User> = {
|
|
55
|
+
entity?: Entity<M>;
|
|
56
|
+
context: FireCMSContext<USER>;
|
|
39
57
|
fullPath?: string;
|
|
58
|
+
fullIdPath?: string;
|
|
40
59
|
collection?: EntityCollection<M>;
|
|
60
|
+
/**
|
|
61
|
+
* Optional form context, present if the action is being called from a form.
|
|
62
|
+
* This allows you to access the form state and methods, including modifying the form values.
|
|
63
|
+
*/
|
|
64
|
+
formContext?: FormContext;
|
|
65
|
+
/**
|
|
66
|
+
* Present if this actions is being called from a side dialog only
|
|
67
|
+
*/
|
|
68
|
+
sideEntityController?: SideEntityController;
|
|
69
|
+
/**
|
|
70
|
+
* Is the action being called from the collection view or from the entity form view?
|
|
71
|
+
*/
|
|
72
|
+
view: "collection" | "form";
|
|
73
|
+
/**
|
|
74
|
+
* If the action is rendered in the form, is it open in a side panel or full screen?
|
|
75
|
+
*/
|
|
76
|
+
openEntityMode: "side_panel" | "full_screen";
|
|
77
|
+
/**
|
|
78
|
+
* Optional selection controller, present if the action is being called from a collection view
|
|
79
|
+
*/
|
|
41
80
|
selectionController?: SelectionController;
|
|
81
|
+
/**
|
|
82
|
+
* Optional highlight function to highlight the entity in the collection view
|
|
83
|
+
* @param entity
|
|
84
|
+
*/
|
|
42
85
|
highlightEntity?: (entity: Entity<any>) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Optional unhighlight function to remove the highlight from the entity in the collection view
|
|
88
|
+
* @param entity
|
|
89
|
+
*/
|
|
43
90
|
unhighlightEntity?: (entity: Entity<any>) => void;
|
|
44
|
-
onCollectionChange?: () => void;
|
|
45
91
|
/**
|
|
46
|
-
*
|
|
92
|
+
* Optional function to navigate back (e.g. when deleting an entity or navigating from a form)
|
|
47
93
|
*/
|
|
48
|
-
|
|
94
|
+
navigateBack?: () => void;
|
|
95
|
+
/**
|
|
96
|
+
* Callback to be called when the collection changes, e.g. after an entity is deleted or created.
|
|
97
|
+
*/
|
|
98
|
+
onCollectionChange?: () => void;
|
|
49
99
|
};
|
|
@@ -9,29 +9,29 @@ import { User } from "./user";
|
|
|
9
9
|
* Useful for adding your own logic or blocking the execution of the operation.
|
|
10
10
|
* @group Models
|
|
11
11
|
*/
|
|
12
|
-
export type EntityCallbacks<M extends Record<string, any> = any,
|
|
12
|
+
export type EntityCallbacks<M extends Record<string, any> = any, USER extends User = User> = {
|
|
13
13
|
/**
|
|
14
14
|
* Callback used after fetching data
|
|
15
15
|
* @param entityFetchProps
|
|
16
16
|
*/
|
|
17
|
-
onFetch?(entityFetchProps: EntityOnFetchProps<M,
|
|
17
|
+
onFetch?(entityFetchProps: EntityOnFetchProps<M, USER>): Promise<Entity<M>> | Entity<M>;
|
|
18
18
|
/**
|
|
19
19
|
* Callback used when save is successful
|
|
20
20
|
* @param entitySaveProps
|
|
21
21
|
*/
|
|
22
|
-
onSaveSuccess?(entitySaveProps: EntityOnSaveProps<M,
|
|
22
|
+
onSaveSuccess?(entitySaveProps: EntityOnSaveProps<M, USER>): Promise<void> | void;
|
|
23
23
|
/**
|
|
24
24
|
* Callback used when saving fails
|
|
25
25
|
* @param entitySaveProps
|
|
26
26
|
*/
|
|
27
|
-
onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M,
|
|
27
|
+
onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M, USER>): Promise<void> | void;
|
|
28
28
|
/**
|
|
29
29
|
* Callback used before saving, you need to return the values that will get
|
|
30
30
|
* saved. If you throw an error in this method the process stops, and an
|
|
31
31
|
* error snackbar gets displayed.
|
|
32
32
|
* @param entitySaveProps
|
|
33
33
|
*/
|
|
34
|
-
onPreSave?(entitySaveProps: EntityOnPreSaveProps<M,
|
|
34
|
+
onPreSave?(entitySaveProps: EntityOnPreSaveProps<M, USER>): Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
|
|
35
35
|
/**
|
|
36
36
|
* Callback used after the entity is deleted.
|
|
37
37
|
* If you throw an error in this method the process stops, and an
|
|
@@ -39,13 +39,13 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
39
39
|
*
|
|
40
40
|
* @param entityDeleteProps
|
|
41
41
|
*/
|
|
42
|
-
onPreDelete?(entityDeleteProps: EntityOnDeleteProps<M,
|
|
42
|
+
onPreDelete?(entityDeleteProps: EntityOnDeleteProps<M, USER>): void;
|
|
43
43
|
/**
|
|
44
44
|
* Callback used after the entity is deleted.
|
|
45
45
|
*
|
|
46
46
|
* @param entityDeleteProps
|
|
47
47
|
*/
|
|
48
|
-
onDelete?(entityDeleteProps: EntityOnDeleteProps<M,
|
|
48
|
+
onDelete?(entityDeleteProps: EntityOnDeleteProps<M, USER>): void;
|
|
49
49
|
/**
|
|
50
50
|
* Callback fired when any value in the form changes. You can use it
|
|
51
51
|
* to define the ID of a `new` entity based on the current values.
|
|
@@ -59,11 +59,11 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
59
59
|
* Parameters passed to hooks when an entity is fetched
|
|
60
60
|
* @group Models
|
|
61
61
|
*/
|
|
62
|
-
export interface EntityOnFetchProps<M extends Record<string, any> = any,
|
|
62
|
+
export interface EntityOnFetchProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
63
63
|
/**
|
|
64
64
|
* Collection of the entity
|
|
65
65
|
*/
|
|
66
|
-
collection: EntityCollection<M,
|
|
66
|
+
collection: EntityCollection<M, USER>;
|
|
67
67
|
/**
|
|
68
68
|
* Full path of the CMS where this collection is being fetched.
|
|
69
69
|
* Might contain unresolved aliases.
|
|
@@ -76,27 +76,27 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, UserTyp
|
|
|
76
76
|
/**
|
|
77
77
|
* Context of the app status
|
|
78
78
|
*/
|
|
79
|
-
context: FireCMSContext<
|
|
79
|
+
context: FireCMSContext<USER>;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Parameters passed to hooks before an entity is saved
|
|
83
83
|
* @group Models
|
|
84
84
|
*/
|
|
85
|
-
export type EntityOnPreSaveProps<M extends Record<string, any> = any,
|
|
85
|
+
export type EntityOnPreSaveProps<M extends Record<string, any> = any, USER extends User = User> = Omit<EntityOnSaveProps<M, USER>, "entityId"> & {
|
|
86
86
|
entityId?: string;
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
89
|
* Parameters passed to hooks before an entity is saved
|
|
90
90
|
* @group Models
|
|
91
91
|
*/
|
|
92
|
-
export type EntityOnSaveFailureProps<M extends Record<string, any> = any,
|
|
92
|
+
export type EntityOnSaveFailureProps<M extends Record<string, any> = any, USER extends User = User> = Omit<EntityOnSaveProps<M, USER>, "entityId"> & {
|
|
93
93
|
entityId?: string;
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
96
|
* Parameters passed to hooks when an entity is saved
|
|
97
97
|
* @group Models
|
|
98
98
|
*/
|
|
99
|
-
export interface EntityOnSaveProps<M extends Record<string, any> = any,
|
|
99
|
+
export interface EntityOnSaveProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
100
100
|
/**
|
|
101
101
|
* Resolved collection of the entity
|
|
102
102
|
*/
|
|
@@ -129,13 +129,13 @@ export interface EntityOnSaveProps<M extends Record<string, any> = any, UserType
|
|
|
129
129
|
/**
|
|
130
130
|
* Context of the app status
|
|
131
131
|
*/
|
|
132
|
-
context: FireCMSContext<
|
|
132
|
+
context: FireCMSContext<USER>;
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* Parameters passed to hooks when an entity is deleted
|
|
136
136
|
* @group Models
|
|
137
137
|
*/
|
|
138
|
-
export interface EntityOnDeleteProps<M extends Record<string, any> = any,
|
|
138
|
+
export interface EntityOnDeleteProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
139
139
|
/**
|
|
140
140
|
* collection of the entity being deleted
|
|
141
141
|
*/
|
|
@@ -155,7 +155,7 @@ export interface EntityOnDeleteProps<M extends Record<string, any> = any, UserTy
|
|
|
155
155
|
/**
|
|
156
156
|
* Context of the app status
|
|
157
157
|
*/
|
|
158
|
-
context: FireCMSContext<
|
|
158
|
+
context: FireCMSContext<USER>;
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* Parameters passed to hooks when an entity is deleted
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataSourceDelegate } from "./datasource";
|
|
2
2
|
import { StorageSource } from "./storage";
|
|
3
3
|
export type EntityOverrides = {
|
|
4
|
-
|
|
4
|
+
dataSourceDelegate?: DataSourceDelegate;
|
|
5
5
|
storageSource?: StorageSource;
|
|
6
6
|
};
|
|
@@ -6,16 +6,16 @@ import { FireCMSContext } from "./firecms_context";
|
|
|
6
6
|
* exports
|
|
7
7
|
* @group Models
|
|
8
8
|
*/
|
|
9
|
-
export interface ExportConfig<
|
|
10
|
-
additionalFields: ExportMappingFunction<
|
|
9
|
+
export interface ExportConfig<USER extends User = User> {
|
|
10
|
+
additionalFields: ExportMappingFunction<USER>[];
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* @group Models
|
|
14
14
|
*/
|
|
15
|
-
export interface ExportMappingFunction<
|
|
15
|
+
export interface ExportMappingFunction<USER extends User = User> {
|
|
16
16
|
key: string;
|
|
17
17
|
builder: ({ entity, context }: {
|
|
18
18
|
entity: Entity<any>;
|
|
19
|
-
context: FireCMSContext<
|
|
19
|
+
context: FireCMSContext<USER>;
|
|
20
20
|
}) => Promise<string> | string;
|
|
21
21
|
}
|
package/dist/types/fields.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CMSType, PropertyOrBuilder } from "./properties";
|
|
1
|
+
import { CMSType, Property, PropertyOrBuilder } from "./properties";
|
|
2
2
|
import { ResolvedEntityCollection, ResolvedProperty } from "./resolved_entities";
|
|
3
3
|
import { FormexController } from "@firecms/formex";
|
|
4
|
+
import { Entity } from "./entities";
|
|
4
5
|
/**
|
|
5
6
|
* When building a custom field you need to create a React component that takes
|
|
6
7
|
* this interface as props.
|
|
@@ -52,7 +53,7 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
52
53
|
/**
|
|
53
54
|
* Property related to this field
|
|
54
55
|
*/
|
|
55
|
-
property: ResolvedProperty<T>;
|
|
56
|
+
property: Property<T> | ResolvedProperty<T>;
|
|
56
57
|
/**
|
|
57
58
|
* Should this field include a description
|
|
58
59
|
*/
|
|
@@ -67,13 +68,10 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
67
68
|
*/
|
|
68
69
|
partOfArray?: boolean;
|
|
69
70
|
/**
|
|
70
|
-
*
|
|
71
|
+
* Display the child properties directly, without being wrapped in an
|
|
72
|
+
* extendable panel. Note that this will also hide the title of this property.
|
|
71
73
|
*/
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Is this field being rendered in the entity table popup
|
|
75
|
-
*/
|
|
76
|
-
tableMode?: boolean;
|
|
74
|
+
minimalistView?: boolean;
|
|
77
75
|
/**
|
|
78
76
|
* Should this field autofocus on mount
|
|
79
77
|
*/
|
|
@@ -81,7 +79,7 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
81
79
|
/**
|
|
82
80
|
* Additional properties set by the developer
|
|
83
81
|
*/
|
|
84
|
-
customProps
|
|
82
|
+
customProps: CustomProps;
|
|
85
83
|
/**
|
|
86
84
|
* Additional values related to the state of the form or the entity
|
|
87
85
|
*/
|
|
@@ -90,6 +88,18 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
90
88
|
* Flag to indicate if this field should be disabled
|
|
91
89
|
*/
|
|
92
90
|
disabled?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Size of the field
|
|
93
|
+
*/
|
|
94
|
+
size?: "small" | "medium" | "large";
|
|
95
|
+
/**
|
|
96
|
+
* Some properties might change internal state (like expanding a panel).
|
|
97
|
+
* This function should be called when the internal state changes.
|
|
98
|
+
* This is used to preserve state in array containers.
|
|
99
|
+
*
|
|
100
|
+
* @param property
|
|
101
|
+
*/
|
|
102
|
+
onPropertyChange?: (property: Partial<Property<any>>) => void;
|
|
93
103
|
}
|
|
94
104
|
/**
|
|
95
105
|
* Context passed to custom fields
|
|
@@ -118,15 +128,22 @@ export interface FormContext<M extends Record<string, any> = any> {
|
|
|
118
128
|
/**
|
|
119
129
|
* Entity id, it can be null if it's a new entity
|
|
120
130
|
*/
|
|
121
|
-
entityId
|
|
131
|
+
entityId: string;
|
|
122
132
|
/**
|
|
123
133
|
* Path this entity is located at
|
|
124
134
|
*/
|
|
125
135
|
path?: string;
|
|
136
|
+
status: "new" | "existing" | "copy";
|
|
137
|
+
entity?: Entity<M>;
|
|
138
|
+
savingError?: Error;
|
|
139
|
+
openEntityMode: "side_panel" | "full_screen";
|
|
126
140
|
/**
|
|
127
|
-
* This is the underlying formex controller that powers the form
|
|
141
|
+
* This is the underlying formex controller that powers the form.
|
|
142
|
+
* If you are in a red only mode, the formex controller is there, but you can't
|
|
143
|
+
* operate with it
|
|
128
144
|
*/
|
|
129
145
|
formex: FormexController<M>;
|
|
146
|
+
disabled: boolean;
|
|
130
147
|
}
|
|
131
148
|
/**
|
|
132
149
|
* In case you need to render a field bound to a Property inside your
|
|
@@ -157,18 +174,15 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
|
|
|
157
174
|
* field is being edited
|
|
158
175
|
*/
|
|
159
176
|
underlyingValueHasChanged?: boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Is this field being rendered in a table
|
|
162
|
-
*/
|
|
163
|
-
tableMode?: boolean;
|
|
164
177
|
/**
|
|
165
178
|
* Is this field part of an array
|
|
166
179
|
*/
|
|
167
180
|
partOfArray?: boolean;
|
|
168
181
|
/**
|
|
169
|
-
*
|
|
182
|
+
* Display the child properties directly, without being wrapped in an
|
|
183
|
+
* extendable panel. Note that this will also hide the title of this property.
|
|
170
184
|
*/
|
|
171
|
-
|
|
185
|
+
minimalistView?: boolean;
|
|
172
186
|
/**
|
|
173
187
|
* Should the field take focus when rendered. When opening the popup view
|
|
174
188
|
* in table mode, it makes sense to put the focus on the only field rendered.
|
|
@@ -183,4 +197,16 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
|
|
|
183
197
|
* Only used when the field is part of an array.
|
|
184
198
|
*/
|
|
185
199
|
index?: number;
|
|
200
|
+
/**
|
|
201
|
+
* The size of the field
|
|
202
|
+
*/
|
|
203
|
+
size?: "small" | "medium" | "large";
|
|
204
|
+
/**
|
|
205
|
+
* Some properties might change internal state (like expanding a panel).
|
|
206
|
+
* This function should be called when the internal state changes.
|
|
207
|
+
* This is used to preserve state in array containers.
|
|
208
|
+
*
|
|
209
|
+
* @param property
|
|
210
|
+
*/
|
|
211
|
+
onPropertyChange?: (property: Partial<Property<any>>) => void;
|
|
186
212
|
}
|
package/dist/types/firecms.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { EntityLinkBuilder } from "./entity_link_builder";
|
|
|
12
12
|
import { UserConfigurationPersistence } from "./local_config_persistence";
|
|
13
13
|
import { FireCMSPlugin } from "./plugins";
|
|
14
14
|
import { CMSAnalyticsEvent } from "./analytics";
|
|
15
|
+
import { EntityAction } from "./entity_actions";
|
|
15
16
|
/**
|
|
16
17
|
* Use this callback to build entity collections dynamically.
|
|
17
18
|
* You can use the user to decide which collections to show.
|
|
@@ -44,7 +45,7 @@ export type CMSViewsBuilder = (params: {
|
|
|
44
45
|
/**
|
|
45
46
|
* @group Models
|
|
46
47
|
*/
|
|
47
|
-
export type FireCMSProps<
|
|
48
|
+
export type FireCMSProps<USER extends User> = {
|
|
48
49
|
/**
|
|
49
50
|
* Use this function to return the components you want to render under
|
|
50
51
|
* FireCMS
|
|
@@ -62,6 +63,10 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
62
63
|
*/
|
|
63
64
|
loading: boolean;
|
|
64
65
|
}) => React.ReactNode;
|
|
66
|
+
/**
|
|
67
|
+
* If you have a custom API key, you can use it here.
|
|
68
|
+
*/
|
|
69
|
+
apiKey?: string;
|
|
65
70
|
/**
|
|
66
71
|
* Record of custom form fields to be used in the CMS.
|
|
67
72
|
* You can use the key to reference the custom field in
|
|
@@ -81,6 +86,13 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
81
86
|
* You can also define an entity view from the UI.
|
|
82
87
|
*/
|
|
83
88
|
entityViews?: EntityCustomView[];
|
|
89
|
+
/**
|
|
90
|
+
* List of actions that can be performed on entities.
|
|
91
|
+
* These actions are displayed in the entity view and in the collection view.
|
|
92
|
+
* You can later reuse these actions in the `entityActions` prop of a collection,
|
|
93
|
+
* by specifying the `key` of the action.
|
|
94
|
+
*/
|
|
95
|
+
entityActions?: EntityAction[];
|
|
84
96
|
/**
|
|
85
97
|
* Format of the dates in the CMS.
|
|
86
98
|
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
@@ -101,7 +113,7 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
101
113
|
/**
|
|
102
114
|
* Delegate for implementing your auth operations.
|
|
103
115
|
*/
|
|
104
|
-
authController: AuthController<
|
|
116
|
+
authController: AuthController<USER>;
|
|
105
117
|
/**
|
|
106
118
|
* Use this controller to access the configuration that is stored locally,
|
|
107
119
|
* and not defined in code
|
|
@@ -109,7 +121,8 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
109
121
|
userConfigPersistence?: UserConfigurationPersistence;
|
|
110
122
|
/**
|
|
111
123
|
* Use plugins to modify the behaviour of the CMS.
|
|
112
|
-
*
|
|
124
|
+
* DEPRECATED: use the `plugins` prop in the `useBuildNavigationController` instead.
|
|
125
|
+
* This prop will work as a fallback for the `plugins` prop in the `useBuildNavigationController`.
|
|
113
126
|
*/
|
|
114
127
|
plugins?: FireCMSPlugin<any, any, any>[];
|
|
115
128
|
/**
|
|
@@ -17,7 +17,7 @@ import { AnalyticsController } from "./analytics_controller";
|
|
|
17
17
|
* @group Hooks and utilities
|
|
18
18
|
* @see useFireCMSContext
|
|
19
19
|
*/
|
|
20
|
-
export type FireCMSContext<
|
|
20
|
+
export type FireCMSContext<USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>> = {
|
|
21
21
|
/**
|
|
22
22
|
* Connector to your database, e.g. your Firestore database
|
|
23
23
|
*/
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { EntityCollection } from "./collections";
|
|
3
3
|
import { EntityReference } from "./entities";
|
|
4
|
+
import { FireCMSPlugin } from "./plugins";
|
|
4
5
|
/**
|
|
5
6
|
* Controller that includes the resolved navigation and utility methods and
|
|
6
7
|
* attributes.
|
|
8
|
+
* This controller holds the state of the navigation including the collections.
|
|
7
9
|
* @group Models
|
|
8
10
|
*/
|
|
9
11
|
export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
@@ -29,7 +31,7 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
|
|
|
29
31
|
* level of the navigation (e.g. in the home page or the navigation
|
|
30
32
|
* drawer)
|
|
31
33
|
*/
|
|
32
|
-
topLevelNavigation?:
|
|
34
|
+
topLevelNavigation?: NavigationResult;
|
|
33
35
|
/**
|
|
34
36
|
* Is the navigation loading (the configuration persistence has not
|
|
35
37
|
* loaded yet, or a specified navigation builder has not completed)
|
|
@@ -48,6 +50,10 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
|
|
|
48
50
|
* The collection is resolved from the given path or alias.
|
|
49
51
|
*/
|
|
50
52
|
getCollection: (pathOrId: string, includeUserOverride?: boolean) => EC | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Get the top level collection configuration for a given id
|
|
55
|
+
*/
|
|
56
|
+
getCollectionById: (id: string) => EC | undefined;
|
|
51
57
|
/**
|
|
52
58
|
* Get the collection configuration from its parent ids.
|
|
53
59
|
*/
|
|
@@ -57,11 +63,13 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
|
|
|
57
63
|
*/
|
|
58
64
|
getCollectionFromPaths: (pathSegments: string[]) => EC | undefined;
|
|
59
65
|
/**
|
|
60
|
-
* Default path under the navigation routes of the CMS will be created
|
|
66
|
+
* Default path under the navigation routes of the CMS will be created.
|
|
67
|
+
* Defaults to '/'. You may want to change this `basepath` to 'admin' for example.
|
|
61
68
|
*/
|
|
62
69
|
basePath: string;
|
|
63
70
|
/**
|
|
64
|
-
* Default path under the collection routes of the CMS will be created
|
|
71
|
+
* Default path under the collection routes of the CMS will be created.
|
|
72
|
+
* It defaults to '/c'
|
|
65
73
|
*/
|
|
66
74
|
baseCollectionPath: string;
|
|
67
75
|
/**
|
|
@@ -72,14 +80,6 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
|
|
|
72
80
|
* @param cmsPath
|
|
73
81
|
*/
|
|
74
82
|
urlPathToDataPath: (cmsPath: string) => string;
|
|
75
|
-
/**
|
|
76
|
-
* Convert a collection or entity path to a URL path
|
|
77
|
-
* @param path
|
|
78
|
-
*/
|
|
79
|
-
buildCMSUrlPath: (path: string) => string;
|
|
80
|
-
buildUrlEditCollectionPath: (props: {
|
|
81
|
-
path: string;
|
|
82
|
-
}) => string;
|
|
83
83
|
/**
|
|
84
84
|
* Base url path for the home screen
|
|
85
85
|
*/
|
|
@@ -97,10 +97,11 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
|
|
|
97
97
|
*/
|
|
98
98
|
buildUrlCollectionPath: (path: string) => string;
|
|
99
99
|
/**
|
|
100
|
-
* Turn a path with
|
|
100
|
+
* Turn a path with collection ids into a resolved path.
|
|
101
|
+
* The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
|
|
101
102
|
* @param pathWithAliases
|
|
102
103
|
*/
|
|
103
|
-
|
|
104
|
+
resolveIdsFrom: (pathWithAliases: string) => string;
|
|
104
105
|
/**
|
|
105
106
|
* Call this method to recalculate the navigation
|
|
106
107
|
*/
|
|
@@ -120,6 +121,31 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
|
|
|
120
121
|
* @param ids
|
|
121
122
|
*/
|
|
122
123
|
convertIdsToPaths: (ids: string[]) => string[];
|
|
124
|
+
/**
|
|
125
|
+
* A function to navigate to a specified route or URL.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} to - The target route or URL to navigate to.
|
|
128
|
+
* @param {NavigateOptions} [options] - Optional configuration settings for navigation, such as replace behavior or state data.
|
|
129
|
+
*/
|
|
130
|
+
navigate: (to: string, options?: NavigateOptions) => void;
|
|
131
|
+
/**
|
|
132
|
+
* Plugin system allowing to extend the CMS functionality.
|
|
133
|
+
*/
|
|
134
|
+
plugins?: FireCMSPlugin<any, any, any>[];
|
|
135
|
+
};
|
|
136
|
+
export interface NavigateOptions {
|
|
137
|
+
replace?: boolean;
|
|
138
|
+
state?: any;
|
|
139
|
+
preventScrollReset?: boolean;
|
|
140
|
+
relative?: "route" | "path";
|
|
141
|
+
flushSync?: boolean;
|
|
142
|
+
viewTransition?: boolean;
|
|
143
|
+
}
|
|
144
|
+
export type NavigationBlocker = {
|
|
145
|
+
updateBlockListener: (path: string, block: boolean, basePath?: string) => () => void;
|
|
146
|
+
isBlocked: (path: string) => boolean;
|
|
147
|
+
proceed?: () => void;
|
|
148
|
+
reset?: () => void;
|
|
123
149
|
};
|
|
124
150
|
/**
|
|
125
151
|
* Custom additional views created by the developer, added to the main
|
|
@@ -144,8 +170,9 @@ export interface CMSView {
|
|
|
144
170
|
* You can use any of the icons in the Material specs:
|
|
145
171
|
* https://fonts.google.com/icons
|
|
146
172
|
* e.g. 'account_tree' or 'person'
|
|
173
|
+
* Find all the icons in https://firecms.co/docs/icons
|
|
147
174
|
*/
|
|
148
|
-
icon?: string;
|
|
175
|
+
icon?: string | React.ReactNode;
|
|
149
176
|
/**
|
|
150
177
|
* Should this view be hidden from the main navigation panel.
|
|
151
178
|
* It will still be accessible if you reach the specified path
|
|
@@ -163,7 +190,21 @@ export interface CMSView {
|
|
|
163
190
|
*/
|
|
164
191
|
group?: string;
|
|
165
192
|
}
|
|
166
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Used to group navigation entries in the main navigation.
|
|
195
|
+
*/
|
|
196
|
+
export interface NavigationGroupMapping {
|
|
197
|
+
/**
|
|
198
|
+
* Name of the group, used to display the group header in the UI
|
|
199
|
+
*/
|
|
200
|
+
name: string;
|
|
201
|
+
/**
|
|
202
|
+
* List of collection ids or view paths that belong to this group.
|
|
203
|
+
*/
|
|
204
|
+
entries: string[];
|
|
205
|
+
}
|
|
206
|
+
export interface NavigationEntry {
|
|
207
|
+
id: string;
|
|
167
208
|
url: string;
|
|
168
209
|
name: string;
|
|
169
210
|
path: string;
|
|
@@ -173,7 +214,9 @@ export interface TopNavigationEntry {
|
|
|
173
214
|
description?: string;
|
|
174
215
|
group: string;
|
|
175
216
|
}
|
|
176
|
-
export type
|
|
177
|
-
|
|
217
|
+
export type NavigationResult = {
|
|
218
|
+
allowDragAndDrop: boolean;
|
|
219
|
+
navigationEntries: NavigationEntry[];
|
|
178
220
|
groups: string[];
|
|
221
|
+
onNavigationEntriesUpdate: (entries: NavigationGroupMapping[]) => void;
|
|
179
222
|
};
|
|
@@ -30,7 +30,7 @@ export interface Permissions {
|
|
|
30
30
|
* Props passed to a {@link PermissionsBuilder}
|
|
31
31
|
* @group Models
|
|
32
32
|
*/
|
|
33
|
-
export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCollection,
|
|
33
|
+
export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCollection, USER extends User = User, M extends object = InferCollectionType<EC>> {
|
|
34
34
|
/**
|
|
35
35
|
* Entity being edited, might be null in some cases, when the operation
|
|
36
36
|
* refers to the collection.
|
|
@@ -49,7 +49,7 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
|
|
|
49
49
|
/**
|
|
50
50
|
* Logged in user
|
|
51
51
|
*/
|
|
52
|
-
user:
|
|
52
|
+
user: USER | null;
|
|
53
53
|
/**
|
|
54
54
|
* Collection these permissions apply to
|
|
55
55
|
*/
|
|
@@ -57,11 +57,11 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
|
|
|
57
57
|
/**
|
|
58
58
|
* Auth controller
|
|
59
59
|
*/
|
|
60
|
-
authController: AuthController<
|
|
60
|
+
authController: AuthController<USER>;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Builder used to assign permissions to entities,
|
|
64
64
|
* based on the logged user or collection.
|
|
65
65
|
* @group Models
|
|
66
66
|
*/
|
|
67
|
-
export type PermissionsBuilder<EC extends EntityCollection = EntityCollection,
|
|
67
|
+
export type PermissionsBuilder<EC extends EntityCollection = EntityCollection, USER extends User = User, M extends object = InferCollectionType<EC>> = (({ pathSegments, user, collection, authController }: PermissionsBuilderProps<EC, USER, M>) => Permissions | undefined);
|