@rebasepro/admin 0.10.0 → 0.10.1-canary.0a881d4
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/{CollectionEditorDialog-BOlKGGg7.js → CollectionEditorDialog-DMztwJ5S.js} +12 -12
- package/dist/CollectionEditorDialog-DMztwJ5S.js.map +1 -0
- package/dist/{PropertyEditView-i51tFOfM.js → PropertyEditView-CjFCnftn.js} +18 -18
- package/dist/PropertyEditView-CjFCnftn.js.map +1 -0
- package/dist/{RouterCollectionsStudioView-Dh4W53PU.js → RouterCollectionsStudioView-nDFQdKHA.js} +4 -4
- package/dist/RouterCollectionsStudioView-nDFQdKHA.js.map +1 -0
- package/dist/collection_editor/api/generateCollectionApi.d.ts +4 -4
- package/dist/collection_editor/pgColumnToProperty.d.ts +4 -3
- package/dist/collection_editor/serializable_types.d.ts +31 -30
- package/dist/collection_editor/serializable_utils.d.ts +6 -5
- package/dist/collection_editor/types/collection_editor_controller.d.ts +6 -5
- package/dist/collection_editor/types/collection_inference.d.ts +3 -2
- package/dist/collection_editor/types/config_controller.d.ts +8 -7
- package/dist/collection_editor/ui/AddKanbanColumnAction.d.ts +2 -2
- package/dist/collection_editor/ui/CollectionViewHeaderAction.d.ts +3 -2
- package/dist/collection_editor/ui/EditorCollectionAction.d.ts +1 -1
- package/dist/collection_editor/ui/EditorCollectionActionStart.d.ts +1 -1
- package/dist/collection_editor/ui/EditorEntityAction.d.ts +1 -1
- package/dist/collection_editor/ui/HomePageEditorCollectionAction.d.ts +1 -1
- package/dist/collection_editor/ui/KanbanSetupAction.d.ts +2 -2
- package/dist/collection_editor/ui/NewCollectionCard.d.ts +1 -1
- package/dist/collection_editor/ui/PropertyAddColumnComponent.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.d.ts +3 -3
- package/dist/collection_editor/ui/collection_editor/CollectionDetailsForm.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +5 -4
- package/dist/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/CollectionJsonImportDialog.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +3 -2
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/EntityActionsEditTab.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/GetCodeDialog.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +3 -2
- package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/SubcollectionsEditTab.d.ts +4 -3
- package/dist/collection_editor/ui/collection_editor/ViewModeSwitch.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/templates/blog_template.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/templates/pages_template.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/templates/products_template.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/templates/users_template.d.ts +2 -2
- package/dist/collection_editor/ui/collection_editor/utils/supported_fields.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +2 -1
- package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +2 -2
- package/dist/collection_editor/validateCollectionJson.d.ts +2 -2
- package/dist/collection_editor_ui.js +4 -4
- package/dist/components/AdminModeSyncer.d.ts +1 -1
- package/dist/components/ClearFilterSortButton.d.ts +1 -1
- package/dist/components/CollectionPanel.d.ts +2 -2
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +4 -4
- package/dist/components/CollectionTableBinding/CollectionTableBinding.d.ts +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +3 -3
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +3 -3
- package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +3 -3
- package/dist/components/CollectionTableBinding/internal/common.d.ts +2 -2
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +2 -2
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +3 -3
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +3 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +3 -3
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +3 -3
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -3
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -3
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +3 -3
- package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +2 -1
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +3 -3
- package/dist/components/CollectionViewBinding/ViewModeToggle.d.ts +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +3 -2
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +3 -2
- package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -2
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +9 -6
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +2 -1
- package/dist/components/DeleteEntityDialog.d.ts +2 -2
- package/dist/components/DetailViewBinding.d.ts +3 -3
- package/dist/components/DrawerNavigationGroup.d.ts +1 -1
- package/dist/components/EditViewBinding.d.ts +3 -3
- package/dist/components/EntityPreviewBinding.d.ts +3 -3
- package/dist/components/EntityViewBinding.d.ts +2 -2
- package/dist/components/HomePage/ContentHomePage.d.ts +1 -1
- package/dist/components/HomePage/HomePageDnD.d.ts +1 -1
- package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
- package/dist/components/PropertyConfigBadge.d.ts +1 -1
- package/dist/components/RebaseAdmin.d.ts +1 -1
- package/dist/components/RebaseLayout.d.ts +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
- package/dist/components/SelectableTable/SelectableTable.d.ts +3 -2
- package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -2
- package/dist/components/SidePanelBinding.d.ts +1 -1
- package/dist/components/admin/CreationResultDialog.d.ts +1 -1
- package/dist/components/common/default_entity_actions.d.ts +2 -1
- package/dist/components/field_configs.d.ts +3 -2
- package/dist/components/history/EntityHistoryEntry.d.ts +2 -2
- package/dist/components/history/EntityHistoryView.d.ts +1 -1
- package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
- package/dist/components/history/LastEditedByIndicator.d.ts +2 -2
- package/dist/contexts/BreacrumbsContext.d.ts +1 -1
- package/dist/contexts/SideDialogsControllerContext.d.ts +1 -1
- package/dist/contexts/SidePanelControllerContext.d.ts +1 -1
- package/dist/data_export/export/ExportCollectionAction.d.ts +4 -3
- package/dist/data_import/components/ImportSaveInProgress.d.ts +2 -2
- package/dist/data_import/import/ImportCollectionAction.d.ts +2 -1
- package/dist/data_import/utils/data.d.ts +2 -1
- package/dist/{export-BM6HPujv.js → export-CavEbZVF.js} +2 -2
- package/dist/export-CavEbZVF.js.map +1 -0
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/form_utils.d.ts +4 -3
- package/dist/{history-CtIPJxvQ.js → history-B1lIsrkX.js} +2 -2
- package/dist/history-B1lIsrkX.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +2 -2
- package/dist/hooks/navigation/contexts/NavigationStateContext.d.ts +1 -1
- package/dist/hooks/navigation/contexts/UrlContext.d.ts +1 -1
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +2 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +7 -5
- package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
- package/dist/hooks/navigation/useNavigationResolution.d.ts +6 -5
- package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -7
- package/dist/hooks/navigation/useResolvedViews.d.ts +4 -2
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +2 -2
- package/dist/hooks/navigation/utils.d.ts +5 -5
- package/dist/hooks/useBreadcrumbsController.d.ts +1 -1
- package/dist/hooks/useBuildSidePanel.d.ts +4 -4
- package/dist/hooks/useCMSContext.d.ts +4 -2
- package/dist/hooks/useResolvedNavigationFrom.d.ts +5 -4
- package/dist/hooks/useResolvedUsers.d.ts +8 -0
- package/dist/hooks/useSideDialogsController.d.ts +1 -1
- package/dist/hooks/useSidePanel.d.ts +1 -1
- package/dist/{import-DzQnT03v.js → import-36UcGe71.js} +2 -2
- package/dist/import-36UcGe71.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/preview/components/UrlComponentPreview.d.ts +1 -1
- package/dist/preview/components/UserPreview.d.ts +3 -2
- package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
- package/dist/preview/util.d.ts +1 -1
- package/dist/routes/CustomViewRoute.d.ts +1 -1
- package/dist/types/components/EntityFormActionsProps.d.ts +2 -2
- package/dist/types/components/EntityFormProps.d.ts +3 -3
- package/dist/types/fields.d.ts +2 -2
- package/dist/util/dataControllerAdapter.d.ts +1 -1
- package/dist/util/entity_actions.d.ts +1 -1
- package/dist/util/navigation_utils.d.ts +3 -3
- package/dist/util/previews.d.ts +22 -4
- package/dist/util/property_utils.d.ts +3 -2
- package/dist/util/resolutions.d.ts +1 -1
- package/dist/util/view_mode.d.ts +3 -3
- package/dist/{util-XFwQ9FEc.js → util-CPgUM4M8.js} +353 -221
- package/dist/util-CPgUM4M8.js.map +1 -0
- package/package.json +11 -9
- package/src/collection_editor/ConfigControllerProvider.tsx +11 -12
- package/src/collection_editor/api/generateCollectionApi.ts +4 -4
- package/src/collection_editor/pgColumnToProperty.ts +4 -3
- package/src/collection_editor/serializable_types.ts +36 -34
- package/src/collection_editor/serializable_utils.ts +17 -32
- package/src/collection_editor/types/collection_editor_controller.tsx +6 -5
- package/src/collection_editor/types/collection_inference.ts +3 -2
- package/src/collection_editor/types/config_controller.tsx +8 -7
- package/src/collection_editor/ui/AddKanbanColumnAction.tsx +3 -2
- package/src/collection_editor/ui/CollectionViewHeaderAction.tsx +3 -2
- package/src/collection_editor/ui/EditorCollectionAction.tsx +3 -2
- package/src/collection_editor/ui/EditorCollectionActionStart.tsx +3 -2
- package/src/collection_editor/ui/EditorEntityAction.tsx +3 -2
- package/src/collection_editor/ui/HomePageEditorCollectionAction.tsx +1 -1
- package/src/collection_editor/ui/KanbanSetupAction.tsx +3 -2
- package/src/collection_editor/ui/MissingReferenceWidget.tsx +1 -1
- package/src/collection_editor/ui/NewCollectionCard.tsx +1 -1
- package/src/collection_editor/ui/PropertyAddColumnComponent.tsx +3 -2
- package/src/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.tsx +6 -5
- package/src/collection_editor/ui/collection_editor/CollectionDetailsForm.tsx +5 -7
- package/src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx +28 -38
- package/src/collection_editor/ui/collection_editor/CollectionEditorWelcomeView.tsx +4 -3
- package/src/collection_editor/ui/collection_editor/CollectionJsonImportDialog.tsx +3 -2
- package/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.tsx +4 -3
- package/src/collection_editor/ui/collection_editor/CollectionRLSTab.tsx +4 -3
- package/src/collection_editor/ui/collection_editor/CollectionRelationsTab.tsx +3 -2
- package/src/collection_editor/ui/collection_editor/CollectionStudioView.tsx +2 -2
- package/src/collection_editor/ui/collection_editor/CollectionsStudioView.tsx +3 -2
- package/src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx +4 -3
- package/src/collection_editor/ui/collection_editor/EntityActionsEditTab.tsx +4 -4
- package/src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx +4 -4
- package/src/collection_editor/ui/collection_editor/GetCodeDialog.tsx +5 -4
- package/src/collection_editor/ui/collection_editor/KanbanConfigSection.tsx +3 -2
- package/src/collection_editor/ui/collection_editor/PropertyEditView.tsx +4 -3
- package/src/collection_editor/ui/collection_editor/PropertyTree.tsx +2 -1
- package/src/collection_editor/ui/collection_editor/SubcollectionsEditTab.tsx +6 -5
- package/src/collection_editor/ui/collection_editor/ViewModeSwitch.tsx +1 -1
- package/src/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.tsx +3 -2
- package/src/collection_editor/ui/collection_editor/properties/BlockPropertyField.tsx +2 -1
- package/src/collection_editor/ui/collection_editor/properties/MapPropertyField.tsx +3 -2
- package/src/collection_editor/ui/collection_editor/properties/RelationPropertyField.tsx +3 -2
- package/src/collection_editor/ui/collection_editor/properties/RepeatPropertyField.tsx +2 -1
- package/src/collection_editor/ui/collection_editor/templates/blog_template.ts +3 -3
- package/src/collection_editor/ui/collection_editor/templates/pages_template.ts +3 -3
- package/src/collection_editor/ui/collection_editor/templates/products_template.ts +4 -4
- package/src/collection_editor/ui/collection_editor/templates/users_template.ts +2 -2
- package/src/collection_editor/ui/collection_editor/utils/supported_fields.tsx +1 -1
- package/src/collection_editor/ui/collection_editor/utils/update_property_for_widget.ts +10 -8
- package/src/collection_editor/useJsonCollectionsConfigController.tsx +10 -9
- package/src/collection_editor/useLocalCollectionsConfigController.tsx +5 -5
- package/src/collection_editor/validateCollectionJson.ts +4 -5
- package/src/components/AdminModeSyncer.tsx +1 -1
- package/src/components/ClearFilterSortButton.tsx +1 -1
- package/src/components/CollectionPanel.tsx +5 -4
- package/src/components/CollectionTableBinding/CollectionRowActions.tsx +6 -6
- package/src/components/CollectionTableBinding/CollectionTableBinding.tsx +5 -4
- package/src/components/CollectionTableBinding/CollectionTableBindingProps.tsx +3 -2
- package/src/components/CollectionTableBinding/PropertyTableCell.tsx +5 -5
- package/src/components/CollectionTableBinding/fields/TableMultipleRelationField.tsx +4 -3
- package/src/components/CollectionTableBinding/fields/TableReferenceField.tsx +5 -4
- package/src/components/CollectionTableBinding/fields/TableRelationField.tsx +4 -3
- package/src/components/CollectionTableBinding/internal/common.tsx +8 -7
- package/src/components/CollectionTableBinding/internal/popup_field/PopupFormField.tsx +5 -4
- package/src/components/CollectionTableBinding/table_bindings.tsx +7 -7
- package/src/components/CollectionViewBinding/BoardCardBinding.tsx +6 -5
- package/src/components/CollectionViewBinding/CollectionBoardViewBinding.tsx +5 -6
- package/src/components/CollectionViewBinding/CollectionCardViewBinding.tsx +4 -3
- package/src/components/CollectionViewBinding/CollectionListViewBinding.tsx +10 -13
- package/src/components/CollectionViewBinding/CollectionViewActions.tsx +3 -3
- package/src/components/CollectionViewBinding/CollectionViewBinding.tsx +17 -16
- package/src/components/CollectionViewBinding/CollectionViewStartActions.tsx +3 -3
- package/src/components/CollectionViewBinding/EntityCardBinding.tsx +6 -5
- package/src/components/CollectionViewBinding/FilterPresetsButton.tsx +2 -1
- package/src/components/CollectionViewBinding/FiltersDialog.tsx +2 -2
- package/src/components/CollectionViewBinding/SplitListView.tsx +6 -5
- package/src/components/CollectionViewBinding/ViewModeToggle.tsx +1 -1
- package/src/components/CollectionViewBinding/hooks/useCollectionInlineEditor.ts +3 -2
- package/src/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.ts +3 -2
- package/src/components/CollectionViewBinding/useBoardDataController.tsx +3 -2
- package/src/components/CollectionViewBinding/usePreviewSlots.ts +57 -25
- package/src/components/CollectionViewBinding/useSelectionController.tsx +2 -1
- package/src/components/DefaultDrawer.tsx +2 -2
- package/src/components/DeleteEntityDialog.tsx +3 -2
- package/src/components/DetailViewBinding.tsx +23 -18
- package/src/components/DrawerNavigationGroup.tsx +1 -1
- package/src/components/EditFormActions.tsx +5 -5
- package/src/components/EditViewBinding.tsx +11 -15
- package/src/components/EntityPreviewBinding.tsx +7 -6
- package/src/components/EntityViewBinding.tsx +3 -3
- package/src/components/HomePage/ContentHomePage.tsx +2 -2
- package/src/components/HomePage/FavouritesView.tsx +1 -1
- package/src/components/HomePage/HomePageDnD.tsx +1 -1
- package/src/components/HomePage/NavigationCardBinding.tsx +2 -2
- package/src/components/PropertyConfigBadge.tsx +2 -1
- package/src/components/RebaseAdmin.tsx +1 -1
- package/src/components/RebaseAuthGate.tsx +1 -1
- package/src/components/RebaseLayout.tsx +1 -1
- package/src/components/RebaseNavigation.tsx +4 -3
- package/src/components/ReferenceTable/SelectionTableBinding.tsx +6 -5
- package/src/components/ReferenceWidget.tsx +3 -2
- package/src/components/SelectableTable/SelectableTable.tsx +3 -3
- package/src/components/SelectableTable/SelectionStore.ts +1 -1
- package/src/components/SelectableTable/filters/FilterFieldBinding.tsx +9 -6
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +3 -2
- package/src/components/SideDialogs.tsx +2 -2
- package/src/components/SidePanelBinding.tsx +5 -5
- package/src/components/SidePanelProvider.tsx +1 -1
- package/src/components/admin/CreationResultDialog.tsx +1 -1
- package/src/components/common/default_entity_actions.tsx +3 -2
- package/src/components/field_configs.tsx +30 -29
- package/src/components/history/EntityHistoryEntry.tsx +3 -2
- package/src/components/history/EntityHistoryView.tsx +1 -1
- package/src/components/history/LastEditedByFormAction.tsx +1 -1
- package/src/components/history/LastEditedByIndicator.tsx +3 -2
- package/src/contexts/BreacrumbsContext.tsx +1 -1
- package/src/contexts/SideDialogsControllerContext.tsx +1 -1
- package/src/contexts/SidePanelControllerContext.tsx +1 -1
- package/src/data_export/export/ExportCollectionAction.tsx +5 -4
- package/src/data_import/components/ImportSaveInProgress.tsx +4 -3
- package/src/data_import/import/ImportCollectionAction.tsx +3 -2
- package/src/data_import/utils/data.ts +3 -2
- package/src/form/EntityForm.tsx +19 -10
- package/src/form/EntityFormActions.tsx +3 -3
- package/src/form/EntityFormBinding.tsx +6 -4
- package/src/form/PropertyFieldBinding.tsx +15 -12
- package/src/form/components/FieldHelperText.tsx +1 -1
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +5 -4
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +7 -6
- package/src/form/field_bindings/BlockFieldBinding.tsx +4 -4
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
- package/src/form/field_bindings/MapFieldBinding.tsx +7 -7
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +1 -1
- package/src/form/field_bindings/MultipleRelationFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +4 -3
- package/src/form/field_bindings/RelationFieldBinding.tsx +2 -2
- package/src/form/field_bindings/RepeatFieldBinding.tsx +5 -5
- package/src/form/field_bindings/SelectFieldBinding.tsx +1 -1
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +2 -2
- package/src/form/field_bindings/SwitchFieldBinding.tsx +1 -1
- package/src/form/field_bindings/TextFieldBinding.tsx +8 -8
- package/src/form/field_bindings/UserSelectFieldBinding.tsx +1 -1
- package/src/form/form_utils.ts +5 -3
- package/src/form/useClearRestoreValue.tsx +1 -1
- package/src/form/validation.ts +1 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/navigation/contexts/CollectionRegistryContext.tsx +3 -2
- package/src/hooks/navigation/contexts/NavigationStateContext.tsx +1 -1
- package/src/hooks/navigation/contexts/UrlContext.tsx +1 -1
- package/src/hooks/navigation/useBuildCollectionRegistryController.tsx +19 -15
- package/src/hooks/navigation/useBuildNavigationStateController.tsx +8 -6
- package/src/hooks/navigation/useBuildUrlController.tsx +2 -2
- package/src/hooks/navigation/useNavigationResolution.ts +15 -21
- package/src/hooks/navigation/useResolvedCollections.ts +10 -9
- package/src/hooks/navigation/useResolvedViews.tsx +4 -2
- package/src/hooks/navigation/useTopLevelNavigation.ts +3 -2
- package/src/hooks/navigation/utils.ts +6 -5
- package/src/hooks/useBreadcrumbsController.tsx +1 -1
- package/src/hooks/useBuildSidePanel.tsx +9 -12
- package/src/hooks/useCMSContext.tsx +8 -4
- package/src/hooks/useResolvedNavigationFrom.tsx +7 -5
- package/src/hooks/useResolvedUsers.ts +143 -0
- package/src/hooks/useSelectionDialog.tsx +3 -2
- package/src/hooks/useSideDialogsController.tsx +1 -1
- package/src/hooks/useSidePanel.tsx +1 -1
- package/src/index.ts +2 -1
- package/src/preview/PropertyPreview.tsx +11 -11
- package/src/preview/components/ReferencePreview.tsx +6 -5
- package/src/preview/components/RelationPreview.tsx +6 -5
- package/src/preview/components/UrlComponentPreview.tsx +1 -1
- package/src/preview/components/UserPreview.tsx +13 -4
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfRelationsPreview.tsx +1 -1
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
- package/src/preview/property_previews/StringPropertyPreview.tsx +19 -13
- package/src/preview/util.ts +1 -1
- package/src/routes/CustomViewRoute.tsx +1 -1
- package/src/routes/RebaseRoute.tsx +7 -5
- package/src/types/components/EntityFormActionsProps.tsx +3 -2
- package/src/types/components/EntityFormProps.tsx +4 -3
- package/src/types/fields.tsx +3 -2
- package/src/util/dataControllerAdapter.ts +2 -1
- package/src/util/entity_actions.ts +1 -1
- package/src/util/navigation_utils.ts +4 -13
- package/src/util/previews.ts +43 -53
- package/src/util/propertyConfigMapper.ts +7 -7
- package/src/util/property_utils.tsx +5 -4
- package/src/util/resolutions.ts +1 -1
- package/src/util/view_mode.ts +4 -3
- package/dist/CollectionEditorDialog-BOlKGGg7.js.map +0 -1
- package/dist/PropertyEditView-i51tFOfM.js.map +0 -1
- package/dist/RouterCollectionsStudioView-Dh4W53PU.js.map +0 -1
- package/dist/export-BM6HPujv.js.map +0 -1
- package/dist/history-CtIPJxvQ.js.map +0 -1
- package/dist/import-DzQnT03v.js.map +0 -1
- package/dist/util-XFwQ9FEc.js.map +0 -1
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import type { AppView, NavigationResult, RebasePlugin, NavigationStateController, UrlController, NavigationGroupMapping, AdminCollection } from "@rebasepro/admin-types";
|
|
2
3
|
import { useCallback, useMemo, useRef } from "react";
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
5
|
+
import { RebaseData, CollectionRegistryController, User } from "@rebasepro/types";
|
|
6
|
+
import { AuthController } from "@rebasepro/admin-types";
|
|
7
|
+
import type { EffectiveRoleController } from "@rebasepro/types";
|
|
8
|
+
import type { CollectionConfigsBuilder, AppViewsBuilder } from "@rebasepro/admin-types";
|
|
6
9
|
import { CollectionRegistry } from "@rebasepro/common";
|
|
7
10
|
|
|
8
|
-
|
|
9
11
|
import { useResolvedCollections } from "./useResolvedCollections";
|
|
10
12
|
import { useResolvedViews } from "./useResolvedViews";
|
|
11
13
|
import { useTopLevelNavigation } from "./useTopLevelNavigation";
|
|
12
14
|
|
|
13
|
-
export type BuildNavigationStateProps<EC extends
|
|
15
|
+
export type BuildNavigationStateProps<EC extends AdminCollection, USER extends User> = {
|
|
14
16
|
authController: AuthController<USER>;
|
|
15
17
|
collections?: EC[] | CollectionConfigsBuilder<EC>;
|
|
16
18
|
views?: AppView[] | AppViewsBuilder;
|
|
@@ -37,7 +39,7 @@ export type BuildNavigationStateProps<EC extends CollectionConfig, USER extends
|
|
|
37
39
|
*
|
|
38
40
|
* The NavigationStateController type is preserved as a public API.
|
|
39
41
|
*/
|
|
40
|
-
export function useBuildNavigationStateController<EC extends
|
|
42
|
+
export function useBuildNavigationStateController<EC extends AdminCollection, USER extends User>(
|
|
41
43
|
props: BuildNavigationStateProps<EC, USER>
|
|
42
44
|
): NavigationStateController {
|
|
43
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { UrlController, NavigateOptions } from "@rebasepro/types";
|
|
1
|
+
import type { UrlController, NavigateOptions } from "@rebasepro/admin-types";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
|
-
import { removeInitialAndTrailingSlashes, resolveCollectionPathIds } from "@rebasepro/
|
|
3
|
+
import { removeInitialAndTrailingSlashes, resolveCollectionPathIds } from "@rebasepro/app";
|
|
4
4
|
import { CollectionRegistryController } from "@rebasepro/types";
|
|
5
5
|
import { useNavigate } from "react-router-dom";
|
|
6
6
|
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
EntityAction,
|
|
6
|
-
CollectionConfig,
|
|
7
|
-
CollectionConfigsBuilder,
|
|
8
|
-
RebaseContext,
|
|
9
|
-
RebasePlugin,
|
|
10
|
-
UserCreationResult
|
|
11
|
-
} from "@rebasepro/types";
|
|
12
|
-
import { type AuthController, type User, type RebaseData } from "@rebasepro/types";
|
|
1
|
+
import type { AuthCollectionConfig } from "@rebasepro/types";
|
|
2
|
+
import type { AppView, AppViewsBuilder, EntityAction, CollectionConfigsBuilder, RebaseContext, RebasePlugin, UserCreationResult, AdminCollection } from "@rebasepro/admin-types";
|
|
3
|
+
import { type User, type RebaseData } from "@rebasepro/types";
|
|
4
|
+
import { type AuthController } from "@rebasepro/admin-types";
|
|
13
5
|
import { canReadCollection } from "@rebasepro/common";
|
|
14
6
|
import { resetPasswordAction } from "../../components/common/default_entity_actions";
|
|
15
7
|
import { CreationResultDialog } from "../../components/admin/CreationResultDialog";
|
|
@@ -23,7 +15,7 @@ function isRebaseContext(ctx: unknown): ctx is RebaseContext {
|
|
|
23
15
|
return typeof ctx === "object" && ctx !== null && "dialogsController" in ctx;
|
|
24
16
|
}
|
|
25
17
|
|
|
26
|
-
export function filterOutNotAllowedCollections(resolvedCollections:
|
|
18
|
+
export function filterOutNotAllowedCollections(resolvedCollections: AdminCollection[], authController: AuthController): AdminCollection[] {
|
|
27
19
|
return resolvedCollections
|
|
28
20
|
.filter((c) => canReadCollection(c, authController))
|
|
29
21
|
.map((c) => {
|
|
@@ -35,8 +27,8 @@ export function filterOutNotAllowedCollections(resolvedCollections: CollectionCo
|
|
|
35
27
|
});
|
|
36
28
|
}
|
|
37
29
|
|
|
38
|
-
export function applyPluginModifyCollection(resolvedCollections:
|
|
39
|
-
return resolvedCollections.map((collection):
|
|
30
|
+
export function applyPluginModifyCollection(resolvedCollections: AdminCollection[], modifyCollection: (collection: AdminCollection) => AdminCollection): AdminCollection[] {
|
|
31
|
+
return resolvedCollections.map((collection): AdminCollection => {
|
|
40
32
|
const modifiedCollection = modifyCollection(collection);
|
|
41
33
|
if (modifiedCollection.childCollections) {
|
|
42
34
|
return {
|
|
@@ -64,9 +56,9 @@ export function applyPluginModifyCollection(resolvedCollections: CollectionConfi
|
|
|
64
56
|
* Skips injection if the collection already has the action/callback present.
|
|
65
57
|
*/
|
|
66
58
|
function injectAuthCollectionConfig(
|
|
67
|
-
collections:
|
|
59
|
+
collections: AdminCollection[],
|
|
68
60
|
adminPasswordResetSupported: boolean
|
|
69
|
-
):
|
|
61
|
+
): AdminCollection[] {
|
|
70
62
|
return collections.map((collection) => {
|
|
71
63
|
const authProp = collection.auth;
|
|
72
64
|
if (!authProp) return collection;
|
|
@@ -87,7 +79,9 @@ function injectAuthCollectionConfig(
|
|
|
87
79
|
} else if (typeof resetPref === "object") {
|
|
88
80
|
// An explicitly supplied action is the collection author's own; they
|
|
89
81
|
// own its backend, so the adapter capability doesn't apply.
|
|
90
|
-
|
|
82
|
+
// `auth.actions.resetPassword`'s object form is an EntityAction; core
|
|
83
|
+
// types it as `object` because a server never renders one.
|
|
84
|
+
actionToInject = resetPref as EntityAction;
|
|
91
85
|
} else if (!adminPasswordResetSupported) {
|
|
92
86
|
actionToInject = undefined;
|
|
93
87
|
} else {
|
|
@@ -162,12 +156,12 @@ function injectAuthCollectionConfig(
|
|
|
162
156
|
}
|
|
163
157
|
|
|
164
158
|
export async function resolveCollections(
|
|
165
|
-
collections: undefined |
|
|
159
|
+
collections: undefined | AdminCollection[] | CollectionConfigsBuilder,
|
|
166
160
|
authController: AuthController,
|
|
167
161
|
data: RebaseData,
|
|
168
162
|
plugins: RebasePlugin[] | undefined
|
|
169
|
-
): Promise<
|
|
170
|
-
let resolvedCollections:
|
|
163
|
+
): Promise<AdminCollection[]> {
|
|
164
|
+
let resolvedCollections: AdminCollection[] = [];
|
|
171
165
|
if (typeof collections === "function") {
|
|
172
166
|
resolvedCollections = await collections({
|
|
173
167
|
user: authController.user,
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import type { RebasePlugin, AdminCollection } from "@rebasepro/admin-types";
|
|
2
3
|
import { useRef, useMemo } from "react";
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
5
|
+
import { CollectionRegistryController, RebaseData, User } from "@rebasepro/types";
|
|
6
|
+
import { AuthController } from "@rebasepro/admin-types";
|
|
7
|
+
import type { CollectionConfigsBuilder } from "@rebasepro/admin-types";
|
|
6
8
|
import { CollectionRegistry } from "@rebasepro/common";
|
|
7
9
|
|
|
8
|
-
|
|
9
10
|
import { resolveCollections } from "./useNavigationResolution";
|
|
10
11
|
import { areCollectionListsEqual } from "./utils";
|
|
11
12
|
import { useAsyncResolver } from "./useAsyncResolver";
|
|
12
13
|
|
|
13
|
-
export type UseResolvedCollectionsProps<EC extends
|
|
14
|
+
export type UseResolvedCollectionsProps<EC extends AdminCollection, USER extends User> = {
|
|
14
15
|
authController: AuthController<USER>;
|
|
15
16
|
collections?: EC[] | CollectionConfigsBuilder<EC>;
|
|
16
17
|
data: RebaseData;
|
|
@@ -21,7 +22,7 @@ export type UseResolvedCollectionsProps<EC extends CollectionConfig, USER extend
|
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
export type UseResolvedCollectionsResult = {
|
|
24
|
-
collections:
|
|
25
|
+
collections: AdminCollection[];
|
|
25
26
|
loading: boolean;
|
|
26
27
|
error: Error | undefined;
|
|
27
28
|
refresh: () => void;
|
|
@@ -29,7 +30,7 @@ export type UseResolvedCollectionsResult = {
|
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Hook that resolves collection props (which may be async builders or arrays)
|
|
32
|
-
* into concrete
|
|
33
|
+
* into concrete AdminCollection[], and registers them with the CollectionRegistry.
|
|
33
34
|
*
|
|
34
35
|
* When userManagement is provided, the default users collection is always
|
|
35
36
|
* prepended. Developer collections override via generic slug-based dedup
|
|
@@ -38,7 +39,7 @@ export type UseResolvedCollectionsResult = {
|
|
|
38
39
|
* Uses refs for potentially-unstable dependencies (driver, authController,
|
|
39
40
|
* plugins) to avoid re-triggering effects when their object identity changes.
|
|
40
41
|
*/
|
|
41
|
-
export function useResolvedCollections<EC extends
|
|
42
|
+
export function useResolvedCollections<EC extends AdminCollection, USER extends User>(
|
|
42
43
|
props: UseResolvedCollectionsProps<EC, USER>
|
|
43
44
|
): UseResolvedCollectionsResult {
|
|
44
45
|
|
|
@@ -66,7 +67,7 @@ export function useResolvedCollections<EC extends CollectionConfig, USER extends
|
|
|
66
67
|
const pluginsRef = useRef(plugins);
|
|
67
68
|
pluginsRef.current = plugins;
|
|
68
69
|
|
|
69
|
-
const { data: collections, loading, error, refresh } = useAsyncResolver<
|
|
70
|
+
const { data: collections, loading, error, refresh } = useAsyncResolver<AdminCollection[]>({
|
|
70
71
|
resolver: async () => {
|
|
71
72
|
const resolved = await resolveCollections(
|
|
72
73
|
collectionsProp,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import type {
|
|
2
|
+
import type { EffectiveRoleController } from "@rebasepro/types";
|
|
3
|
+
import type { AppView, AppViewsBuilder, RebasePlugin } from "@rebasepro/admin-types";
|
|
3
4
|
import { useMemo, useRef } from "react";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -17,7 +18,8 @@ function viewSlugsEqual(a: AppView[] | undefined, b: AppView[] | undefined): boo
|
|
|
17
18
|
return true;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
import type {
|
|
21
|
+
import type { RebaseData, User } from "@rebasepro/types";
|
|
22
|
+
import type { AuthController } from "@rebasepro/admin-types";
|
|
21
23
|
|
|
22
24
|
import { resolveAppViews } from "./useNavigationResolution";
|
|
23
25
|
import { useAsyncResolver } from "./useAsyncResolver";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import type { AppView, UrlController, RebasePlugin, NavigationEntry, NavigationGroupMapping, NavigationResult, AdminCollection } from "@rebasepro/admin-types";
|
|
2
3
|
import { useCallback, useMemo, useRef } from "react";
|
|
3
4
|
import { deepEqual as equal } from "fast-equals";
|
|
4
5
|
|
|
@@ -8,7 +9,7 @@ import { CollectionRegistry } from "@rebasepro/common";
|
|
|
8
9
|
import { computeNavigationGroups, getGroup, NAVIGATION_ADMIN_GROUP_NAME, NAVIGATION_DEFAULT_GROUP_NAME } from "./utils";
|
|
9
10
|
|
|
10
11
|
export type UseTopLevelNavigationProps = {
|
|
11
|
-
collections:
|
|
12
|
+
collections: AdminCollection[];
|
|
12
13
|
views: AppView[] | undefined;
|
|
13
14
|
adminViews: AppView[] | undefined;
|
|
14
15
|
plugins?: RebasePlugin[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import type { AppView, RebasePlugin, NavigationGroupMapping, AdminCollection } from "@rebasepro/admin-types";
|
|
2
3
|
|
|
3
4
|
import { getSubcollections } from "@rebasepro/common";
|
|
4
5
|
import { deepEqual as equal } from "fast-equals";
|
|
@@ -6,7 +7,7 @@ import { deepEqual as equal } from "fast-equals";
|
|
|
6
7
|
export const NAVIGATION_DEFAULT_GROUP_NAME = "Views";
|
|
7
8
|
export const NAVIGATION_ADMIN_GROUP_NAME = "Admin";
|
|
8
9
|
|
|
9
|
-
export function getGroup(collectionOrView:
|
|
10
|
+
export function getGroup(collectionOrView: AdminCollection | AppView) {
|
|
10
11
|
const trimmed = collectionOrView.group?.trim();
|
|
11
12
|
if (!trimmed || trimmed === "") {
|
|
12
13
|
return NAVIGATION_DEFAULT_GROUP_NAME;
|
|
@@ -21,7 +22,7 @@ export function computeNavigationGroups({
|
|
|
21
22
|
plugins
|
|
22
23
|
}: {
|
|
23
24
|
navigationGroupMappings?: NavigationGroupMapping[],
|
|
24
|
-
collections?:
|
|
25
|
+
collections?: AdminCollection[],
|
|
25
26
|
views?: AppView[],
|
|
26
27
|
plugins?: RebasePlugin[]
|
|
27
28
|
}): NavigationGroupMapping[] {
|
|
@@ -146,7 +147,7 @@ export function computeNavigationGroups({
|
|
|
146
147
|
return result;
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
export function areCollectionListsEqual(a:
|
|
150
|
+
export function areCollectionListsEqual(a: AdminCollection[], b: AdminCollection[], visitedSlugs: string[] = []) {
|
|
150
151
|
if (a.length !== b.length) {
|
|
151
152
|
return false;
|
|
152
153
|
}
|
|
@@ -157,7 +158,7 @@ export function areCollectionListsEqual(a: CollectionConfig[], b: CollectionConf
|
|
|
157
158
|
return aSorted.every((value, index) => areCollectionsEqual(value, bSorted[index], visitedSlugs));
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
export function areCollectionsEqual(a:
|
|
161
|
+
export function areCollectionsEqual(a: AdminCollection, b: AdminCollection, visitedSlugs: string[] = []) {
|
|
161
162
|
if (a.slug !== b.slug) {
|
|
162
163
|
return false;
|
|
163
164
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
import { BreadcrumbContext } from "../contexts/BreacrumbsContext";
|
|
3
|
-
import { BreadcrumbEntry, BreadcrumbsController } from "@rebasepro/types";
|
|
3
|
+
import { BreadcrumbEntry, BreadcrumbsController } from "@rebasepro/admin-types";
|
|
4
4
|
|
|
5
5
|
export type { BreadcrumbEntry, BreadcrumbsController };
|
|
6
6
|
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
1
|
+
|
|
2
|
+
import type { Property } from "@rebasepro/types";
|
|
3
|
+
import type { CustomizationController, SidePanelBindingProps, SideDialogPanelProps, SideDialogsController, SidePanelController, UrlController, NavigationStateController, AdminCollection } from "@rebasepro/admin-types";
|
|
3
4
|
import { useCallback, useEffect, useRef, useMemo } from "react";
|
|
4
|
-
import {
|
|
5
|
+
import { CollectionRegistryController } from "@rebasepro/types";
|
|
6
|
+
import { AuthController } from "@rebasepro/admin-types";
|
|
5
7
|
import { useLocation } from "react-router-dom";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
NavigationViewInternal,
|
|
9
|
-
removeInitialAndTrailingSlashes,
|
|
10
|
-
removeTrailingSlash,
|
|
11
|
-
resolveDefaultSelectedView
|
|
12
|
-
} from "@rebasepro/common";
|
|
8
|
+
import { NavigationViewInternal } from "@rebasepro/app";
|
|
9
|
+
import { getNavigationEntriesFromPath, removeInitialAndTrailingSlashes, removeTrailingSlash, resolveDefaultSelectedView } from "@rebasepro/app";
|
|
13
10
|
import { resolvedSelectedEntityView } from "../util/resolutions";
|
|
14
11
|
import { ADDITIONAL_TAB_WIDTH, CONTAINER_FULL_WIDTH, FORM_CONTAINER_WIDTH } from "@rebasepro/app";
|
|
15
12
|
import { useCustomizationController, useLargeLayout, useComponentOverride, CollectionScopeProvider } from "@rebasepro/app";
|
|
@@ -73,7 +70,7 @@ export function getEntityViewWidth(props: SidePanelBindingProps<any>, small: boo
|
|
|
73
70
|
|
|
74
71
|
const collectionViewWidthCache: { [key: string]: string } = {};
|
|
75
72
|
|
|
76
|
-
function calculateCollectionDesiredWidth(collection:
|
|
73
|
+
function calculateCollectionDesiredWidth(collection: AdminCollection<any>): string {
|
|
77
74
|
if (collectionViewWidthCache[collection.slug]) {
|
|
78
75
|
return collectionViewWidthCache[collection.slug];
|
|
79
76
|
}
|
|
@@ -240,7 +237,7 @@ width: newWidth };
|
|
|
240
237
|
}), [close, open, replace]);
|
|
241
238
|
};
|
|
242
239
|
|
|
243
|
-
export function buildSidePanelsFromUrl(path: string, collections:
|
|
240
|
+
export function buildSidePanelsFromUrl(path: string, collections: AdminCollection[], newFlag: boolean): SidePanelBindingProps<any>[] {
|
|
244
241
|
|
|
245
242
|
const navigationViewsForPath: NavigationViewInternal<any>[] = getNavigationEntriesFromPath({
|
|
246
243
|
path,
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useRebaseContext } from "@rebasepro/app";
|
|
3
|
+
import type {
|
|
4
|
+
User
|
|
5
|
+
} from "@rebasepro/types";
|
|
3
6
|
import type {
|
|
4
7
|
AuthController,
|
|
5
8
|
RebaseContext,
|
|
6
9
|
SideDialogsController,
|
|
7
|
-
SidePanelController
|
|
8
|
-
|
|
10
|
+
SidePanelController
|
|
11
|
+
} from "@rebasepro/admin-types";
|
|
12
|
+
import type {
|
|
13
|
+
CollectionRegistryController
|
|
9
14
|
} from "@rebasepro/types";
|
|
10
15
|
import type {
|
|
11
|
-
CollectionRegistryController,
|
|
12
16
|
NavigationStateController,
|
|
13
17
|
UrlController
|
|
14
|
-
} from "@rebasepro/types";
|
|
18
|
+
} from "@rebasepro/admin-types";
|
|
15
19
|
import { useSidePanel } from "./useSidePanel";
|
|
16
20
|
import { useSideDialogsController } from "./useSideDialogsController";
|
|
17
21
|
import {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
|
|
2
|
+
import type { EntityCustomView, AdminCollection } from "@rebasepro/admin-types";
|
|
3
|
+
import { Entity, User } from "@rebasepro/types";
|
|
4
|
+
import { RebaseContext } from "@rebasepro/admin-types";
|
|
3
5
|
import { useEffect, useState, useMemo } from "react";
|
|
4
|
-
import { getNavigationEntriesFromPath } from "@rebasepro/
|
|
6
|
+
import { getNavigationEntriesFromPath } from "@rebasepro/app";
|
|
5
7
|
import { useCMSContext } from "./useCMSContext";
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -22,7 +24,7 @@ export interface ResolvedNavigationEntity<M extends Record<string, unknown>> {
|
|
|
22
24
|
entity: Entity<M>;
|
|
23
25
|
entityId: string | number;
|
|
24
26
|
path: string;
|
|
25
|
-
parentCollection:
|
|
27
|
+
parentCollection: AdminCollection<M>;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -32,7 +34,7 @@ export interface ResolvedNavigationEntity<M extends Record<string, unknown>> {
|
|
|
32
34
|
export interface ResolvedNavigationCollection<M extends Record<string, unknown>> {
|
|
33
35
|
type: "collection";
|
|
34
36
|
path: string;
|
|
35
|
-
collection:
|
|
37
|
+
collection: AdminCollection<M>;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import type { User } from "@rebasepro/types";
|
|
3
|
+
import { useAuthController, useRebaseClient } from "@rebasepro/app";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the auth users behind `userSelect` values.
|
|
7
|
+
*
|
|
8
|
+
* A collection view can ask for dozens of ids at once — one per row — so
|
|
9
|
+
* lookups are coalesced into a single `GET /api/users?ids=…` per tick and
|
|
10
|
+
* cached per base URL. Ids that resolve to nothing are remembered too, so a
|
|
11
|
+
* dangling reference is not retried on every render.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface UserCache {
|
|
15
|
+
users: Map<string, User | null>;
|
|
16
|
+
pending: Map<string, Promise<void>>;
|
|
17
|
+
queue: Set<string>;
|
|
18
|
+
flush?: ReturnType<typeof setTimeout>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const caches = new Map<string, UserCache>();
|
|
22
|
+
|
|
23
|
+
function getCache(baseUrl: string): UserCache {
|
|
24
|
+
let cache = caches.get(baseUrl);
|
|
25
|
+
if (!cache) {
|
|
26
|
+
cache = { users: new Map(),
|
|
27
|
+
pending: new Map(),
|
|
28
|
+
queue: new Set() };
|
|
29
|
+
caches.set(baseUrl, cache);
|
|
30
|
+
}
|
|
31
|
+
return cache;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function fetchUsers(baseUrl: string, ids: string[], token: string | undefined): Promise<Map<string, User | null>> {
|
|
35
|
+
const resolved = new Map<string, User | null>();
|
|
36
|
+
for (const id of ids) resolved.set(id, null);
|
|
37
|
+
|
|
38
|
+
const params = new URLSearchParams({ ids: ids.join(",") });
|
|
39
|
+
const response = await fetch(`${baseUrl}/api/users?${params}`, {
|
|
40
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {}
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
// A non-admin viewer gets a 403 here. Treat it as "unresolvable" rather
|
|
44
|
+
// than an error: callers fall back to showing the raw value.
|
|
45
|
+
return resolved;
|
|
46
|
+
}
|
|
47
|
+
const data = await response.json();
|
|
48
|
+
const rows: Record<string, unknown>[] = data.users ?? data.data ?? [];
|
|
49
|
+
for (const row of rows) {
|
|
50
|
+
const uid = (row.uid as string) ?? (row.id as string);
|
|
51
|
+
if (!uid) continue;
|
|
52
|
+
resolved.set(uid, {
|
|
53
|
+
uid,
|
|
54
|
+
email: (row.email as string) ?? "",
|
|
55
|
+
displayName: (row.displayName as string) ?? (row.display_name as string) ?? null,
|
|
56
|
+
photoURL: (row.photoURL as string) ?? (row.photo_url as string) ?? null,
|
|
57
|
+
providerId: "custom",
|
|
58
|
+
isAnonymous: false,
|
|
59
|
+
roles: (row.roles as string[]) ?? []
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return resolved;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function requestUser(
|
|
66
|
+
baseUrl: string,
|
|
67
|
+
uid: string,
|
|
68
|
+
getAuthToken: (() => Promise<string | undefined>) | undefined
|
|
69
|
+
): Promise<void> {
|
|
70
|
+
const cache = getCache(baseUrl);
|
|
71
|
+
const existing = cache.pending.get(uid);
|
|
72
|
+
if (existing) return existing;
|
|
73
|
+
|
|
74
|
+
cache.queue.add(uid);
|
|
75
|
+
|
|
76
|
+
const promise = new Promise<void>((resolve, reject) => {
|
|
77
|
+
if (cache.flush) clearTimeout(cache.flush);
|
|
78
|
+
cache.flush = setTimeout(async () => {
|
|
79
|
+
const ids = [...cache.queue];
|
|
80
|
+
cache.queue.clear();
|
|
81
|
+
cache.flush = undefined;
|
|
82
|
+
try {
|
|
83
|
+
const token = await getAuthToken?.();
|
|
84
|
+
const resolved = await fetchUsers(baseUrl, ids, token);
|
|
85
|
+
for (const id of ids) {
|
|
86
|
+
cache.users.set(id, resolved.get(id) ?? null);
|
|
87
|
+
cache.pending.delete(id);
|
|
88
|
+
}
|
|
89
|
+
resolve();
|
|
90
|
+
} catch (error) {
|
|
91
|
+
for (const id of ids) cache.pending.delete(id);
|
|
92
|
+
reject(error);
|
|
93
|
+
}
|
|
94
|
+
}, 0);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
cache.pending.set(uid, promise);
|
|
98
|
+
return promise;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The auth user behind a `userSelect` value, or `null` while it is loading or
|
|
103
|
+
* when it cannot be resolved.
|
|
104
|
+
*/
|
|
105
|
+
export function useResolvedUser(uid: string | undefined): User | null {
|
|
106
|
+
const client = useRebaseClient<{ baseUrl?: string }>();
|
|
107
|
+
const { getAuthToken } = useAuthController();
|
|
108
|
+
const baseUrl = client?.baseUrl;
|
|
109
|
+
|
|
110
|
+
const [user, setUser] = useState<User | null>(() =>
|
|
111
|
+
(baseUrl && uid) ? getCache(baseUrl).users.get(uid) ?? null : null);
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!baseUrl || !uid) {
|
|
115
|
+
setUser(null);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const cache = getCache(baseUrl);
|
|
119
|
+
if (cache.users.has(uid)) {
|
|
120
|
+
setUser(cache.users.get(uid) ?? null);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let active = true;
|
|
125
|
+
requestUser(baseUrl, uid, getAuthToken)
|
|
126
|
+
.then(() => {
|
|
127
|
+
if (active) setUser(getCache(baseUrl).users.get(uid) ?? null);
|
|
128
|
+
})
|
|
129
|
+
.catch(() => {
|
|
130
|
+
if (active) setUser(null);
|
|
131
|
+
});
|
|
132
|
+
return () => {
|
|
133
|
+
active = false;
|
|
134
|
+
};
|
|
135
|
+
}, [baseUrl, uid, getAuthToken]);
|
|
136
|
+
|
|
137
|
+
return user;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Human-readable label for a resolved user. */
|
|
141
|
+
export function getUserLabel(user: User): string {
|
|
142
|
+
return user.displayName || user.email || user.uid;
|
|
143
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SelectionProps, SelectionTableBinding } from "../components/ReferenceTable/SelectionTableBinding";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { useCallback, useMemo } from "react";
|
|
4
4
|
import { useSideDialogsController } from "./useSideDialogsController";
|
|
5
5
|
import { useCollectionRegistryController } from "./navigation/contexts/CollectionRegistryContext";
|
|
6
|
+
import type { AdminCollection } from "@rebasepro/admin-types";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* This hook is used to open a side dialog that allows the selection
|
|
@@ -26,7 +27,7 @@ export function useSelectionDialog<M extends Record<string, unknown>>(referenceD
|
|
|
26
27
|
if (referenceDialogProps.path) {
|
|
27
28
|
let usedCollection = referenceDialogProps.collection;
|
|
28
29
|
if (!usedCollection)
|
|
29
|
-
usedCollection = navigation.getCollection(referenceDialogProps.path) as
|
|
30
|
+
usedCollection = navigation.getCollection(referenceDialogProps.path) as AdminCollection<M> | undefined;
|
|
30
31
|
if (!usedCollection)
|
|
31
32
|
throw Error("Not able to resolve the collection in useSelectionDialog. Make sure a collection is registered in path " + referenceDialogProps.path);
|
|
32
33
|
sideDialogsController.open({
|
|
@@ -18,7 +18,7 @@ import { useContext } from "react";
|
|
|
18
18
|
*
|
|
19
19
|
* @group Hooks and utilities
|
|
20
20
|
*/
|
|
21
|
-
import { SideDialogPanelProps, SideDialogsController } from "@rebasepro/types";
|
|
21
|
+
import { SideDialogPanelProps, SideDialogsController } from "@rebasepro/admin-types";
|
|
22
22
|
|
|
23
23
|
export type { SideDialogPanelProps, SideDialogsController };
|
|
24
24
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SidePanelController } from "@rebasepro/types";
|
|
1
|
+
import type { SidePanelController } from "@rebasepro/admin-types";
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
|
|
4
4
|
export const SidePanelControllerContext = React.createContext<SidePanelController>({} as SidePanelController);
|
package/src/index.ts
CHANGED
|
@@ -89,7 +89,8 @@ export {
|
|
|
89
89
|
getDefaultPropertiesOrder,
|
|
90
90
|
// Preview utilities (moved from @rebasepro/app — property-aware logic belongs in CMS)
|
|
91
91
|
getEntityPreviewKeys,
|
|
92
|
-
getEntityTitlePropertyKey
|
|
92
|
+
getEntityTitlePropertyKey,
|
|
93
|
+
getEntityTitlePropertyKeyForEntity
|
|
93
94
|
} from "./util";
|
|
94
95
|
|
|
95
96
|
// Headless collection view adapters
|
|
@@ -56,8 +56,8 @@ export const PropertyPreview = React.memo(function PropertyPreview<P extends Pro
|
|
|
56
56
|
|
|
57
57
|
if (property === null) {
|
|
58
58
|
content = <EmptyValue/>;
|
|
59
|
-
} else if (property.
|
|
60
|
-
const ResolvedPreview = resolveComponentRef(property.
|
|
59
|
+
} else if (property.admin?.Preview) {
|
|
60
|
+
const ResolvedPreview = resolveComponentRef(property.admin.Preview) as React.ComponentType<PropertyPreviewProps<Property>> | undefined;
|
|
61
61
|
if (ResolvedPreview) {
|
|
62
62
|
content = <Suspense fallback={null}>
|
|
63
63
|
{createElement(ResolvedPreview,
|
|
@@ -68,7 +68,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<P extends Pro
|
|
|
68
68
|
size,
|
|
69
69
|
height,
|
|
70
70
|
width,
|
|
71
|
-
customProps: property.
|
|
71
|
+
customProps: property.admin?.customProps
|
|
72
72
|
})}
|
|
73
73
|
</Suspense>;
|
|
74
74
|
}
|
|
@@ -86,20 +86,20 @@ export const PropertyPreview = React.memo(function PropertyPreview<P extends Pro
|
|
|
86
86
|
size={props.size}
|
|
87
87
|
fill={fill}
|
|
88
88
|
storagePathOrDownloadUrl={filePath}/>;
|
|
89
|
-
} else if (stringProperty.
|
|
90
|
-
if (typeof stringProperty.
|
|
89
|
+
} else if (stringProperty.admin?.urlPreview) {
|
|
90
|
+
if (typeof stringProperty.admin?.urlPreview === "boolean")
|
|
91
91
|
content =
|
|
92
92
|
<UrlComponentPreview size={props.size}
|
|
93
93
|
url={value}
|
|
94
94
|
fill={fill}/>;
|
|
95
|
-
else if (typeof stringProperty.
|
|
95
|
+
else if (typeof stringProperty.admin?.urlPreview === "string")
|
|
96
96
|
content =
|
|
97
97
|
<UrlComponentPreview size={props.size}
|
|
98
98
|
url={value}
|
|
99
99
|
interactive={interactive}
|
|
100
100
|
fill={fill}
|
|
101
|
-
previewType={stringProperty.
|
|
102
|
-
} else if (stringProperty.
|
|
101
|
+
previewType={stringProperty.admin?.urlPreview}/>;
|
|
102
|
+
} else if (stringProperty.admin?.markdown) {
|
|
103
103
|
content = <Markdown source={value} size={"small"}/>;
|
|
104
104
|
} else if (stringProperty.userSelect) {
|
|
105
105
|
content = <UserPreview
|
|
@@ -194,7 +194,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<P extends Pro
|
|
|
194
194
|
if (typeof value === "object" && value !== null && "isEntityReference" in value && (value as EntityReference).isEntityReference()) {
|
|
195
195
|
content = <ReferencePreview
|
|
196
196
|
disabled={!property.path}
|
|
197
|
-
previewProperties={property.
|
|
197
|
+
previewProperties={property.admin?.previewProperties}
|
|
198
198
|
includeId={property.includeId}
|
|
199
199
|
includeEntityLink={property.includeEntityLink}
|
|
200
200
|
size={props.size}
|
|
@@ -223,7 +223,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<P extends Pro
|
|
|
223
223
|
key={`preview_rel_${propertyKey}_${index}`}>
|
|
224
224
|
<RelationPreview
|
|
225
225
|
disabled={!property.relation}
|
|
226
|
-
previewProperties={property.
|
|
226
|
+
previewProperties={property.admin?.previewProperties}
|
|
227
227
|
includeId={property.includeId}
|
|
228
228
|
includeEntityLink={property.includeEntityLink}
|
|
229
229
|
size={"small"}
|
|
@@ -241,7 +241,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<P extends Pro
|
|
|
241
241
|
if (relationValue) {
|
|
242
242
|
content = <RelationPreview
|
|
243
243
|
disabled={!property.relation}
|
|
244
|
-
previewProperties={property.
|
|
244
|
+
previewProperties={property.admin?.previewProperties}
|
|
245
245
|
includeId={property.includeId}
|
|
246
246
|
includeEntityLink={property.includeEntityLink}
|
|
247
247
|
size={props.size}
|