@rebasepro/cms 0.28.2 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/collection_editor/_cms_internals.d.ts +0 -1
- package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
- package/dist/components/AdditionalFieldValue.d.ts +9 -3
- package/dist/components/AdditionalFieldValue.js +7 -4
- package/dist/components/AdditionalFieldValue.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +117 -18
- package/dist/components/CollectionPanel.js +115 -37
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
- package/dist/components/CollectionTableBinding/column_utils.js +6 -3
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
- package/dist/components/CollectionTableBinding/internal/common.js +88 -4
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
- package/dist/components/CollectionViewBinding/RowActions.js +60 -0
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
- package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
- package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
- package/dist/components/CollectionViewBinding/fields.js +47 -0
- package/dist/components/CollectionViewBinding/fields.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
- package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +3 -3
- package/dist/components/CollectionsProvider.js +4 -4
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/CollectionsScopeContext.d.ts +1 -1
- package/dist/components/CollectionsScopeContext.js +1 -1
- package/dist/components/CollectionsScopeContext.js.map +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +2 -2
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +32 -68
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js +5 -4
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -2
- package/dist/components/EditViewBinding.js +25 -15
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.js +8 -5
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +8 -1
- package/dist/components/EntityViewBinding.js +43 -14
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +40 -0
- package/dist/components/EntityViewBody.js +90 -0
- package/dist/components/EntityViewBody.js.map +1 -0
- package/dist/components/FieldValue.d.ts +50 -0
- package/dist/components/FieldValue.js +81 -0
- package/dist/components/FieldValue.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PanelNotFound.d.ts +5 -0
- package/dist/components/PanelNotFound.js +21 -0
- package/dist/components/PanelNotFound.js.map +1 -0
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/components/RebaseCMS.js +11 -3
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +9 -3
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RebaseShell.js +10 -5
- package/dist/components/RebaseShell.js.map +1 -1
- package/dist/components/RecordDetail.d.ts +61 -0
- package/dist/components/RecordDetail.js +123 -0
- package/dist/components/RecordDetail.js.map +1 -0
- package/dist/components/RecordForm.d.ts +126 -0
- package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
- package/dist/components/RecordForm.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
- package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +5 -3
- package/dist/components/ReferenceWidget.js +10 -7
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.js +4 -4
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +2 -3
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
- package/dist/components/SelectableTable/SelectionStore.js +1 -1
- package/dist/components/SelectableTable/SelectionStore.js.map +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
- package/dist/components/SidePanelBinding.js +13 -12
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/collection_prop.d.ts +18 -0
- package/dist/components/collection_prop.js +23 -0
- package/dist/components/collection_prop.js.map +1 -0
- package/dist/components/common/default_entity_actions.js +54 -54
- package/dist/components/common/default_entity_actions.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +4 -1
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
- package/dist/data_export/export/ExportCollectionAction.js +4 -3
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +6 -3
- package/dist/data_export/export/additional_fields.js +8 -4
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.js +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +255 -150
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js +3 -2
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.d.ts +1 -1
- package/dist/form/EntityFormBinding.js +22 -11
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormField.d.ts +36 -0
- package/dist/form/FormField.js +41 -0
- package/dist/form/FormField.js.map +1 -0
- package/dist/form/FormFieldsContext.d.ts +69 -0
- package/dist/form/FormFieldsContext.js +143 -0
- package/dist/form/FormFieldsContext.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +4 -4
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/collection_showing.d.ts +8 -0
- package/dist/form/collection_showing.js +29 -0
- package/dist/form/collection_showing.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +2 -1
- package/dist/form/components/ErrorFocus.js.map +1 -1
- package/dist/form/components/FieldBlock.js +3 -1
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +5 -1
- package/dist/form/components/FormRail.js +5 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/FormSections.d.ts +5 -1
- package/dist/form/components/FormSections.js +11 -4
- package/dist/form/components/FormSections.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/form_dom_ids.d.ts +25 -0
- package/dist/form/form_dom_ids.js +42 -0
- package/dist/form/form_dom_ids.js.map +1 -0
- package/dist/form/index.d.ts +3 -1
- package/dist/form/resolve_cell_property.d.ts +5 -0
- package/dist/form/resolve_cell_property.js +22 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.js +9 -9
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useEntityDisplay.js +6 -4
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useRecordActions.js +2 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useSelectionDialog.d.ts +20 -7
- package/dist/hooks/useSelectionDialog.js +29 -8
- package/dist/hooks/useSelectionDialog.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +15 -9
- package/dist/mcp-view.d.ts +9 -0
- package/dist/mcp-view.js +2 -0
- package/dist/mcp_view/app_modules.d.ts +29 -0
- package/dist/mcp_view/app_modules.js +163 -0
- package/dist/mcp_view/app_modules.js.map +1 -0
- package/dist/mcp_view/bridge.d.ts +90 -0
- package/dist/mcp_view/bridge.js +205 -0
- package/dist/mcp_view/bridge.js.map +1 -0
- package/dist/mcp_view/code_app.d.ts +65 -0
- package/dist/mcp_view/code_app.js +139 -0
- package/dist/mcp_view/code_app.js.map +1 -0
- package/dist/mcp_view/index.d.ts +54 -0
- package/dist/mcp_view/index.js +262 -0
- package/dist/mcp_view/index.js.map +1 -0
- package/dist/mcp_view/payload.d.ts +78 -0
- package/dist/mcp_view/payload.js +155 -0
- package/dist/mcp_view/payload.js.map +1 -0
- package/dist/mcp_view/screen.d.ts +30 -0
- package/dist/mcp_view/screen.js +245 -0
- package/dist/mcp_view/screen.js.map +1 -0
- package/dist/mcp_view/storage_source.d.ts +14 -0
- package/dist/mcp_view/storage_source.js +29 -0
- package/dist/mcp_view/storage_source.js.map +1 -0
- package/dist/mcp_view/store.d.ts +9 -0
- package/dist/mcp_view/store.js +27 -0
- package/dist/mcp_view/store.js.map +1 -0
- package/dist/mcp_view/tool_driver.d.ts +160 -0
- package/dist/mcp_view/tool_driver.js +575 -0
- package/dist/mcp_view/tool_driver.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +34 -1
- package/dist/preview/components/DatePreview.js +72 -37
- package/dist/preview/components/DatePreview.js.map +1 -1
- package/dist/routes/RebaseRoute.js +1 -1
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +5 -3
- package/dist/selection/SelectionMenu.js +16 -9
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/resolve_selection.d.ts +61 -7
- package/dist/selection/resolve_selection.js +93 -11
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +60 -10
- package/dist/types/fields.d.ts +2 -65
- package/dist/util/dataControllerAdapter.d.ts +8 -0
- package/dist/util/dataControllerAdapter.js +11 -0
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/navigation_utils.d.ts +5 -4
- package/dist/util/navigation_utils.js +6 -6
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +8 -0
- package/dist/util/propertyConfigMapper.js +16 -2
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/package.json +15 -9
- package/recipes/README.md +79 -26
- package/recipes/approval-queue.tsx +79 -0
- package/recipes/bulk-set-status.tsx +23 -17
- package/recipes/calendar-view.tsx +28 -23
- package/recipes/master-detail.tsx +75 -0
- package/recipes/my-preferences.tsx +3 -3
- package/recipes/orders-dashboard.tsx +58 -84
- package/recipes/site-settings.tsx +4 -4
- package/dist/components/EntityFormPanel.d.ts +0 -63
- package/dist/components/EntityFormPanel.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetailViewBinding.js","names":[],"sources":["../../src/components/DetailViewBinding.tsx"],"sourcesContent":["import type { ComponentRef } from \"@rebasepro/types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport type { EntityCustomViewParams, FormViewConfig, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { FormContext } from \"../types/fields\";\nimport type { PluginFormActionProps } from \"@rebasepro/cms-types\";\nimport React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Entity, EntityStatus, Property } from \"@rebasepro/types\";\nimport { PluginProviderStack, resolveComponentRef, useComponentOverride, CollectionScopeProvider, getAdminEntityChildViews } from \"@rebasepro/app\";\n\nimport { CollectionViewBinding } from \"./CollectionViewBinding/CollectionViewBinding\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport { EntityIdentityBar } from \"./EntityIdentityBar\";\nimport { SplitListCloseButton } from \"./CollectionViewBinding/SplitListCloseButton\";\nimport { SplitListShowButton } from \"./CollectionViewBinding/SplitListShowButton\";\nimport { EntityInspector, InspectorTab } from \"./EntityInspector\";\nimport { CircularProgressCenter, iconSize } from \"@rebasepro/ui\";\nimport {\n Alert,\n Button,\n CenteredView,\n cls,\n CodeIcon,\n defaultBorderMixin,\n HistoryIcon,\n IconButton,\n Maximize2Icon,\n PencilIcon,\n Skeleton,\n Tab,\n Tabs,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { ErrorView, createFormexStub, usePermissions, useTranslation, getIcon } from \"@rebasepro/app\";\n\nimport { removeInitialAndTrailingSlashes, resolveDefaultSelectedView } from \"@rebasepro/app\";\nimport { withListState } from \"../util/view_mode\";\nimport { resolvedSelectedEntityView } from \"../util/resolutions\";\nimport {\n useCustomizationController,\n useFetch,\n useRebaseContext,\n useLargeLayout,\n useSlot\n} from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigate } from \"react-router\";\nimport { useEntityDisplayTitle } from \"../hooks/useEntityDisplayTitle\";\nimport { useAdminContext } from \"../hooks/useAdminContext\";\nimport { useLeaveRecord, useRecordActions } from \"../hooks/useRecordActions\";\n\n\nimport {\n MAIN_TAB_VALUE,\n JSON_TAB_VALUE,\n HISTORY_TAB_VALUE,\n ENTITY_VIEW_TAB_BAR_CLASS,\n ENTITY_VIEW_TAB_CLASS,\n ENTITY_VIEW_TAB_LABEL_CLASS\n} from \"../util/view_constants\";\n\nexport type BarActionsParams = {\n values: object,\n status: EntityStatus,\n path: string,\n entityId?: string | number;\n /** Always false here — this view reads a record, it does not edit one. */\n dirty: boolean;\n};\n\nexport type OnTabChangeParams<M extends Record<string, unknown>> = {\n path: string;\n entityId?: string | number;\n selectedTab?: string;\n collection: AdminCollection<M>;\n};\n\nexport interface DetailViewBindingProps<M extends Record<string, unknown> = Record<string, unknown>> {\n path: string;\n collection: AdminCollection<M>;\n entityId: string | number;\n selectedTab?: string;\n parentCollectionSlugs: string[];\n parentEntityIds: string[];\n onTabChange?: (props: OnTabChangeParams<M>) => void;\n onEditClick?: () => void;\n /**\n * Dismiss this record — the ✕ at the identity bar's trailing edge.\n *\n * Set by the layouts that own the record's place on screen but are not side\n * dialogs: the split, where dismissing is navigating back to the collection.\n */\n onCloseRequest?: () => void;\n layout?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n barActions?: (params: BarActionsParams) => React.ReactNode;\n /**\n * Controls the owning panel puts at the identity bar's leading edge, ahead\n * of the breadcrumb — the side panel's close button.\n */\n barActionsStart?: React.ReactNode;\n /**\n * Full screen only: bring the list back beside this record. Set when the\n * record was opened out of a split collection, so folding the list away is\n * reversible; it takes the place of the back arrow when present.\n */\n onShowList?: () => void;\n}\n\nexport function DetailViewBinding<M extends Record<string, unknown>>({\n entityId,\n ...props\n}: DetailViewBindingProps<M>) {\n\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useFetch<M>({\n path: props.path,\n entityId: entityId,\n collection: props.collection,\n // The relation fields' values, read with the record (see `useFetch`).\n relations: true,\n useCache: false\n });\n\n if (!dataLoading && dataLoadingError) {\n return <CenteredView>\n <ErrorView error={dataLoadingError} />\n </CenteredView>;\n }\n\n if (!dataLoading && !entity) {\n return <CenteredView>\n <Typography variant=\"label\">Entity not found</Typography>\n </CenteredView>;\n }\n\n const content = (\n <DetailViewBindingInner<M>\n {...props}\n entityId={entityId}\n entity={entity}\n dataLoading={dataLoading}\n />\n );\n\n return (\n <CollectionScopeProvider collection={props.collection}>\n {content}\n </CollectionScopeProvider>\n );\n}\n\nfunction DetailViewBindingInner<M extends Record<string, unknown>>({\n path,\n entityId,\n selectedTab: selectedTabProp,\n collection,\n parentCollectionSlugs,\n parentEntityIds,\n onTabChange,\n onEditClick,\n onCloseRequest,\n entity,\n dataLoading,\n layout = \"full_screen\",\n barActions,\n barActionsStart,\n onShowList\n}: DetailViewBindingProps<M> & {\n entity?: Entity<M>,\n dataLoading: boolean,\n}) {\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const { t } = useTranslation();\n const context = useRebaseContext();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const customizationController = useCustomizationController();\n const plugins = customizationController.plugins;\n const collectionRegistryController = useCollectionRegistryController();\n const { canEdit: canEditHook } = usePermissions();\n\n const canEdit = useMemo(() => {\n return entity ? canEditHook(collection, path, entity) : false;\n }, [canEditHook, entity, collection, path]);\n\n const [usedEntity, setUsedEntity] = useState<Entity<M> | undefined>(entity);\n useEffect(() => {\n if (entity) setUsedEntity(entity);\n }, [entity]);\n\n const defaultSelectedView = useMemo(() => resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\",\nentityId }\n ), [collection, entityId]);\n\n // Track whether the user has explicitly clicked a tab in this component\n // instance. See EditViewBindingInner for full explanation.\n const userHasChangedTab = useRef(false);\n\n const [selectedTab, setSelectedTab] = useState<string>(() => {\n const val = selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE;\n return val === \"edit\" ? MAIN_TAB_VALUE : val;\n });\n useEffect(() => {\n const val = userHasChangedTab.current\n ? (selectedTabProp ?? MAIN_TAB_VALUE)\n : (selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);\n const target = val === \"edit\" ? MAIN_TAB_VALUE : val;\n if (target !== selectedTab) {\n setSelectedTab(target);\n }\n }, [selectedTabProp, defaultSelectedView]);\n\n // `hideFromEntityViews`, not `hideFromNavigation`: the latter governs the\n // drawer. Filtering tabs on it defeated the introspection generator, which\n // sets `hideFromNavigation` on owned-child tables precisely *because* \"every\n // inbound foreign key renders as a tab on the parent\" — so the rows it\n // deliberately kept out of the drawer became reachable from nowhere.\n const childViews = getAdminEntityChildViews(collection).filter(v => !v.collection.hideFromEntityViews);\n const subcollections = childViews.map(v => v.collection);\n const subcollectionsCount = subcollections?.length ?? 0;\n const customViews = collection.entityViews ?? [];\n const customViewsCount = customViews?.length ?? 0;\n const includeJsonView = collection.includeJsonView === undefined ? true : collection.includeJsonView;\n const includeHistoryView = Boolean(collection.history);\n // Same split as the edit view: the strip is for destinations, the inspector\n // for the developer tools that used to sit in front of them.\n const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;\n\n const [inspectorTab, setInspectorTab] = useState<InspectorTab | null>(null);\n\n const legacyInspectorTab: InspectorTab | undefined = selectedTab === JSON_TAB_VALUE\n ? \"json\"\n : selectedTab === HISTORY_TAB_VALUE ? \"history\" : undefined;\n useEffect(() => {\n if (legacyInspectorTab) setInspectorTab(legacyInspectorTab);\n }, [legacyInspectorTab]);\n\n const {\n resolvedEntityViews\n } = resolvedSelectedEntityView(customViews, customizationController, undefined, canEdit);\n\n const validTabValues = useMemo(() => {\n const set = new Set<string>([\n MAIN_TAB_VALUE,\n ...resolvedEntityViews.map(v => v.key),\n ...subcollections.map(s => s.slug)\n ]);\n return set;\n }, [resolvedEntityViews, subcollections]);\n\n const activeTab = validTabValues.has(selectedTab) ? selectedTab : MAIN_TAB_VALUE;\n\n const {\n selectedEntityView\n } = resolvedSelectedEntityView(customViews, customizationController, activeTab, canEdit);\n\n const mainViewVisible = activeTab === MAIN_TAB_VALUE;\n\n // Track which custom view tabs have been visited\n const mountedTabsRef = useRef<Set<string>>(new Set());\n if (activeTab) {\n mountedTabsRef.current.add(activeTab);\n }\n\n // Read-only form context for custom entity views\n const readOnlyFormContext = useMemo<FormContext<M> | undefined>(() => {\n if (!hasEntityId(entityId)) return undefined;\n const formexStub = createFormexStub<M>(usedEntity?.values ?? {} as M);\n return {\n entityId,\n disabled: true,\n readOnly: true,\n openEntityMode: layout,\n status: \"existing\",\n values: usedEntity?.values ?? ({} as M),\n setFieldValue: () => {\n throw new Error(\"Cannot update values in read-only detail view\");\n },\n save: () => {\n throw new Error(\"Cannot save in read-only detail view\");\n },\n submit: () => {\n throw new Error(\"Cannot submit in read-only detail view\");\n },\n collection,\n path,\n entity: usedEntity,\n savingError: undefined,\n formex: formexStub\n };\n }, [entityId, layout, usedEntity, collection, path]);\n\n // Plugin slots\n const formActionTopProps: PluginFormActionProps = useMemo(() => ({\n entityId,\n parentCollectionSlugs,\n parentEntityIds,\n path,\n status: \"existing\",\n collection: collection!,\n context,\n formContext: readOnlyFormContext as FormContext<Record<string, unknown>> | undefined,\n openEntityMode: layout,\n disabled: true\n }), [entityId, parentCollectionSlugs, parentEntityIds, path, collection, context, readOnlyFormContext, layout]);\n const pluginActionsTop = useSlot(\"form.actions.top\", formActionTopProps);\n\n // The record's own actions, as on the edit view: a read-only record is\n // still one you can recalculate, resend or delete. There is no form here,\n // so they are called without a `formContext`.\n const adminContext = useAdminContext();\n const leaveRecord = useLeaveRecord({ layout, path, onCloseRequest });\n const recordActionClickProps = useMemo(() => usedEntity\n ? {\n view: \"form\" as const,\n entity: usedEntity as Entity<Record<string, unknown>>,\n path,\n collection: collection as AdminCollection,\n context,\n sidePanelController: adminContext.sidePanelController,\n openEntityMode: layout,\n navigateBack: leaveRecord\n }\n : undefined, [usedEntity, path, collection, context, adminContext.sidePanelController, layout, leaveRecord]);\n const recordActions = useRecordActions({\n collection,\n path,\n entity: usedEntity,\n clickProps: recordActionClickProps\n });\n\n // Resolve formView.Builder if provided\n const formViewConfig = (collection as AdminCollection<M> & { formView?: FormViewConfig<M> }).formView;\n const FormViewBuilder = formViewConfig?.Builder ? resolveComponentRef<EntityCustomViewParams>(formViewConfig.Builder as ComponentRef<EntityCustomViewParams>) : null;\n\n // The heading, resolved the one way — this used to be a copy of\n // `useEntityDisplayTitle`'s body, and the two had already drifted.\n const title = useEntityDisplayTitle({\n collection,\n entity: usedEntity,\n status: \"existing\"\n });\n\n // Non-action custom views\n const nonActionCustomViews = useMemo(() =>\n resolvedEntityViews.filter(e => !e.includeActions),\n [resolvedEntityViews]\n );\n\n const customViewsView = customViews && nonActionCustomViews\n .map((customView) => {\n if (!customView) return null;\n const Builder = resolveComponentRef<EntityCustomViewParams>(customView.Builder);\n if (!Builder) return null;\n if (!hasEntityId(entityId)) return null;\n\n const isActive = activeTab === customView.key;\n const hasBeenMounted = mountedTabsRef.current.has(customView.key);\n if (!isActive && !hasBeenMounted) return null;\n\n return <div\n className={cls(defaultBorderMixin,\n \"relative flex-1 w-full h-full overflow-auto\",\n { \"hidden\": !isActive }\n )}\n key={`custom_view_${customView.key}`}\n role=\"tabpanel\">\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter />}>\n {readOnlyFormContext && <Builder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n entity={usedEntity}\n modifiedValues={usedEntity?.values}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>>}\n />}\n </Suspense>\n </ErrorBoundary>\n </div>;\n }).filter(Boolean);\n\n const globalLoading = dataLoading && !usedEntity;\n\n // Subcollection views\n const subCollectionsViews = childViews && childViews.map(({ collection: subcollection }) => {\n const subcollectionId = subcollection.slug;\n // By slug, like the path it extends: the data layer hands the driver\n // the stored path, `path` included, for the whole of it at once.\n const newFullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollection.slug)}` : undefined;\n\n if (activeTab !== subcollectionId) return null;\n return (\n <div\n className={\"relative flex-1 h-full overflow-auto w-full\"}\n key={`subcol_${subcollectionId}`}\n role=\"tabpanel\">\n {globalLoading && <CircularProgressCenter />}\n {!globalLoading &&\n (usedEntity && newFullPath\n ? <ResolvedCollectionView\n path={newFullPath}\n parentCollectionSlugs={[...parentCollectionSlugs, collection.slug]}\n parentEntityIds={[...parentEntityIds, String(usedEntity?.id)]}\n updateUrl={false}\n {...subcollection}\n openEntityMode={layout} />\n : <div className=\"flex items-center justify-center w-full h-full p-3\">\n <Typography variant={\"label\"}>\n {/* No `?? \"…\"` here: `t` returns the key itself\n when it cannot find one, never null, so the\n fallback never ran and this rendered the raw\n `save_entity_before_subcollections`. The key\n exists now, in all seven locales. */}\n {t(\"save_entity_before_subcollections\")}\n </Typography>\n </div>)\n }\n </div>\n );\n }).filter(Boolean);\n\n const onSideTabClick = useCallback((value: string) => {\n userHasChangedTab.current = true;\n setSelectedTab(value);\n onTabChange?.({\n path,\n entityId,\n selectedTab: value === MAIN_TAB_VALUE ? undefined : value,\n collection\n });\n }, [onTabChange, path, entityId, collection]);\n\n const propertyDetailView = () => {\n // formView.Builder replaces the default property display. It gets the\n // centred column the record used to be given here; the default display\n // now lays itself out, rail included.\n if (FormViewBuilder && usedEntity) {\n return <div className={\"@container/form flex-1 min-w-0 overflow-y-auto flex justify-center items-start\"}>\n <div className={cls(\n // Same widths as the default form (see EntityForm).\n \"w-full max-w-3xl @7xl/form:max-w-4xl 2xl:max-w-4xl flex flex-col\",\n layout === \"dialog\"\n ? \"pt-5 pb-12 px-6 sm:px-8\"\n : \"pt-6 pb-16 px-5 sm:px-8\"\n )}>\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter />}>\n <FormViewBuilder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n entity={usedEntity}\n modifiedValues={usedEntity?.values}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>>}\n />\n </Suspense>\n </ErrorBoundary>\n </div>\n </div>;\n }\n\n return (\n <>\n {usedEntity && <EntityViewBinding\n entity={usedEntity}\n collection={collection}\n path={path}\n asPage\n openEntityMode={layout}\n formContext={readOnlyFormContext}\n />}\n </>\n );\n };\n\n // Tabs\n const subcollectionTabs = subcollections && subcollections.map((subcollection) => {\n const icon = getIcon(subcollection.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={subcollection.slug}\n key={`entity_detail_collection_tab_${subcollection.name}`}>\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {subcollection.name}\n </span>\n </Tab>\n );\n });\n\n const customViewTabsStart = resolvedEntityViews.filter(view => view.position === \"start\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n const customViewTabsEnd = resolvedEntityViews.filter(view => !view.position || view.position === \"end\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n\n // The breadcrumb's destination, and the back arrow's when it renders. Both\n // keep the list's whole URL state: a collection reached from one of its own\n // records must come back as the user left it — the same view mode, search,\n // filters and sort.\n const collectionUrl = withListState(urlController.buildUrlCollectionPath(path));\n\n // Full screen is the one layout with no way out of its own: a side panel and a\n // dialog can be dismissed, and a split keeps the list beside it, but opening an\n // entity full screen replaces the collection entirely and left browser Back as\n // the only route back to it — which is not an affordance the page shows, and is\n // wrong anyway once the user has moved between tabs inside the entity.\n //\n // Unless the list can be unfolded back beside the record: that chevron\n // leads to the same collection while keeping the record open, so it stands\n // alone rather than beside an arrow going almost the same place.\n //\n // It goes to the bar's leading edge — where a back control reads as back,\n // and where the edit view has always put the same arrow — rather than to\n // the trailing edge among the record's own actions.\n const backToCollection = layout === \"full_screen\" && !onShowList\n ? () => navigate(collectionUrl)\n : undefined;\n\n const fullScreenButton = !barActions && // Not in split: the list panel beside it carries the close control,\n // and an expand button there competes with it.\n (layout === \"side_panel\" || layout === \"dialog\") && hasEntityId(entityId) ? (\n <Tooltip title={\"Open full screen\"}>\n <IconButton aria-label={\"Open full screen\"}\n size=\"small\"\n onClick={() => {\n const entityUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(`${entityUrl}#full`);\n }}\n >\n <Maximize2Icon size={iconSize.smallest} />\n </IconButton>\n </Tooltip>\n ) : null;\n\n // Edit button — only rendered when the user has edit permissions\n const editButton = canEdit && onEditClick ? (\n <Button\n variant=\"filled\"\n color=\"primary\"\n size=\"small\"\n startIcon={<PencilIcon size={iconSize.smallest} />}\n onClick={onEditClick}>\n {t(\"edit_entity\")}\n </Button>\n ) : null;\n\n // Main content view. The title, the `path/id` chip and the empty band under\n // them have moved into the identity bar, and the `w-80 2xl:w-96` rail that\n // held a single Edit button is gone — the bar holds it now.\n //\n // The scroll now lives on the record's own column rather than on this row,\n // so the metadata rail beside it stays put while the record scrolls — the\n // same arrangement the form uses.\n const mainView = <div\n className={cls(\n \"flex-1 flex flex-row w-full min-h-0\",\n !mainViewVisible ? \"hidden\" : \"\"\n )}>\n {propertyDetailView()}\n </div>;\n\n let result = <div className=\"relative flex flex-col h-full w-full bg-surface-card\">\n\n <EntityIdentityBar\n collection={collection as AdminCollection}\n collectionUrl={layout === \"full_screen\" || layout === \"split\" ? collectionUrl : undefined}\n title={title}\n entityId={entityId}\n status={\"existing\"}\n dirty={false}\n saving={false}\n onBack={backToCollection}\n onClose={onCloseRequest}\n onInspect={includeJsonView ? () => setInspectorTab(\"json\") : undefined}\n onViewHistory={includeHistoryView ? () => setInspectorTab(\"history\") : undefined}\n externalLink={usedEntity\n ? customizationController?.entityLinkBuilder?.({ entity: usedEntity })\n : undefined}\n recordActions={recordActions}\n // Where Save stands on the edit view: after the record's own\n // buttons, ahead of the menu.\n primaryAction={editButton}\n leading={<>\n {barActionsStart}\n {/* Split view: closing the list is opening this record\n full screen, and the control for it belongs at this\n bar's leading edge. Full screen carries its mirror. */}\n {layout === \"split\" && <SplitListCloseButton/>}\n {layout === \"full_screen\" && onShowList && <SplitListShowButton onClick={onShowList}/>}\n </>}\n trailing={<>\n {pluginActionsTop}\n {fullScreenButton}\n {barActions?.({\n path,\n entityId,\n values: usedEntity?.values ?? {},\n status: \"existing\",\n dirty: false\n })}\n </>}\n />\n\n {hasAdditionalViews && <div className={cls(\n \"h-10 shrink-0 flex items-stretch border-b px-2 min-w-0\",\n ENTITY_VIEW_TAB_BAR_CLASS,\n defaultBorderMixin\n )}>\n <Tabs\n className={\"!w-full items-stretch\"}\n innerClassName={\"h-full\"}\n variant={\"boxy\"}\n value={activeTab}\n onValueChange={(value) => {\n onSideTabClick(value);\n }}>\n\n {/* Before the record, not after it.\n\n `position: \"start\"` used to mean \"first among the custom\n views\", which put it after a tab it was already after: the\n record's own tab is drawn here unconditionally, so \"start\"\n and \"end\" only ever ordered the custom views against each\n other, and no collection could open with anything but the\n form on the left.\n\n A cover — a read-only summary of the record, the thing an\n operator opens a row to see — belongs in front of the form\n that edits it. That is what `defaultSelectedView` already\n allowed, and the strip contradicted it by drawing the\n selected tab second. Views that say nothing still land after\n the record, so nothing moves for a collection that never\n asked. */}\n {customViewTabsStart}\n\n <Tab value={MAIN_TAB_VALUE}\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}>\n <span className=\"flex items-center gap-1.5\">\n {getIcon(collection.icon, undefined, undefined, \"smallest\")}\n {collection.singularName ?? collection.name}\n </span>\n </Tab>\n\n {customViewTabsEnd}\n {subcollectionTabs}\n </Tabs>\n </div>}\n\n {/* See EditViewBinding: the inspector docks beside the record rather\n than over it, so the record stays readable and scrollable. */}\n <div className={\"flex-1 min-h-0 flex\"}>\n\n <div className={\"flex-1 min-w-0 flex flex-col\"}>\n {globalLoading\n ? <DetailViewSkeleton collection={collection} />\n : mainView}\n\n {customViewsView}\n {subCollectionsViews}\n </div>\n\n <EntityInspector\n tab={inspectorTab}\n onTabChange={setInspectorTab}\n onClose={() => setInspectorTab(null)}\n collection={collection as AdminCollection}\n entity={usedEntity as Entity<Record<string, unknown>> | undefined}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>> | undefined}\n values={usedEntity?.values}\n includeHistory={includeHistoryView}/>\n </div>\n\n </div>;\n\n if (plugins && plugins.length > 0) {\n result = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity: usedEntity,\n context,\n formContext: readOnlyFormContext\n }}>\n {result}\n </PluginProviderStack>\n );\n }\n\n return result;\n}\n\nfunction DetailViewSkeleton({ collection }: { collection: AdminCollection<Record<string, unknown>> }) {\n return (\n <div className=\"flex-1 flex flex-row w-full overflow-y-auto justify-center\">\n <div className=\"relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit\">\n <div className=\"flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10\">\n <div className=\"w-full flex flex-col items-start my-4 lg:my-6\">\n <div className={`py-1 my-4 w-2/3 ${collection.hideIdFromForm ? \"mb-6\" : \"\"}`}>\n <Skeleton height={28} className=\"w-full rounded-md\" />\n </div>\n <Skeleton height={32} className=\"w-full rounded-md\" />\n </div>\n <div className=\"mt-12 flex flex-col gap-8\">\n <div className=\"flex flex-wrap gap-x-4 w-full space-y-8\">\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8GA,SAAgB,kBAAqD,EACjE,UACA,GAAG,SACuB;CAE1B,MAAM,EACF,QACA,aACA,qBACA,SAAY;EACZ,MAAM,MAAM;EACF;EACV,YAAY,MAAM;EAElB,WAAW;EACX,UAAU;CACd,CAAC;CAED,IAAI,CAAC,eAAe,kBAChB,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,WAAD,EAAW,OAAO,iBAAmB,CAAA,EAC3B,CAAA;CAGlB,IAAI,CAAC,eAAe,CAAC,QACjB,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,YAAD;EAAY,SAAQ;YAAQ;CAA4B,CAAA,EAC9C,CAAA;CAGlB,MAAM,UACF,oBAAC,wBAAD;EACI,GAAI;EACM;EACF;EACK;CAChB,CAAA;CAGL,OACI,oBAAC,yBAAD;EAAyB,YAAY,MAAM;YACtC;CACoB,CAAA;AAEjC;AAEA,SAAS,uBAA0D,EAC/D,MACA,UACA,aAAa,iBACb,YACA,uBACA,iBACA,aACA,aACA,gBACA,QACA,aACA,SAAS,eACT,YACA,iBACA,cAID;CACC,MAAM,yBAAyB,qBAAqB,mBAAmB,qBAAqB;CAC5F,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,UAAU,iBAAiB;CACjC,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,WAAW,YAAY;CAC7B,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,UAAU,wBAAwB;CACH,gCAAgC;CACrE,MAAM,EAAE,SAAS,gBAAgB,eAAe;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AC,OAAD;GAAK,WAAU;aACX,qBAAC,OAAD;IAAK,WAAU;cAAf,CACI,qBAAC,OAAD;KAAK,WAAU;eAAf,CACI,oBAAC,OAAD;MAAK,WAAW,mBAAmB,WAAW,iBAAiB,SAAS;gBACpE,oBAAC,UAAD;OAAU,QAAQ;OAAI,WAAU;MAAqB,CAAA;KACpD,CAAA,GACL,oBAAC,UAAD;MAAU,QAAQ;MAAI,WAAU;KAAqB,CAAA,CACpD;QACL,oBAAC,OAAD;KAAK,WAAU;eACX,qBAAC,OAAD;MAAK,WAAU;gBAAf;OACI,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;MACJ;;IACJ,CAAA,CACJ;;EACJ,CAAA;CACJ,CAAA;AAEb"}
|
|
1
|
+
{"version":3,"file":"DetailViewBinding.js","names":[],"sources":["../../src/components/DetailViewBinding.tsx"],"sourcesContent":["import { hasEntityId } from \"@rebasepro/common\";\nimport type { EntityCustomViewParams, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { FormContext } from \"../types/fields\";\nimport type { PluginFormActionProps } from \"@rebasepro/cms-types\";\nimport React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Entity, EntityStatus, Property } from \"@rebasepro/types\";\nimport { PluginProviderStack, resolveComponentRef, useComponentOverride, CollectionScopeProvider, getAdminEntityChildViews } from \"@rebasepro/app\";\n\nimport { CollectionViewBinding } from \"./CollectionViewBinding/CollectionViewBinding\";\nimport { EntityViewBody, useReadOnlyFormContext } from \"./EntityViewBody\";\nimport { EntityIdentityBar } from \"./EntityIdentityBar\";\nimport { SplitListCloseButton } from \"./CollectionViewBinding/SplitListCloseButton\";\nimport { SplitListShowButton } from \"./CollectionViewBinding/SplitListShowButton\";\nimport { EntityInspector, InspectorTab } from \"./EntityInspector\";\nimport { CircularProgressCenter, iconSize } from \"@rebasepro/ui\";\nimport {\n Alert,\n Button,\n CenteredView,\n cls,\n CodeIcon,\n defaultBorderMixin,\n HistoryIcon,\n IconButton,\n Maximize2Icon,\n PencilIcon,\n Skeleton,\n Tab,\n Tabs,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { ErrorView, usePermissions, useTranslation, getIcon } from \"@rebasepro/app\";\n\nimport { removeInitialAndTrailingSlashes, resolveDefaultSelectedView } from \"@rebasepro/app\";\nimport { withListState } from \"../util/view_mode\";\nimport { resolvedSelectedEntityView } from \"../util/resolutions\";\nimport { rowOfEntity } from \"@rebasepro/app\";\nimport {\n useCustomizationController,\n useFetch,\n useRebaseContext,\n useLargeLayout,\n useSlot\n} from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigate } from \"react-router\";\nimport { useEntityDisplayTitle } from \"../hooks/useEntityDisplayTitle\";\nimport { useAdminContext } from \"../hooks/useAdminContext\";\nimport { useLeaveRecord, useRecordActions } from \"../hooks/useRecordActions\";\n\n\nimport {\n MAIN_TAB_VALUE,\n JSON_TAB_VALUE,\n HISTORY_TAB_VALUE,\n ENTITY_VIEW_TAB_BAR_CLASS,\n ENTITY_VIEW_TAB_CLASS,\n ENTITY_VIEW_TAB_LABEL_CLASS\n} from \"../util/view_constants\";\n\nexport type BarActionsParams = {\n values: object,\n status: EntityStatus,\n path: string,\n entityId?: string | number;\n /** Always false here — this view reads a record, it does not edit one. */\n dirty: boolean;\n};\n\nexport type OnTabChangeParams<M extends Record<string, unknown>> = {\n path: string;\n entityId?: string | number;\n selectedTab?: string;\n collection: AdminCollection<M>;\n};\n\nexport interface DetailViewBindingProps<M extends Record<string, unknown> = Record<string, unknown>> {\n path: string;\n collection: AdminCollection<M>;\n entityId: string | number;\n selectedTab?: string;\n parentCollectionSlugs: string[];\n parentEntityIds: string[];\n onTabChange?: (props: OnTabChangeParams<M>) => void;\n onEditClick?: () => void;\n /**\n * Dismiss this record — the ✕ at the identity bar's trailing edge.\n *\n * Set by the layouts that own the record's place on screen but are not side\n * dialogs: the split, where dismissing is navigating back to the collection.\n */\n onCloseRequest?: () => void;\n layout?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n barActions?: (params: BarActionsParams) => React.ReactNode;\n /**\n * Controls the owning panel puts at the identity bar's leading edge, ahead\n * of the breadcrumb — the side panel's close button.\n */\n barActionsStart?: React.ReactNode;\n /**\n * Full screen only: bring the list back beside this record. Set when the\n * record was opened out of a split collection, so folding the list away is\n * reversible; it takes the place of the back arrow when present.\n */\n onShowList?: () => void;\n}\n\nexport function DetailViewBinding<M extends Record<string, unknown>>({\n entityId,\n ...props\n}: DetailViewBindingProps<M>) {\n\n const { t } = useTranslation();\n\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useFetch<M>({\n path: props.path,\n entityId: entityId,\n collection: props.collection,\n // The relation fields' values, read with the record (see `useFetch`).\n relations: true,\n useCache: false\n });\n\n if (!dataLoading && dataLoadingError) {\n return <CenteredView>\n <ErrorView error={dataLoadingError} />\n </CenteredView>;\n }\n\n if (!dataLoading && !entity) {\n return <CenteredView>\n <Typography variant=\"label\">{t(\"entity_not_found\")}</Typography>\n </CenteredView>;\n }\n\n const content = (\n <DetailViewBindingInner<M>\n {...props}\n entityId={entityId}\n entity={entity}\n dataLoading={dataLoading}\n />\n );\n\n return (\n <CollectionScopeProvider collection={props.collection}>\n {content}\n </CollectionScopeProvider>\n );\n}\n\nfunction DetailViewBindingInner<M extends Record<string, unknown>>({\n path,\n entityId,\n selectedTab: selectedTabProp,\n collection,\n parentCollectionSlugs,\n parentEntityIds,\n onTabChange,\n onEditClick,\n onCloseRequest,\n entity,\n dataLoading,\n layout = \"full_screen\",\n barActions,\n barActionsStart,\n onShowList\n}: DetailViewBindingProps<M> & {\n entity?: Entity<M>,\n dataLoading: boolean,\n}) {\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const { t } = useTranslation();\n const context = useRebaseContext();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const customizationController = useCustomizationController();\n const plugins = customizationController.plugins;\n const collectionRegistryController = useCollectionRegistryController();\n const { canEdit: canEditHook } = usePermissions();\n\n const canEdit = useMemo(() => {\n return entity ? canEditHook(collection, path, entity.values) : false;\n }, [canEditHook, entity, collection, path]);\n\n const [usedEntity, setUsedEntity] = useState<Entity<M> | undefined>(entity);\n useEffect(() => {\n if (entity) setUsedEntity(entity);\n }, [entity]);\n // The record as the entity views and the actions are handed it.\n const usedRow = usedEntity ? rowOfEntity(usedEntity, collection) : undefined;\n\n const defaultSelectedView = useMemo(() => resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\", id: entityId }\n ), [collection, entityId]);\n\n // Track whether the user has explicitly clicked a tab in this component\n // instance. See EditViewBindingInner for full explanation.\n const userHasChangedTab = useRef(false);\n\n const [selectedTab, setSelectedTab] = useState<string>(() => {\n const val = selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE;\n return val === \"edit\" ? MAIN_TAB_VALUE : val;\n });\n useEffect(() => {\n const val = userHasChangedTab.current\n ? (selectedTabProp ?? MAIN_TAB_VALUE)\n : (selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);\n const target = val === \"edit\" ? MAIN_TAB_VALUE : val;\n if (target !== selectedTab) {\n setSelectedTab(target);\n }\n }, [selectedTabProp, defaultSelectedView]);\n\n // `hideFromEntityViews`, not `hideFromNavigation`: the latter governs the\n // drawer. Filtering tabs on it defeated the introspection generator, which\n // sets `hideFromNavigation` on owned-child tables precisely *because* \"every\n // inbound foreign key renders as a tab on the parent\" — so the rows it\n // deliberately kept out of the drawer became reachable from nowhere.\n const childViews = getAdminEntityChildViews(collection).filter(v => !v.collection.hideFromEntityViews);\n const subcollections = childViews.map(v => v.collection);\n const subcollectionsCount = subcollections?.length ?? 0;\n const customViews = collection.entityViews ?? [];\n const customViewsCount = customViews?.length ?? 0;\n const includeJsonView = collection.includeJsonView === undefined ? true : collection.includeJsonView;\n const includeHistoryView = Boolean(collection.history);\n // Same split as the edit view: the strip is for destinations, the inspector\n // for the developer tools that used to sit in front of them.\n const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;\n\n const [inspectorTab, setInspectorTab] = useState<InspectorTab | null>(null);\n\n const legacyInspectorTab: InspectorTab | undefined = selectedTab === JSON_TAB_VALUE\n ? \"json\"\n : selectedTab === HISTORY_TAB_VALUE ? \"history\" : undefined;\n useEffect(() => {\n if (legacyInspectorTab) setInspectorTab(legacyInspectorTab);\n }, [legacyInspectorTab]);\n\n const {\n resolvedEntityViews\n } = resolvedSelectedEntityView(customViews, customizationController, undefined, canEdit);\n\n const validTabValues = useMemo(() => {\n const set = new Set<string>([\n MAIN_TAB_VALUE,\n ...resolvedEntityViews.map(v => v.key),\n ...subcollections.map(s => s.slug)\n ]);\n return set;\n }, [resolvedEntityViews, subcollections]);\n\n const activeTab = validTabValues.has(selectedTab) ? selectedTab : MAIN_TAB_VALUE;\n\n const {\n selectedEntityView\n } = resolvedSelectedEntityView(customViews, customizationController, activeTab, canEdit);\n\n const mainViewVisible = activeTab === MAIN_TAB_VALUE;\n\n // Track which custom view tabs have been visited\n const mountedTabsRef = useRef<Set<string>>(new Set());\n if (activeTab) {\n mountedTabsRef.current.add(activeTab);\n }\n\n // Read-only form context for custom entity views\n const readOnlyFormContext = useReadOnlyFormContext<M>({\n entityId,\n entity: usedEntity,\n collection,\n path,\n openEntityMode: layout\n });\n\n // Plugin slots\n const formActionTopProps: PluginFormActionProps = useMemo(() => ({\n id: entityId,\n parentCollectionSlugs,\n parentEntityIds,\n path,\n status: \"existing\",\n collection: collection!,\n context,\n formContext: readOnlyFormContext as FormContext<Record<string, unknown>> | undefined,\n openEntityMode: layout,\n disabled: true\n }), [entityId, parentCollectionSlugs, parentEntityIds, path, collection, context, readOnlyFormContext, layout]);\n const pluginActionsTop = useSlot(\"form.actions.top\", formActionTopProps);\n\n // The record's own actions, as on the edit view: a read-only record is\n // still one you can recalculate, resend or delete. There is no form here,\n // so they are called without a `formContext`.\n const adminContext = useAdminContext();\n const leaveRecord = useLeaveRecord({ layout, path, onCloseRequest });\n const recordActionClickProps = useMemo(() => usedEntity\n ? {\n view: \"form\" as const,\n row: usedRow,\n id: String(usedEntity.id),\n path,\n collection: collection as AdminCollection,\n context,\n sidePanelController: adminContext.sidePanelController,\n openEntityMode: layout,\n navigateBack: leaveRecord\n }\n : undefined, [usedEntity, usedRow, path, collection, context, adminContext.sidePanelController, layout, leaveRecord]);\n const recordActions = useRecordActions({\n collection,\n path,\n entity: usedEntity,\n clickProps: recordActionClickProps\n });\n\n // The heading, resolved the one way — this used to be a copy of\n // `useEntityDisplayTitle`'s body, and the two had already drifted.\n const title = useEntityDisplayTitle({\n collection,\n entity: usedEntity,\n status: \"existing\"\n });\n\n // Non-action custom views\n const nonActionCustomViews = useMemo(() =>\n resolvedEntityViews.filter(e => !e.includeActions),\n [resolvedEntityViews]\n );\n\n const customViewsView = customViews && nonActionCustomViews\n .map((customView) => {\n if (!customView) return null;\n const Builder = resolveComponentRef<EntityCustomViewParams>(customView.Builder);\n if (!Builder) return null;\n if (!hasEntityId(entityId)) return null;\n\n const isActive = activeTab === customView.key;\n const hasBeenMounted = mountedTabsRef.current.has(customView.key);\n if (!isActive && !hasBeenMounted) return null;\n\n return <div\n className={cls(defaultBorderMixin,\n \"relative flex-1 w-full h-full overflow-auto\",\n { \"hidden\": !isActive }\n )}\n key={`custom_view_${customView.key}`}\n role=\"tabpanel\">\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter />}>\n {readOnlyFormContext && <Builder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n row={usedRow}\n id={usedEntity ? String(usedEntity.id) : undefined}\n modifiedValues={usedEntity?.values}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>>}\n />}\n </Suspense>\n </ErrorBoundary>\n </div>;\n }).filter(Boolean);\n\n const globalLoading = dataLoading && !usedEntity;\n\n // Subcollection views\n const subCollectionsViews = childViews && childViews.map(({ collection: subcollection }) => {\n const subcollectionId = subcollection.slug;\n // By slug, like the path it extends: the data layer hands the driver\n // the stored path, `path` included, for the whole of it at once.\n const newFullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollection.slug)}` : undefined;\n\n if (activeTab !== subcollectionId) return null;\n return (\n <div\n className={\"relative flex-1 h-full overflow-auto w-full\"}\n key={`subcol_${subcollectionId}`}\n role=\"tabpanel\">\n {globalLoading && <CircularProgressCenter />}\n {!globalLoading &&\n (usedEntity && newFullPath\n ? <ResolvedCollectionView\n path={newFullPath}\n parentCollectionSlugs={[...parentCollectionSlugs, collection.slug]}\n parentEntityIds={[...parentEntityIds, String(usedEntity?.id)]}\n updateUrl={false}\n {...subcollection}\n openEntityMode={layout} />\n : <div className=\"flex items-center justify-center w-full h-full p-3\">\n <Typography variant={\"label\"}>\n {/* No `?? \"…\"` here: `t` returns the key itself\n when it cannot find one, never null, so the\n fallback never ran and this rendered the raw\n `save_entity_before_subcollections`. The key\n exists now, in all seven locales. */}\n {t(\"save_entity_before_subcollections\")}\n </Typography>\n </div>)\n }\n </div>\n );\n }).filter(Boolean);\n\n const onSideTabClick = useCallback((value: string) => {\n userHasChangedTab.current = true;\n setSelectedTab(value);\n onTabChange?.({\n path,\n entityId,\n selectedTab: value === MAIN_TAB_VALUE ? undefined : value,\n collection\n });\n }, [onTabChange, path, entityId, collection]);\n\n // The record's body, drawn where `RecordDetail` draws it.\n const propertyDetailView = () => usedEntity\n ? <EntityViewBody<M>\n entity={usedEntity}\n collection={collection}\n path={path}\n formContext={readOnlyFormContext}\n openEntityMode={layout}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n />\n : null;\n\n // Tabs\n const subcollectionTabs = subcollections && subcollections.map((subcollection) => {\n const icon = getIcon(subcollection.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={subcollection.slug}\n key={`entity_detail_collection_tab_${subcollection.name}`}>\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {subcollection.name}\n </span>\n </Tab>\n );\n });\n\n const customViewTabsStart = resolvedEntityViews.filter(view => view.position === \"start\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n const customViewTabsEnd = resolvedEntityViews.filter(view => !view.position || view.position === \"end\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n\n // The breadcrumb's destination, and the back arrow's when it renders. Both\n // keep the list's whole URL state: a collection reached from one of its own\n // records must come back as the user left it — the same view mode, search,\n // filters and sort.\n const collectionUrl = withListState(urlController.buildUrlCollectionPath(path));\n\n // Full screen is the one layout with no way out of its own: a side panel and a\n // dialog can be dismissed, and a split keeps the list beside it, but opening an\n // entity full screen replaces the collection entirely and left browser Back as\n // the only route back to it — which is not an affordance the page shows, and is\n // wrong anyway once the user has moved between tabs inside the entity.\n //\n // Unless the list can be unfolded back beside the record: that chevron\n // leads to the same collection while keeping the record open, so it stands\n // alone rather than beside an arrow going almost the same place.\n //\n // It goes to the bar's leading edge — where a back control reads as back,\n // and where the edit view has always put the same arrow — rather than to\n // the trailing edge among the record's own actions.\n const backToCollection = layout === \"full_screen\" && !onShowList\n ? () => navigate(collectionUrl)\n : undefined;\n\n const fullScreenButton = !barActions && // Not in split: the list panel beside it carries the close control,\n // and an expand button there competes with it.\n (layout === \"side_panel\" || layout === \"dialog\") && hasEntityId(entityId) ? (\n <Tooltip title={\"Open full screen\"}>\n <IconButton aria-label={\"Open full screen\"}\n size=\"small\"\n onClick={() => {\n const entityUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(`${entityUrl}#full`);\n }}\n >\n <Maximize2Icon size={iconSize.smallest} />\n </IconButton>\n </Tooltip>\n ) : null;\n\n // Edit button — only rendered when the user has edit permissions\n const editButton = canEdit && onEditClick ? (\n <Button\n variant=\"filled\"\n color=\"primary\"\n size=\"small\"\n startIcon={<PencilIcon size={iconSize.smallest} />}\n onClick={onEditClick}>\n {t(\"edit_entity\")}\n </Button>\n ) : null;\n\n // Main content view. The title, the `path/id` chip and the empty band under\n // them have moved into the identity bar, and the `w-80 2xl:w-96` rail that\n // held a single Edit button is gone — the bar holds it now.\n //\n // The scroll now lives on the record's own column rather than on this row,\n // so the metadata rail beside it stays put while the record scrolls — the\n // same arrangement the form uses.\n const mainView = <div\n className={cls(\n \"flex-1 flex flex-row w-full min-h-0\",\n !mainViewVisible ? \"hidden\" : \"\"\n )}>\n {propertyDetailView()}\n </div>;\n\n let result = <div className=\"relative flex flex-col h-full w-full bg-surface-card\">\n\n <EntityIdentityBar\n collection={collection as AdminCollection}\n collectionUrl={layout === \"full_screen\" || layout === \"split\" ? collectionUrl : undefined}\n title={title}\n entityId={entityId}\n status={\"existing\"}\n dirty={false}\n saving={false}\n onBack={backToCollection}\n onClose={onCloseRequest}\n onInspect={includeJsonView ? () => setInspectorTab(\"json\") : undefined}\n onViewHistory={includeHistoryView ? () => setInspectorTab(\"history\") : undefined}\n externalLink={usedEntity\n ? customizationController?.entityLinkBuilder?.({\n row: rowOfEntity(usedEntity, collection),\n id: String(usedEntity.id),\n path: usedEntity.path\n })\n : undefined}\n recordActions={recordActions}\n // Where Save stands on the edit view: after the record's own\n // buttons, ahead of the menu.\n primaryAction={editButton}\n leading={<>\n {barActionsStart}\n {/* Split view: closing the list is opening this record\n full screen, and the control for it belongs at this\n bar's leading edge. Full screen carries its mirror. */}\n {layout === \"split\" && <SplitListCloseButton/>}\n {layout === \"full_screen\" && onShowList && <SplitListShowButton onClick={onShowList}/>}\n </>}\n trailing={<>\n {pluginActionsTop}\n {fullScreenButton}\n {barActions?.({\n path,\n entityId,\n values: usedEntity?.values ?? {},\n status: \"existing\",\n dirty: false\n })}\n </>}\n />\n\n {hasAdditionalViews && <div className={cls(\n \"h-10 shrink-0 flex items-stretch border-b px-2 min-w-0\",\n ENTITY_VIEW_TAB_BAR_CLASS,\n defaultBorderMixin\n )}>\n <Tabs\n className={\"!w-full items-stretch\"}\n innerClassName={\"h-full\"}\n variant={\"boxy\"}\n value={activeTab}\n onValueChange={(value) => {\n onSideTabClick(value);\n }}>\n\n {/* Before the record, not after it.\n\n `position: \"start\"` used to mean \"first among the custom\n views\", which put it after a tab it was already after: the\n record's own tab is drawn here unconditionally, so \"start\"\n and \"end\" only ever ordered the custom views against each\n other, and no collection could open with anything but the\n form on the left.\n\n A cover — a read-only summary of the record, the thing an\n operator opens a row to see — belongs in front of the form\n that edits it. That is what `defaultSelectedView` already\n allowed, and the strip contradicted it by drawing the\n selected tab second. Views that say nothing still land after\n the record, so nothing moves for a collection that never\n asked. */}\n {customViewTabsStart}\n\n <Tab value={MAIN_TAB_VALUE}\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}>\n <span className=\"flex items-center gap-1.5\">\n {getIcon(collection.icon, undefined, undefined, \"smallest\")}\n {collection.singularName ?? collection.name}\n </span>\n </Tab>\n\n {customViewTabsEnd}\n {subcollectionTabs}\n </Tabs>\n </div>}\n\n {/* See EditViewBinding: the inspector docks beside the record rather\n than over it, so the record stays readable and scrollable. */}\n <div className={\"flex-1 min-h-0 flex\"}>\n\n <div className={\"flex-1 min-w-0 flex flex-col\"}>\n {globalLoading\n ? <DetailViewSkeleton collection={collection} />\n : mainView}\n\n {customViewsView}\n {subCollectionsViews}\n </div>\n\n <EntityInspector\n tab={inspectorTab}\n onTabChange={setInspectorTab}\n onClose={() => setInspectorTab(null)}\n collection={collection as AdminCollection}\n entity={usedEntity as Entity<Record<string, unknown>> | undefined}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>> | undefined}\n values={usedEntity?.values}\n includeHistory={includeHistoryView}/>\n </div>\n\n </div>;\n\n if (plugins && plugins.length > 0) {\n result = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity: usedEntity,\n context,\n formContext: readOnlyFormContext\n }}>\n {result}\n </PluginProviderStack>\n );\n }\n\n return result;\n}\n\nfunction DetailViewSkeleton({ collection }: { collection: AdminCollection<Record<string, unknown>> }) {\n return (\n <div className=\"flex-1 flex flex-row w-full overflow-y-auto justify-center\">\n <div className=\"relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit\">\n <div className=\"flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10\">\n <div className=\"w-full flex flex-col items-start my-4 lg:my-6\">\n <div className={`py-1 my-4 w-2/3 ${collection.hideIdFromForm ? \"mb-6\" : \"\"}`}>\n <Skeleton height={28} className=\"w-full rounded-md\" />\n </div>\n <Skeleton height={32} className=\"w-full rounded-md\" />\n </div>\n <div className=\"mt-12 flex flex-col gap-8\">\n <div className=\"flex flex-wrap gap-x-4 w-full space-y-8\">\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8GA,SAAgB,kBAAqD,EACjE,UACA,GAAG,SACuB;CAE1B,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,QACA,aACA,qBACA,SAAY;EACZ,MAAM,MAAM;EACF;EACV,YAAY,MAAM;EAElB,WAAW;EACX,UAAU;CACd,CAAC;CAED,IAAI,CAAC,eAAe,kBAChB,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,WAAD,EAAW,OAAO,iBAAmB,CAAA,EAC3B,CAAA;CAGlB,IAAI,CAAC,eAAe,CAAC,QACjB,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,YAAD;EAAY,SAAQ;YAAS,EAAE,kBAAkB;CAAc,CAAA,EACrD,CAAA;CAGlB,MAAM,UACF,oBAAC,wBAAD;EACI,GAAI;EACM;EACF;EACK;CAChB,CAAA;CAGL,OACI,oBAAC,yBAAD;EAAyB,YAAY,MAAM;YACtC;CACoB,CAAA;AAEjC;AAEA,SAAS,uBAA0D,EAC/D,MACA,UACA,aAAa,iBACb,YACA,uBACA,iBACA,aACA,aACA,gBACA,QACA,aACA,SAAS,eACT,YACA,iBACA,cAID;CACC,MAAM,yBAAyB,qBAAqB,mBAAmB,qBAAqB;CAC5F,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,UAAU,iBAAiB;CACjC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Q;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;MACJ;;IACJ,CAAA,CACJ;;EACJ,CAAA;CACJ,CAAA;AAEb"}
|
|
@@ -7,7 +7,7 @@ import { useChildViewSource } from "../hooks/useChildViewSource.js";
|
|
|
7
7
|
import React, { useMemo } from "react";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { AlertCircleIcon, Button, CircularProgress, DialogActions, IconButton, LoadingButton, Tooltip, Typography, iconSize } from "@rebasepro/ui";
|
|
10
|
-
import { ErrorTooltip, getIcon, useCustomizationController, usePermissions, useSnackbarController, useTranslation } from "@rebasepro/app";
|
|
10
|
+
import { ErrorTooltip, getIcon, rowOfEntity, useCustomizationController, usePermissions, useSnackbarController, useTranslation } from "@rebasepro/app";
|
|
11
11
|
//#region src/components/EditFormActions.tsx
|
|
12
12
|
/**
|
|
13
13
|
* The entity form's footer.
|
|
@@ -35,7 +35,7 @@ function EditFormActions({ collection, path, entity, savingError, formex, disabl
|
|
|
35
35
|
formActions: useMemo(() => {
|
|
36
36
|
const customEntityActions = (collection.entityActions ?? []).map((action) => resolveEntityAction(action, customizationController.entityActions)).filter(Boolean);
|
|
37
37
|
const createEnabled = canCreate(collection, path);
|
|
38
|
-
const deleteEnabled = entity ? canDelete(collection, path, entity) : false;
|
|
38
|
+
const deleteEnabled = entity ? canDelete(collection, path, entity.values) : false;
|
|
39
39
|
const disableActions = collection.disableDefaultActions ?? [];
|
|
40
40
|
const actions = [];
|
|
41
41
|
if (createEnabled && !disableActions.includes("copy")) actions.push(copyEntityAction);
|
|
@@ -88,7 +88,8 @@ function buildBottomActions({ savingError, entity, formActions, collection, cont
|
|
|
88
88
|
children: formActions.map((action, index) => {
|
|
89
89
|
const props = {
|
|
90
90
|
view: "form",
|
|
91
|
-
entity,
|
|
91
|
+
row: entity ? rowOfEntity(entity, collection) : void 0,
|
|
92
|
+
id: entity ? String(entity.id) : void 0,
|
|
92
93
|
path: collection.slug,
|
|
93
94
|
collection,
|
|
94
95
|
context,
|
|
@@ -176,7 +177,7 @@ function EntityActionButton({ action, enabled, disabledReason, props }) {
|
|
|
176
177
|
console.debug("Executing action", action.key, props);
|
|
177
178
|
try {
|
|
178
179
|
event.stopPropagation();
|
|
179
|
-
if (props.
|
|
180
|
+
if (props.row) {
|
|
180
181
|
const onClick = action.onClick(props);
|
|
181
182
|
if (onClick instanceof Promise) {
|
|
182
183
|
setLoading(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditFormActions.js","names":[],"sources":["../../src/components/EditFormActions.tsx"],"sourcesContent":["\n\nimport type { FormContext } from \"../types/fields\";\nimport type { EntityAction, EntityActionClickProps, SidePanelController, AdminCollection } from \"@rebasepro/cms-types\";\nimport React, { useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { RebaseContext } from \"@rebasepro/cms-types\";\nimport type { EntityFormActionsProps } from \"../types/components/EntityFormActionsProps\";\nimport { copyEntityAction, deleteEntityAction, unlinkEntityAction } from \"./common/default_entity_actions\";\nimport { entityActionName, mergeEntityActions, resolveEntityActionState } from \"../util/entity_actions\";\nimport { resolveEntityAction } from \"../util/resolutions\";\nimport { Button, CircularProgress, cls, defaultBorderMixin, DialogActions, IconButton, LoadingButton, Tooltip, Typography } from \"@rebasepro/ui\";\nimport { AlertCircleIcon, iconSize } from \"@rebasepro/ui\";\nimport {\n useCustomizationController,\n useSnackbarController,\n useTranslation\n} from \"@rebasepro/app\";\nimport { SideDialogController, useSideDialogContext } from \"./SideDialogs\";\nimport { FormexController } from \"@rebasepro/forms\";\nimport { ErrorTooltip } from \"@rebasepro/app\";\nimport { usePermissions } from \"@rebasepro/app\";\nimport { getIcon } from \"@rebasepro/app\";\nimport { useAdminContext } from \"../hooks/useAdminContext\";\nimport { useChildViewSource } from \"../hooks/useChildViewSource\";\n\n/**\n * The entity form's footer.\n *\n * It used to render in two shapes: this footer, and a `w-80 2xl:w-96` sticky\n * side rail carrying the same Save and Discard above several hundred pixels of\n * nothing. The rail is gone, and Save/Discard have moved to the identity bar\n * where they stay visible while the form scrolls — so with\n * `showDefaultActions={false}` this renders only what the bar cannot host:\n * record actions (copy, delete, custom), plugin actions, the saving error, and\n * the side-panel-only \"save and close\".\n */\nexport function EditFormActions({\n collection,\n path,\n entity,\n savingError,\n formex,\n disabled,\n status,\n pluginActions,\n openEntityMode,\n showDefaultActions = true,\n navigateBack,\n formContext\n}: EntityFormActionsProps) {\n\n const { canCreate, canDelete } = usePermissions();\n const context = useAdminContext();\n const sidePanelController = context.sidePanelController;\n const sideDialogContext = useSideDialogContext();\n const customizationController = useCustomizationController();\n const { t } = useTranslation();\n\n // Rows shared through a junction: the delete button here removes the\n // link, because that is what the server does for this path.\n const childViewSource = useChildViewSource(path);\n const isLinkedChildView = childViewSource?.kind === \"relation\" && childViewSource.mode === \"linked\";\n\n const entityActions = useMemo((): EntityAction[] => {\n const customEntityActions = (collection.entityActions ?? [])\n .map(action => resolveEntityAction(action, customizationController.entityActions))\n .filter(Boolean) as EntityAction[];\n const createEnabled = canCreate(collection, path);\n const deleteEnabled = entity ? canDelete(collection, path, entity) : false;\n const disableActions = collection.disableDefaultActions ?? [];\n const actions: EntityAction[] = [];\n if (createEnabled && !disableActions.includes(\"copy\"))\n actions.push(copyEntityAction);\n if (deleteEnabled && !disableActions.includes(\"delete\"))\n actions.push(isLinkedChildView ? unlinkEntityAction : deleteEntityAction);\n if (customEntityActions)\n return mergeEntityActions(actions, customEntityActions);\n return actions;\n }, [canCreate, canDelete, collection, path, customizationController.entityActions?.length, entity, collection.disableDefaultActions, isLinkedChildView]);\n\n // Record actions stay in the footer whether or not the bar carries Save;\n // they are things you do *to* the record, not ways to leave the form.\n const formActions = entityActions.filter(a => a.includeInForm === undefined || a.includeInForm);\n\n return buildBottomActions({\n savingError,\n entity,\n formActions,\n collection,\n context,\n sidePanelController,\n disabled,\n status,\n sideDialogContext,\n pluginActions,\n openEntityMode,\n navigateBack,\n formContext,\n formex,\n t,\n showDefaultActions\n });\n}\n\ntype ActionsViewProps<M extends Record<string, unknown>> = {\n savingError: Error | undefined,\n entity: Entity<M> | undefined,\n formActions: EntityAction[],\n collection: AdminCollection,\n context: RebaseContext,\n sidePanelController: SidePanelController,\n disabled: boolean,\n status: \"new\" | \"existing\" | \"copy\",\n sideDialogContext: SideDialogController,\n pluginActions?: React.ReactNode[],\n openEntityMode?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n navigateBack: () => void;\n formContext: FormContext,\n formex: FormexController<Record<string, unknown>>;\n t: (key: string, vars?: Record<string, string>) => string;\n showDefaultActions: boolean;\n className?: string;\n};\n\nfunction buildBottomActions<M extends Record<string, unknown>>({\n savingError,\n entity,\n formActions,\n collection,\n context,\n sidePanelController,\n disabled,\n status,\n sideDialogContext,\n pluginActions,\n openEntityMode,\n navigateBack,\n formContext,\n formex,\n t,\n showDefaultActions,\n className\n}: ActionsViewProps<M>) {\n\n const hasErrors = Object.keys(formex.errors).length > 0 && formex.submitCount > 0;\n // \"Save and close\" only means something where there is something to close.\n const canClose = openEntityMode === \"side_panel\" || openEntityMode === \"dialog\";\n const showBackToDetail = collection.defaultEntityAction === \"view\" && status === \"existing\";\n\n // When the container carries the actions — the entity view's identity bar\n // does — this renders nothing at all. A full-width bar holding a copy icon\n // and a delete icon is the same waste as the side rail it replaced: the\n // record actions moved into the bar's overflow menu, and Save, Discard and\n // \"save and close\" are buttons up there too.\n const hasContent = showDefaultActions || Boolean(savingError);\n\n if (!hasContent) return null;\n\n return <DialogActions\n className={className}\n // In normal flow at the foot of the form column, not overlaying it.\n position={\"sticky\"}>\n {savingError &&\n <div className=\"text-right\">\n <Typography color={\"error\"}>{savingError.message}</Typography>\n </div>\n }\n\n {formActions.length > 0 && <div className=\"grow flex overflow-auto no-scrollbar\">\n {formActions.map((action, index) => {\n\n const props = {\n view: \"form\",\n entity,\n // The slug, not the path a Firestore collection declares for\n // its store: actions route, copy and delete by `path`, and\n // the stored path can be another collection's slug.\n path: collection.slug,\n collection: collection,\n context,\n sidePanelController,\n openEntityMode,\n navigateBack,\n formContext\n } satisfies EntityActionClickProps<Record<string, unknown>>;\n\n const { enabled: isEnabled, disabledReason } = resolveEntityActionState(action, props);\n return (\n <EntityActionButton\n key={action.key ?? action.name ?? index}\n action={action}\n enabled={isEnabled}\n disabledReason={disabledReason}\n props={props}\n />\n );\n })}\n </div>}\n\n {pluginActions}\n\n {hasErrors ?\n <ErrorTooltip title={\"This form has errors\"}>\n <AlertCircleIcon className=\"ml-4 text-red-500\" size={iconSize.smallest}/>\n </ErrorTooltip> : null}\n\n {showBackToDetail && (\n <Button variant=\"text\"\n color=\"primary\"\n disabled={disabled}\n onClick={navigateBack}>\n {t(\"back_to_detail\") ?? \"Back to details\"}\n </Button>\n )}\n\n {showDefaultActions && <>\n <Button variant=\"text\"\n color=\"primary\"\n disabled={disabled || formex.isSubmitting}\n type=\"reset\">\n {status === \"existing\" ? t(\"discard\") : t(\"clear\")}\n </Button>\n <Tooltip title={hasErrors ? (t(\"fix_errors_before_saving\") ?? \"Fix highlighted errors before saving\") : undefined}>\n <Button variant={canClose ? \"text\" : \"filled\"}\n color=\"primary\"\n type=\"submit\"\n disabled={disabled || formex.isSubmitting}\n onClick={() => {\n sideDialogContext.setPendingClose(false);\n }}>\n {status === \"existing\" && t(\"save\")}\n {status === \"copy\" && t(\"create_copy\")}\n {status === \"new\" && t(\"create\")}\n </Button>\n </Tooltip>\n </>}\n\n {canClose && <LoadingButton variant=\"filled\"\n color=\"primary\"\n type=\"submit\"\n loading={formex.isSubmitting}\n disabled={disabled}\n onClick={() => {\n sideDialogContext.setPendingClose?.(true);\n }}>\n {status === \"existing\" && t(\"save_and_close\")}\n {status === \"copy\" && t(\"create_copy_and_close\")}\n {status === \"new\" && t(\"create_and_close\")}\n </LoadingButton>}\n </DialogActions>;\n}\n\nfunction EntityActionButton({\n action,\n enabled,\n disabledReason,\n props\n}: {\n action: EntityAction,\n enabled: boolean,\n disabledReason?: string,\n props: EntityActionClickProps<Record<string, unknown>>\n}) {\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n const name = entityActionName(action, t);\n const [loading, setLoading] = React.useState(false);\n return <Tooltip\n title={disabledReason ? `${name}: ${disabledReason}` : name}>\n <IconButton aria-label={name}\n disabled={!enabled}\n onClick={(event) => {\n console.debug(\"Executing action\", action.key, props);\n try {\n event.stopPropagation();\n if (props.entity) {\n const onClick = action.onClick(props);\n // If the action returns a promise, we can handle it\n if (onClick instanceof Promise) {\n setLoading(true);\n onClick\n .catch((error) => {\n console.error(\"Error executing action\", action.key, error);\n snackbarController.open({\n message: `Error executing action: ${error.message}`,\n type: \"error\"\n })\n })\n .finally(() => setLoading(false));\n } else {\n snackbarController.open({\n message: `Action ${name} executed successfully`,\n type: \"success\"\n });\n }\n\n }\n } catch (e: unknown) {\n console.error(\"Error executing action\", action.key, e);\n snackbarController.open({\n message: `Error executing action: ${e instanceof Error ? e.message : String(e)}`,\n type: \"error\"\n });\n }\n }}>\n {loading ? <CircularProgress size={\"smallest\"}/> : getIcon(action.icon, undefined, undefined, \"smallest\")}\n </IconButton>\n </Tooltip>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,gBAAgB,EAC5B,YACA,MACA,QACA,aACA,QACA,UACA,QACA,eACA,gBACA,qBAAqB,MACrB,cACA,eACuB;CAEvB,MAAM,EAAE,WAAW,cAAc,eAAe;CAChD,MAAM,UAAU,gBAAgB;CAChC,MAAM,sBAAsB,QAAQ;CACpC,MAAM,oBAAoB,qBAAqB;CAC/C,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,EAAE,MAAM,eAAe;CA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IACL;GACJ;aACC,UAAU,oBAAC,kBAAD,EAAkB,MAAM,WAAY,CAAA,IAAI,QAAQ,OAAO,MAAM,KAAA,GAAW,KAAA,GAAW,UAAU;EAChG,CAAA;CACP,CAAA;AACb"}
|
|
1
|
+
{"version":3,"file":"EditFormActions.js","names":[],"sources":["../../src/components/EditFormActions.tsx"],"sourcesContent":["\n\nimport type { FormContext } from \"../types/fields\";\nimport type { EntityAction, EntityActionClickProps, SidePanelController, AdminCollection } from \"@rebasepro/cms-types\";\nimport React, { useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { RebaseContext } from \"@rebasepro/cms-types\";\nimport type { EntityFormActionsProps } from \"../types/components/EntityFormActionsProps\";\nimport { copyEntityAction, deleteEntityAction, unlinkEntityAction } from \"./common/default_entity_actions\";\nimport { entityActionName, mergeEntityActions, resolveEntityActionState } from \"../util/entity_actions\";\nimport { resolveEntityAction } from \"../util/resolutions\";\nimport { rowOfEntity } from \"@rebasepro/app\";\nimport { Button, CircularProgress, cls, defaultBorderMixin, DialogActions, IconButton, LoadingButton, Tooltip, Typography } from \"@rebasepro/ui\";\nimport { AlertCircleIcon, iconSize } from \"@rebasepro/ui\";\nimport {\n useCustomizationController,\n useSnackbarController,\n useTranslation\n} from \"@rebasepro/app\";\nimport { SideDialogController, useSideDialogContext } from \"./SideDialogs\";\nimport { FormexController } from \"@rebasepro/forms\";\nimport { ErrorTooltip } from \"@rebasepro/app\";\nimport { usePermissions } from \"@rebasepro/app\";\nimport { getIcon } from \"@rebasepro/app\";\nimport { useAdminContext } from \"../hooks/useAdminContext\";\nimport { useChildViewSource } from \"../hooks/useChildViewSource\";\n\n/**\n * The entity form's footer.\n *\n * It used to render in two shapes: this footer, and a `w-80 2xl:w-96` sticky\n * side rail carrying the same Save and Discard above several hundred pixels of\n * nothing. The rail is gone, and Save/Discard have moved to the identity bar\n * where they stay visible while the form scrolls — so with\n * `showDefaultActions={false}` this renders only what the bar cannot host:\n * record actions (copy, delete, custom), plugin actions, the saving error, and\n * the side-panel-only \"save and close\".\n */\nexport function EditFormActions({\n collection,\n path,\n entity,\n savingError,\n formex,\n disabled,\n status,\n pluginActions,\n openEntityMode,\n showDefaultActions = true,\n navigateBack,\n formContext\n}: EntityFormActionsProps) {\n\n const { canCreate, canDelete } = usePermissions();\n const context = useAdminContext();\n const sidePanelController = context.sidePanelController;\n const sideDialogContext = useSideDialogContext();\n const customizationController = useCustomizationController();\n const { t } = useTranslation();\n\n // Rows shared through a junction: the delete button here removes the\n // link, because that is what the server does for this path.\n const childViewSource = useChildViewSource(path);\n const isLinkedChildView = childViewSource?.kind === \"relation\" && childViewSource.mode === \"linked\";\n\n const entityActions = useMemo((): EntityAction[] => {\n const customEntityActions = (collection.entityActions ?? [])\n .map(action => resolveEntityAction(action, customizationController.entityActions))\n .filter(Boolean) as EntityAction[];\n const createEnabled = canCreate(collection, path);\n const deleteEnabled = entity ? canDelete(collection, path, entity.values) : false;\n const disableActions = collection.disableDefaultActions ?? [];\n const actions: EntityAction[] = [];\n if (createEnabled && !disableActions.includes(\"copy\"))\n actions.push(copyEntityAction);\n if (deleteEnabled && !disableActions.includes(\"delete\"))\n actions.push(isLinkedChildView ? unlinkEntityAction : deleteEntityAction);\n if (customEntityActions)\n return mergeEntityActions(actions, customEntityActions);\n return actions;\n }, [canCreate, canDelete, collection, path, customizationController.entityActions?.length, entity, collection.disableDefaultActions, isLinkedChildView]);\n\n // Record actions stay in the footer whether or not the bar carries Save;\n // they are things you do *to* the record, not ways to leave the form.\n const formActions = entityActions.filter(a => a.includeInForm === undefined || a.includeInForm);\n\n return buildBottomActions({\n savingError,\n entity,\n formActions,\n collection,\n context,\n sidePanelController,\n disabled,\n status,\n sideDialogContext,\n pluginActions,\n openEntityMode,\n navigateBack,\n formContext,\n formex,\n t,\n showDefaultActions\n });\n}\n\ntype ActionsViewProps<M extends Record<string, unknown>> = {\n savingError: Error | undefined,\n entity: Entity<M> | undefined,\n formActions: EntityAction[],\n collection: AdminCollection,\n context: RebaseContext,\n sidePanelController: SidePanelController,\n disabled: boolean,\n status: \"new\" | \"existing\" | \"copy\",\n sideDialogContext: SideDialogController,\n pluginActions?: React.ReactNode[],\n openEntityMode?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n navigateBack: () => void;\n formContext: FormContext,\n formex: FormexController<Record<string, unknown>>;\n t: (key: string, vars?: Record<string, string>) => string;\n showDefaultActions: boolean;\n className?: string;\n};\n\nfunction buildBottomActions<M extends Record<string, unknown>>({\n savingError,\n entity,\n formActions,\n collection,\n context,\n sidePanelController,\n disabled,\n status,\n sideDialogContext,\n pluginActions,\n openEntityMode,\n navigateBack,\n formContext,\n formex,\n t,\n showDefaultActions,\n className\n}: ActionsViewProps<M>) {\n\n const hasErrors = Object.keys(formex.errors).length > 0 && formex.submitCount > 0;\n // \"Save and close\" only means something where there is something to close.\n const canClose = openEntityMode === \"side_panel\" || openEntityMode === \"dialog\";\n const showBackToDetail = collection.defaultEntityAction === \"view\" && status === \"existing\";\n\n // When the container carries the actions — the entity view's identity bar\n // does — this renders nothing at all. A full-width bar holding a copy icon\n // and a delete icon is the same waste as the side rail it replaced: the\n // record actions moved into the bar's overflow menu, and Save, Discard and\n // \"save and close\" are buttons up there too.\n const hasContent = showDefaultActions || Boolean(savingError);\n\n if (!hasContent) return null;\n\n return <DialogActions\n className={className}\n // In normal flow at the foot of the form column, not overlaying it.\n position={\"sticky\"}>\n {savingError &&\n <div className=\"text-right\">\n <Typography color={\"error\"}>{savingError.message}</Typography>\n </div>\n }\n\n {formActions.length > 0 && <div className=\"grow flex overflow-auto no-scrollbar\">\n {formActions.map((action, index) => {\n\n const props = {\n view: \"form\",\n row: entity ? rowOfEntity(entity, collection) : undefined,\n id: entity ? String(entity.id) : undefined,\n // The slug, not the path a Firestore collection declares for\n // its store: actions route, copy and delete by `path`, and\n // the stored path can be another collection's slug.\n path: collection.slug,\n collection: collection,\n context,\n sidePanelController,\n openEntityMode,\n navigateBack,\n formContext\n } satisfies EntityActionClickProps<Record<string, unknown>>;\n\n const { enabled: isEnabled, disabledReason } = resolveEntityActionState(action, props);\n return (\n <EntityActionButton\n key={action.key ?? action.name ?? index}\n action={action}\n enabled={isEnabled}\n disabledReason={disabledReason}\n props={props}\n />\n );\n })}\n </div>}\n\n {pluginActions}\n\n {hasErrors ?\n <ErrorTooltip title={\"This form has errors\"}>\n <AlertCircleIcon className=\"ml-4 text-red-500\" size={iconSize.smallest}/>\n </ErrorTooltip> : null}\n\n {showBackToDetail && (\n <Button variant=\"text\"\n color=\"primary\"\n disabled={disabled}\n onClick={navigateBack}>\n {t(\"back_to_detail\") ?? \"Back to details\"}\n </Button>\n )}\n\n {showDefaultActions && <>\n <Button variant=\"text\"\n color=\"primary\"\n disabled={disabled || formex.isSubmitting}\n type=\"reset\">\n {status === \"existing\" ? t(\"discard\") : t(\"clear\")}\n </Button>\n <Tooltip title={hasErrors ? (t(\"fix_errors_before_saving\") ?? \"Fix highlighted errors before saving\") : undefined}>\n <Button variant={canClose ? \"text\" : \"filled\"}\n color=\"primary\"\n type=\"submit\"\n disabled={disabled || formex.isSubmitting}\n onClick={() => {\n sideDialogContext.setPendingClose(false);\n }}>\n {status === \"existing\" && t(\"save\")}\n {status === \"copy\" && t(\"create_copy\")}\n {status === \"new\" && t(\"create\")}\n </Button>\n </Tooltip>\n </>}\n\n {canClose && <LoadingButton variant=\"filled\"\n color=\"primary\"\n type=\"submit\"\n loading={formex.isSubmitting}\n disabled={disabled}\n onClick={() => {\n sideDialogContext.setPendingClose?.(true);\n }}>\n {status === \"existing\" && t(\"save_and_close\")}\n {status === \"copy\" && t(\"create_copy_and_close\")}\n {status === \"new\" && t(\"create_and_close\")}\n </LoadingButton>}\n </DialogActions>;\n}\n\nfunction EntityActionButton({\n action,\n enabled,\n disabledReason,\n props\n}: {\n action: EntityAction,\n enabled: boolean,\n disabledReason?: string,\n props: EntityActionClickProps<Record<string, unknown>>\n}) {\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n const name = entityActionName(action, t);\n const [loading, setLoading] = React.useState(false);\n return <Tooltip\n title={disabledReason ? `${name}: ${disabledReason}` : name}>\n <IconButton aria-label={name}\n disabled={!enabled}\n onClick={(event) => {\n console.debug(\"Executing action\", action.key, props);\n try {\n event.stopPropagation();\n if (props.row) {\n const onClick = action.onClick(props);\n // If the action returns a promise, we can handle it\n if (onClick instanceof Promise) {\n setLoading(true);\n onClick\n .catch((error) => {\n console.error(\"Error executing action\", action.key, error);\n snackbarController.open({\n message: `Error executing action: ${error.message}`,\n type: \"error\"\n })\n })\n .finally(() => setLoading(false));\n } else {\n snackbarController.open({\n message: `Action ${name} executed successfully`,\n type: \"success\"\n });\n }\n\n }\n } catch (e: unknown) {\n console.error(\"Error executing action\", action.key, e);\n snackbarController.open({\n message: `Error executing action: ${e instanceof Error ? e.message : String(e)}`,\n type: \"error\"\n });\n }\n }}>\n {loading ? <CircularProgress size={\"smallest\"}/> : getIcon(action.icon, undefined, undefined, \"smallest\")}\n </IconButton>\n </Tooltip>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,gBAAgB,EAC5B,YACA,MACA,QACA,aACA,QACA,UACA,QACA,eACA,gBACA,qBAAqB,MACrB,cACA,eACuB;CAEvB,MAAM,EAAE,WAAW,cAAc,eAAe;CAChD,MAAM,UAAU,gBAAgB;CAChC,MAAM,sBAAsB,QAAQ;CACpC,MAAM,oBAAoB,qBAAqB;CAC/C,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,EAAE,MAAM,eAAe;CAI7B,MAAM,kBAAkB,mBAAmB,IAAI;CAC/C,MAAM,oBAAoB,iBAAiB,SAAS,cAAc,gBAAgB,SAAS;CAuB3F,OAAO,mBAAmB;EACtB;EACA;EACA,aAxBkB,cAA8B;GAChD,MAAM,uBAAuB,WAAW,iBAAiB,CAAC,EAAA,CACrD,KAAI,WAAU,oBAAoB,QAAQ,wBAAwB,aAAa,CAAC,CAAC,CACjF,OAAO,OAAO;GACnB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dminCollection } from "@rebasepro/cms-types";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Entity, EntityStatus } from "@rebasepro/types";
|
|
4
4
|
import type { EntityFormBindingProps } from "../form/index.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { OnSavedParams } from "../types/components/EntityFormProps.js";
|
|
6
6
|
import { MAIN_TAB_VALUE, JSON_TAB_VALUE, HISTORY_TAB_VALUE } from "../util/view_constants.js";
|
|
7
7
|
export { MAIN_TAB_VALUE, JSON_TAB_VALUE, HISTORY_TAB_VALUE };
|
|
8
8
|
export type BarActionsParams = {
|
|
@@ -43,7 +43,7 @@ export interface EditViewBindingProps<M extends Record<string, unknown> = Record
|
|
|
43
43
|
parentCollectionSlugs: string[];
|
|
44
44
|
parentEntityIds: string[];
|
|
45
45
|
onValuesModified?: (modified: boolean, values: M) => void;
|
|
46
|
-
onSaved?: (params:
|
|
46
|
+
onSaved?: (params: OnSavedParams) => void;
|
|
47
47
|
onTabChange?: (props: OnTabChangeParams<M>) => void;
|
|
48
48
|
navigateBack?: () => void;
|
|
49
49
|
/**
|
|
@@ -21,7 +21,7 @@ import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "rea
|
|
|
21
21
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
22
22
|
import { Alert, Button, CenteredView, CircularProgressCenter, DialogActions, ErrorBoundary, IconButton, Maximize2Icon, Skeleton, Tab, Tabs, Tooltip, Typography, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
|
|
23
23
|
import { hasEntityId } from "@rebasepro/common";
|
|
24
|
-
import { CollectionScopeProvider, ErrorView, PluginProviderStack, createFormexStub, getAdminEntityChildViews, getEntityFromMemoryCache, getIcon, removeEntityFromMemoryCache, removeInitialAndTrailingSlashes, resolveComponentRef, resolveDefaultSelectedView, saveEntityToMemoryCache, useComponentOverride, useCustomizationController, useFetch, useLargeLayout, usePermissions, useRebaseContext, useSlot, useTranslation } from "@rebasepro/app";
|
|
24
|
+
import { CollectionScopeProvider, ErrorView, PluginProviderStack, createFormexStub, entityOfRow, getAdminEntityChildViews, getEntityFromMemoryCache, getIcon, removeEntityFromMemoryCache, removeInitialAndTrailingSlashes, resolveComponentRef, resolveDefaultSelectedView, rowOfEntity, saveEntityToMemoryCache, useComponentOverride, useCustomizationController, useFetch, useLargeLayout, usePermissions, useRebaseContext, useSlot, useTranslation } from "@rebasepro/app";
|
|
25
25
|
import { Link, useNavigate } from "react-router";
|
|
26
26
|
//#region src/components/EditViewBinding.tsx
|
|
27
27
|
/**
|
|
@@ -60,7 +60,7 @@ function EditViewBinding({ entityId, ...props }) {
|
|
|
60
60
|
const shownEntity = deletedElsewhere ? lastSeenEntity : entity;
|
|
61
61
|
const canEdit = useMemo(() => {
|
|
62
62
|
if (status === "new" || status === "copy") return true;
|
|
63
|
-
else return shownEntity ? canEditHook(props.collection, props.path, shownEntity
|
|
63
|
+
else return shownEntity ? canEditHook(props.collection, props.path, shownEntity.values) : void 0;
|
|
64
64
|
}, [
|
|
65
65
|
canEditHook,
|
|
66
66
|
shownEntity,
|
|
@@ -138,13 +138,14 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
138
138
|
useEffect(() => {
|
|
139
139
|
if (entity) setUsedEntity(entity);
|
|
140
140
|
}, [entity]);
|
|
141
|
+
const usedRow = usedEntity ? rowOfEntity(usedEntity, collection) : void 0;
|
|
141
142
|
const [formContext, setFormContext] = useState(void 0);
|
|
142
143
|
useLargeLayout();
|
|
143
144
|
const discard = useUndoableDiscard();
|
|
144
145
|
const customizationController = useCustomizationController();
|
|
145
146
|
const plugins = customizationController.plugins;
|
|
146
147
|
const formActionTopProps = useMemo(() => ({
|
|
147
|
-
entityId,
|
|
148
|
+
id: entityId,
|
|
148
149
|
parentCollectionSlugs,
|
|
149
150
|
parentEntityIds,
|
|
150
151
|
path,
|
|
@@ -168,7 +169,7 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
168
169
|
const pluginActionsTop = useSlot("form.actions.top", formActionTopProps);
|
|
169
170
|
const defaultSelectedView = useMemo(() => resolveDefaultSelectedView(collection ? collection.defaultSelectedView : void 0, {
|
|
170
171
|
status,
|
|
171
|
-
entityId
|
|
172
|
+
id: entityId
|
|
172
173
|
}), [
|
|
173
174
|
collection,
|
|
174
175
|
status,
|
|
@@ -223,7 +224,7 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
223
224
|
if (!hasEntityId(entityId)) return void 0;
|
|
224
225
|
const formexStub = createFormexStub(usedEntity?.values ?? {});
|
|
225
226
|
return {
|
|
226
|
-
entityId,
|
|
227
|
+
id: entityId,
|
|
227
228
|
disabled: true,
|
|
228
229
|
readOnly: true,
|
|
229
230
|
openEntityMode: layout,
|
|
@@ -240,7 +241,7 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
240
241
|
},
|
|
241
242
|
collection,
|
|
242
243
|
path,
|
|
243
|
-
|
|
244
|
+
row: usedRow,
|
|
244
245
|
savingError: void 0,
|
|
245
246
|
formex: formexStub
|
|
246
247
|
};
|
|
@@ -249,6 +250,7 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
249
250
|
layout,
|
|
250
251
|
status,
|
|
251
252
|
usedEntity,
|
|
253
|
+
usedRow,
|
|
252
254
|
collection,
|
|
253
255
|
path
|
|
254
256
|
]);
|
|
@@ -274,7 +276,8 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
274
276
|
collection,
|
|
275
277
|
parentCollectionSlugs,
|
|
276
278
|
parentEntityIds,
|
|
277
|
-
|
|
279
|
+
row: usedRow,
|
|
280
|
+
id: usedEntity ? String(usedEntity.id) : void 0,
|
|
278
281
|
modifiedValues: usedFormContext?.formex?.values ?? usedEntity?.values,
|
|
279
282
|
formContext: usedFormContext
|
|
280
283
|
})
|
|
@@ -379,7 +382,8 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
379
382
|
entity: usedEntity,
|
|
380
383
|
clickProps: useMemo(() => usedEntity ? {
|
|
381
384
|
view: "form",
|
|
382
|
-
|
|
385
|
+
row: usedRow,
|
|
386
|
+
id: String(usedEntity.id),
|
|
383
387
|
path,
|
|
384
388
|
collection,
|
|
385
389
|
context,
|
|
@@ -389,6 +393,7 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
389
393
|
formContext
|
|
390
394
|
} : void 0, [
|
|
391
395
|
usedEntity,
|
|
396
|
+
usedRow,
|
|
392
397
|
path,
|
|
393
398
|
collection,
|
|
394
399
|
context,
|
|
@@ -478,7 +483,8 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
478
483
|
collection,
|
|
479
484
|
parentCollectionSlugs,
|
|
480
485
|
parentEntityIds,
|
|
481
|
-
|
|
486
|
+
row: usedRow,
|
|
487
|
+
id: usedEntity ? String(usedEntity.id) : void 0,
|
|
482
488
|
modifiedValues: usedEntity?.values,
|
|
483
489
|
formContext: readOnlyFormContext
|
|
484
490
|
})
|
|
@@ -496,9 +502,9 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
496
502
|
const entityView = /* @__PURE__ */ jsx(ResolvedEntityForm, {
|
|
497
503
|
collection,
|
|
498
504
|
path,
|
|
499
|
-
|
|
505
|
+
id: entityId ?? usedEntity?.id,
|
|
500
506
|
onValuesModified,
|
|
501
|
-
entity,
|
|
507
|
+
row: entity ? rowOfEntity(entity, collection) : void 0,
|
|
502
508
|
initialDirtyValues,
|
|
503
509
|
openEntityMode: layout,
|
|
504
510
|
showDefaultActions: false,
|
|
@@ -508,9 +514,9 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
508
514
|
disabled: !canEdit,
|
|
509
515
|
navigateBack,
|
|
510
516
|
...formProps,
|
|
511
|
-
|
|
512
|
-
setUsedEntity(
|
|
513
|
-
formProps?.
|
|
517
|
+
onRowChange: (changed) => {
|
|
518
|
+
setUsedEntity(entityOfRow(changed.row, changed.id, path, collection));
|
|
519
|
+
formProps?.onRowChange?.(changed);
|
|
514
520
|
},
|
|
515
521
|
onStatusChange: (status) => {
|
|
516
522
|
setStatus(status);
|
|
@@ -645,7 +651,11 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
645
651
|
onDiscard: actionsInFooter ? void 0 : onDiscard,
|
|
646
652
|
onInspect: includeJsonView ? () => setInspectorTab("json") : void 0,
|
|
647
653
|
onViewHistory: includeHistoryView ? () => setInspectorTab("history") : void 0,
|
|
648
|
-
externalLink: usedEntity ? customizationController?.entityLinkBuilder?.({
|
|
654
|
+
externalLink: usedEntity ? customizationController?.entityLinkBuilder?.({
|
|
655
|
+
row: rowOfEntity(usedEntity, collection),
|
|
656
|
+
id: String(usedEntity.id),
|
|
657
|
+
path: usedEntity.path
|
|
658
|
+
}) : void 0,
|
|
649
659
|
recordActions,
|
|
650
660
|
pluginActions: formPluginActions,
|
|
651
661
|
leading: /* @__PURE__ */ jsxs(Fragment, { children: [
|