@webiny/app-headless-cms 6.6.0-alpha.0 → 6.6.0-alpha.10
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/ContentEntriesModule.js +23 -6
- package/ContentEntriesModule.js.map +1 -1
- package/HeadlessCMS.js +7 -2
- package/HeadlessCMS.js.map +1 -1
- package/admin/RoutesConfig.js +19 -2
- package/admin/RoutesConfig.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionDelete.js +2 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.test.d.ts +1 -0
- package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js +125 -0
- package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js.map +1 -0
- package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.d.ts +2 -0
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.js +85 -0
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.js.map +1 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
- package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
- package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
- package/admin/components/ContentEntries/Table/Cells/CellLive.js +9 -2
- package/admin/components/ContentEntries/Table/Cells/CellLive.js.map +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditorProvider.js +1 -0
- package/admin/components/ContentModelEditor/ContentModelEditorProvider.js.map +1 -1
- package/admin/components/ContentModelEditor/FieldsSidebar.js +12 -2
- package/admin/components/ContentModelEditor/FieldsSidebar.js.map +1 -1
- package/admin/components/ContentModelEditor/evaluateExpression.d.ts +1 -1
- package/admin/components/ContentModelEditor/evaluateExpression.js +10 -0
- package/admin/components/ContentModelEditor/evaluateExpression.js.map +1 -1
- package/admin/components/ContentModelEditor/operatorOptions.js +12 -0
- package/admin/components/ContentModelEditor/operatorOptions.js.map +1 -1
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
- package/admin/components/Dialogs/EditRevisionNoteDialog.d.ts +2 -0
- package/admin/components/Dialogs/EditRevisionNoteDialog.js +33 -0
- package/admin/components/Dialogs/EditRevisionNoteDialog.js.map +1 -0
- package/admin/components/Dialogs/PublishEntryConfirmDialog.d.ts +26 -1
- package/admin/components/Dialogs/PublishEntryConfirmDialog.js +4 -3
- package/admin/components/Dialogs/PublishEntryConfirmDialog.js.map +1 -1
- package/admin/components/Dialogs/UnpublishEntryConfirmDialog.d.ts +26 -1
- package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js +4 -3
- package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js.map +1 -1
- package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js +3 -3
- package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js.map +1 -1
- package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
- package/admin/components/FieldEditor/EditFieldDialog.js +5 -2
- package/admin/components/FieldEditor/EditFieldDialog.js.map +1 -1
- package/admin/components/FieldEditor/Field.js +5 -5
- package/admin/components/FieldEditor/Field.js.map +1 -1
- package/admin/components/FieldEditor/FieldEditor.js +2 -2
- package/admin/components/FieldEditor/FieldEditor.js.map +1 -1
- package/admin/components/FieldEditor/FieldEditorContext.d.ts +1 -1
- package/admin/components/FieldEditor/FieldEditorContext.js +6 -1
- package/admin/components/FieldEditor/FieldEditorContext.js.map +1 -1
- package/admin/components/LexicalCmsEditor/LexicalEditor.js +10 -6
- package/admin/components/LexicalCmsEditor/LexicalEditor.js.map +1 -1
- package/admin/components/LexicalCmsEditor/TypographyDropDown.js +3 -2
- package/admin/components/LexicalCmsEditor/TypographyDropDown.js.map +1 -1
- package/admin/components/ModelFieldProvider/ModelFieldContext.d.ts +1 -0
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.d.ts +60 -2
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js +18 -5
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js.map +1 -1
- package/admin/config/contentEntries/editor/NewEntryWizard.d.ts +8 -1
- package/admin/config/contentEntries/editor/NewEntryWizard.js +20 -5
- package/admin/config/contentEntries/editor/NewEntryWizard.js.map +1 -1
- package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.d.ts +38 -0
- package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js +23 -0
- package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js.map +1 -0
- package/admin/config/contentEntries/list/Browser/index.d.ts +21 -0
- package/admin/config/contentEntries/list/Browser/index.js +2 -0
- package/admin/config/contentEntries/list/Browser/index.js.map +1 -1
- package/admin/config/contentEntries/list/ContentEntryListConfig.d.ts +39 -0
- package/admin/config/contentEntries/list/ContentEntryListConfig.js +2 -1
- package/admin/config/contentEntries/list/ContentEntryListConfig.js.map +1 -1
- package/admin/graphql/contentModels.d.ts +2 -2
- package/admin/graphql/contentModels.js +3 -1
- package/admin/graphql/contentModels.js.map +1 -1
- package/admin/hooks/usePermission.js +6 -34
- package/admin/hooks/usePermission.js.map +1 -1
- package/admin/plugins/editor/defaultBar/Name/Name.d.ts +0 -5
- package/admin/plugins/editor/defaultBar/Name/Name.js +0 -2
- package/admin/plugins/editor/defaultBar/Name/Name.js.map +1 -1
- package/admin/plugins/editor/formSettings/components/GeneralSettings.js +8 -1
- package/admin/plugins/editor/formSettings/components/GeneralSettings.js.map +1 -1
- package/domain/permissions/checkCmsPermission.d.ts +14 -0
- package/domain/permissions/checkCmsPermission.js +20 -0
- package/domain/permissions/checkCmsPermission.js.map +1 -0
- package/domain/permissions/hasAccessForModel.d.ts +11 -0
- package/domain/permissions/hasAccessForModel.js +20 -0
- package/domain/permissions/hasAccessForModel.js.map +1 -0
- package/domain/permissions/isModelAllowed.d.ts +2 -0
- package/domain/permissions/isModelAllowed.js +11 -0
- package/domain/permissions/isModelAllowed.js.map +1 -0
- package/exports/admin/cms/entry/editor.d.ts +1 -0
- package/exports/admin/cms/entry/editor.js +1 -0
- package/exports/admin/cms/entry/list.d.ts +2 -0
- package/exports/admin/cms/entry/list.js +2 -0
- package/exports/admin/cms.d.ts +2 -0
- package/exports/admin/cms.js +2 -0
- package/features/contentEntry/CmsEntryError.d.ts +10 -0
- package/features/contentEntry/CmsEntryError.js +11 -0
- package/features/contentEntry/CmsEntryError.js.map +1 -0
- package/features/contentEntry/EntryGraphQLFields.js +1 -1
- package/features/contentEntry/EntryGraphQLFields.js.map +1 -1
- package/features/contentEntry/bulkAction/BulkActionGateway.js +6 -1
- package/features/contentEntry/bulkAction/BulkActionGateway.js.map +1 -1
- package/features/contentEntry/bulkAction/BulkActionGateway.test.d.ts +1 -0
- package/features/contentEntry/bulkAction/BulkActionGateway.test.js +134 -0
- package/features/contentEntry/bulkAction/BulkActionGateway.test.js.map +1 -0
- package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
- package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
- package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
- package/features/contentEntry/createEntry/CreateEntryRepository.d.ts +3 -1
- package/features/contentEntry/createEntry/CreateEntryRepository.js +10 -2
- package/features/contentEntry/createEntry/CreateEntryRepository.js.map +1 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.js +6 -1
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.js.map +1 -1
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.d.ts +1 -0
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js +116 -0
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js.map +1 -0
- package/features/contentEntry/deleteEntry/DeleteEntryRepository.d.ts +3 -1
- package/features/contentEntry/deleteEntry/DeleteEntryRepository.js +12 -2
- package/features/contentEntry/deleteEntry/DeleteEntryRepository.js.map +1 -1
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js +6 -1
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js.map +1 -1
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.d.ts +1 -0
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js +112 -0
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
- package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
- package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
- package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
- package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
- package/features/contentEntry/duplicateEntry/feature.js +21 -0
- package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
- package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
- package/features/contentEntry/entryValueGateways.test.js +106 -0
- package/features/contentEntry/entryValueGateways.test.js.map +1 -0
- package/features/contentEntry/feature.js +4 -2
- package/features/contentEntry/feature.js.map +1 -1
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js +6 -1
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js.map +1 -1
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.d.ts +1 -0
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js +130 -0
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js.map +1 -0
- package/features/contentEntry/refTypes.d.ts +7 -0
- package/features/contentEntry/refTypes.js.map +1 -1
- package/features/contentEntry/referenceTitles/ReferenceTitles.d.ts +18 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.js +58 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.js.map +1 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.test.d.ts +1 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.test.js +173 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.test.js.map +1 -0
- package/features/contentEntry/referenceTitles/RememberTitlesDecorators.d.ts +22 -0
- package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js +40 -0
- package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js.map +1 -0
- package/features/contentEntry/referenceTitles/abstractions.d.ts +16 -0
- package/features/contentEntry/referenceTitles/abstractions.js +5 -0
- package/features/contentEntry/referenceTitles/abstractions.js.map +1 -0
- package/features/contentEntry/referenceTitles/feature.d.ts +3 -0
- package/features/contentEntry/referenceTitles/feature.js +20 -0
- package/features/contentEntry/referenceTitles/feature.js.map +1 -0
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
- package/features/contentEntry/updateEntry/UpdateEntryRepository.d.ts +3 -1
- package/features/contentEntry/updateEntry/UpdateEntryRepository.js +10 -2
- package/features/contentEntry/updateEntry/UpdateEntryRepository.js.map +1 -1
- package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js +7 -2
- package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
- package/features/contentEntry/valueTransformers/ObjectValueTransformer.js +16 -2
- package/features/contentEntry/valueTransformers/ObjectValueTransformer.js.map +1 -1
- package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
- package/features/formModel/CmsFormModelBuilder.d.ts +9 -1
- package/features/formModel/CmsFormModelBuilder.js +26 -15
- package/features/formModel/CmsFormModelBuilder.js.map +1 -1
- package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
- package/features/formModel/CmsFormModelBuilder.test.js +465 -0
- package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
- package/features/formModel/CmsLayoutMapper.d.ts +8 -1
- package/features/formModel/CmsLayoutMapper.js +27 -5
- package/features/formModel/CmsLayoutMapper.js.map +1 -1
- package/features/formModel/CmsRefFieldValueFormatter.d.ts +12 -0
- package/features/formModel/CmsRefFieldValueFormatter.js +29 -0
- package/features/formModel/CmsRefFieldValueFormatter.js.map +1 -0
- package/features/formModel/CmsValidationMapper.d.ts +9 -0
- package/features/formModel/CmsValidationMapper.js +25 -19
- package/features/formModel/CmsValidationMapper.js.map +1 -1
- package/features/formModel/feature.js +2 -2
- package/features/formModel/feature.js.map +1 -1
- package/features/formModel/mappers/AssetFieldMapper.d.ts +12 -0
- package/features/formModel/mappers/AssetFieldMapper.js +13 -0
- package/features/formModel/mappers/AssetFieldMapper.js.map +1 -0
- package/features/formModel/mappers/DateTimeFieldMapper.js +3 -0
- package/features/formModel/mappers/DateTimeFieldMapper.js.map +1 -1
- package/features/formModel/mappers/DynamicZoneFieldMapper.js +8 -2
- package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
- package/features/formModel/mappers/ObjectFieldMapper.js +12 -5
- package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
- package/features/formModel/mappers/applyFieldProps.js +2 -1
- package/features/formModel/mappers/applyFieldProps.js.map +1 -1
- package/features/formModel/mappers/applyFieldProps.test.d.ts +1 -0
- package/features/formModel/mappers/applyFieldProps.test.js +59 -0
- package/features/formModel/mappers/applyFieldProps.test.js.map +1 -0
- package/features/formModel/mappers/index.js +2 -0
- package/features/formModel/mappers/index.js.map +1 -1
- package/features/model/deleteModel/DeleteModelGateway.js +6 -1
- package/features/model/deleteModel/DeleteModelGateway.js.map +1 -1
- package/features/model/deleteModel/DeleteModelGateway.test.d.ts +1 -0
- package/features/model/deleteModel/DeleteModelGateway.test.js +71 -0
- package/features/model/deleteModel/DeleteModelGateway.test.js.map +1 -0
- package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
- package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
- package/features/model/exportModels/ExportModelsUseCase.js +7 -1
- package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
- package/features/model/exportModels/abstractions.d.ts +8 -2
- package/features/model/exportModels/abstractions.js.map +1 -1
- package/features/model/updateModel/UpdateModelGateway.js +1 -0
- package/features/model/updateModel/UpdateModelGateway.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +30 -28
- package/presentation/cloneContentModel/CloneContentModelPresenter.d.ts +1 -0
- package/presentation/cloneContentModel/CloneContentModelPresenter.js +8 -6
- package/presentation/cloneContentModel/CloneContentModelPresenter.js.map +1 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.d.ts +1 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js +6 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js.map +1 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.d.ts +1 -0
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js +124 -0
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js.map +1 -0
- package/presentation/contentEntries/bulkActions/abstractions.d.ts +1 -1
- package/presentation/contentEntries/bulkActions/abstractions.js.map +1 -1
- package/presentation/contentEntries/form/ContentEntryFormPresenter.d.ts +2 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.d.ts +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js +107 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js.map +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.js +47 -30
- package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js +244 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js.map +1 -0
- package/presentation/contentEntries/form/abstractions.d.ts +1 -0
- package/presentation/contentEntries/form/abstractions.js.map +1 -1
- package/presentation/contentEntries/form/getFieldBuilders.test.js +4 -2
- package/presentation/contentEntries/form/getFieldBuilders.test.js.map +1 -1
- package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
- package/presentation/contentEntries/form/toFormErrors.js +49 -0
- package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
- package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
- package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
- package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
- package/presentation/contentEntries/list/ContentEntriesDataSource.d.ts +5 -0
- package/presentation/contentEntries/list/ContentEntriesDataSource.js +16 -4
- package/presentation/contentEntries/list/ContentEntriesDataSource.js.map +1 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
- package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
- package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +134 -5
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
- package/presentation/contentEntries/list/abstractions.d.ts +12 -0
- package/presentation/contentEntries/list/abstractions.js.map +1 -1
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.d.ts +7 -0
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js +47 -0
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js.map +1 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +25 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.js +76 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.js +81 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.js.map +1 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.d.ts +2 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +30 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewComponentsContext.d.ts +15 -0
- package/presentation/contentEntries/preview/PreviewComponentsContext.js +43 -0
- package/presentation/contentEntries/preview/PreviewComponentsContext.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewDecorator.d.ts +2 -0
- package/presentation/contentEntries/preview/PreviewDecorator.js +68 -0
- package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.d.ts +10 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.js +19 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewPane.d.ts +18 -0
- package/presentation/contentEntries/preview/PreviewPane.js +217 -0
- package/presentation/contentEntries/preview/PreviewPane.js.map +1 -0
- package/presentation/contentEntries/preview/abstractions.d.ts +24 -0
- package/presentation/contentEntries/preview/abstractions.js +5 -0
- package/presentation/contentEntries/preview/abstractions.js.map +1 -0
- package/presentation/contentEntries/preview/feature.d.ts +3 -0
- package/presentation/contentEntries/preview/feature.js +17 -0
- package/presentation/contentEntries/preview/feature.js.map +1 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +26 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.js +81 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.d.ts +1 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.js +127 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.js.map +1 -0
- package/presentation/contentEntries/preview/useLivePreviewPresenter.d.ts +1 -0
- package/presentation/contentEntries/preview/useLivePreviewPresenter.js +8 -0
- package/presentation/contentEntries/preview/useLivePreviewPresenter.js.map +1 -0
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.d.ts +21 -2
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js +143 -6
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js.map +1 -1
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js +384 -0
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js.map +1 -0
- package/presentation/contentEntries/revisionsList/abstractions.d.ts +16 -0
- package/presentation/contentEntries/revisionsList/abstractions.js.map +1 -1
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +9 -4
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js +122 -0
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js.map +1 -0
- package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
- package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.d.ts +13 -0
- package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js +54 -0
- package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js.map +1 -0
- package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntriesListLayout.js +4 -2
- package/presentation/contentEntries/views/ContentEntriesListLayout.js.map +1 -1
- package/presentation/contentEntries/views/ContentEntriesView.js +2 -0
- package/presentation/contentEntries/views/ContentEntriesView.js.map +1 -1
- package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntryFormView.js +8 -6
- package/presentation/contentEntries/views/ContentEntryFormView.js.map +1 -1
- package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +4 -0
- package/presentation/contentEntries/views/OlderRevisionAlert.js +43 -0
- package/presentation/contentEntries/views/OlderRevisionAlert.js.map +1 -0
- package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
- package/presentation/contentEntries/views/RevisionDrawer.js +4 -0
- package/presentation/contentEntries/views/RevisionDrawer.js.map +1 -1
- package/presentation/contentEntries/views/RevisionListItem.d.ts +3 -3
- package/presentation/contentEntries/views/RevisionListItem.js +82 -14
- package/presentation/contentEntries/views/RevisionListItem.js.map +1 -1
- package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
- package/presentation/contentEntries/views/RevisionsList.js +3 -3
- package/presentation/contentEntries/views/RevisionsList.js.map +1 -1
- package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
- package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js +11 -0
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js.map +1 -1
- package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
- package/presentation/contentEntries/views/layout/ContentEntryFormContent.d.ts +10 -6
- package/presentation/contentEntries/views/layout/ContentEntryFormContent.js +7 -2
- package/presentation/contentEntries/views/layout/ContentEntryFormContent.js.map +1 -1
- package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
- package/presentation/contentModels/ContentModelsPresenter.js +1 -1
- package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
- package/presentation/contentModels/abstractions.d.ts +7 -2
- package/presentation/contentModels/abstractions.js.map +1 -1
- package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/ContentModels.d.ts +2 -2
- package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
- package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
- package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
- package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js +8 -3
- package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js.map +1 -1
- package/presentation/contentModels/components/fullDelete/dialog/Content.js +7 -2
- package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
- package/presentation/contentModels/components/fullDelete/dialog/Content.test.d.ts +1 -0
- package/presentation/contentModels/components/fullDelete/dialog/Content.test.js +54 -0
- package/presentation/contentModels/components/fullDelete/dialog/Content.test.js.map +1 -0
- package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.d.ts +25 -0
- package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js +9 -0
- package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js.map +1 -0
- package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
- package/presentation/fieldEditor/FieldEditorPresenter.js +1 -1
- package/presentation/fieldEditor/FieldEditorPresenter.js.map +1 -1
- package/presentation/fieldEditor/groups/AppearanceGroup.js +12 -0
- package/presentation/fieldEditor/groups/AppearanceGroup.js.map +1 -1
- package/presentation/fieldEditor/groups/GeneralGroup.d.ts +5 -5
- package/presentation/fieldEditor/groups/GeneralGroup.js +5 -1
- package/presentation/fieldEditor/groups/GeneralGroup.js.map +1 -1
- package/presentation/fieldEditor/groups/GeneralGroup.test.d.ts +1 -0
- package/presentation/fieldEditor/groups/GeneralGroup.test.js +68 -0
- package/presentation/fieldEditor/groups/GeneralGroup.test.js.map +1 -0
- package/presentation/fieldEditor/groups/ValidationsGroup.d.ts +2 -0
- package/presentation/fieldEditor/groups/ValidationsGroup.js +21 -7
- package/presentation/fieldEditor/groups/ValidationsGroup.js.map +1 -1
- package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js +3 -3
- package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js.map +1 -1
- package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js +2 -2
- package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js.map +1 -1
- package/presentation/fieldRenderers/feature.js +2 -1
- package/presentation/fieldRenderers/feature.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js +8 -0
- package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js +8 -0
- package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js +1 -0
- package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js +1 -0
- package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.d.ts +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js +8 -2
- package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.d.ts +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js +185 -0
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js.map +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/components/EditEntryDrawer.d.ts +10 -0
- package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js +94 -0
- package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js.map +1 -0
- package/presentation/fieldRenderers/ref/components/EntryCard.d.ts +2 -0
- package/presentation/fieldRenderers/ref/components/EntryCard.js +13 -3
- package/presentation/fieldRenderers/ref/components/EntryCard.js.map +1 -1
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
- package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.d.ts +2 -1
- package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js +6 -0
- package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/detailed/abstractions.d.ts +2 -1
- package/presentation/fieldRenderers/ref/detailed/abstractions.js.map +1 -1
- package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.d.ts +13 -0
- package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js +25 -0
- package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js.map +1 -0
- package/presentation/fieldRenderers/ref/editEntry/abstractions.d.ts +10 -0
- package/presentation/fieldRenderers/ref/editEntry/abstractions.js +5 -0
- package/presentation/fieldRenderers/ref/editEntry/abstractions.js.map +1 -0
- package/presentation/fieldRenderers/ref/editEntry/feature.d.ts +3 -0
- package/presentation/fieldRenderers/ref/editEntry/feature.js +17 -0
- package/presentation/fieldRenderers/ref/editEntry/feature.js.map +1 -0
- package/presentation/fieldTypes/abstractions.d.ts +12 -0
- package/presentation/fieldTypes/abstractions.js.map +1 -1
- package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js +1 -1
- package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js.map +1 -1
- package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.d.ts +15 -0
- package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js +19 -0
- package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js.map +1 -0
- package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js +6 -2
- package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js.map +1 -1
- package/presentation/fieldTypes/renderers/index.d.ts +1 -0
- package/presentation/fieldTypes/renderers/index.js +1 -0
- package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js +2 -0
- package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js.map +1 -1
- package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js +6 -0
- package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js.map +1 -1
- package/presentation/fieldTypes/types/DynamicZoneFieldType.d.ts +3 -6
- package/presentation/fieldTypes/types/DynamicZoneFieldType.js +2 -12
- package/presentation/fieldTypes/types/DynamicZoneFieldType.js.map +1 -1
- package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js +25 -3
- package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js.map +1 -1
- package/presentation/fieldValidators/abstractions.d.ts +7 -0
- package/presentation/fieldValidators/abstractions.js.map +1 -1
- package/presentation/fieldValidators/validators/DateGteValidator.d.ts +6 -0
- package/presentation/fieldValidators/validators/DateGteValidator.js +17 -25
- package/presentation/fieldValidators/validators/DateGteValidator.js.map +1 -1
- package/presentation/fieldValidators/validators/DateLteValidator.d.ts +6 -0
- package/presentation/fieldValidators/validators/DateLteValidator.js +17 -25
- package/presentation/fieldValidators/validators/DateLteValidator.js.map +1 -1
- package/presentation/fieldValidators/validators/dateLimitSettings.d.ts +20 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.js +124 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.js.map +1 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.test.d.ts +1 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.test.js +111 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.test.js.map +1 -0
- package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
- package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
- package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
- package/presentation/importContentModels/components/DataList.d.ts +2 -2
- package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
- package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
- package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
- package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
- package/presentation/modelGroup/ModelGroupPresenter.d.ts +3 -1
- package/presentation/modelGroup/ModelGroupPresenter.js +8 -11
- package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
- package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
- package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
- package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
- package/presentation/newContentModel/NewContentModelPresenter.d.ts +1 -0
- package/presentation/newContentModel/NewContentModelPresenter.js +8 -6
- package/presentation/newContentModel/NewContentModelPresenter.js.map +1 -1
- package/utils/normalizeIcon.d.ts +4 -0
- package/utils/normalizeIcon.js +9 -6
- package/utils/normalizeIcon.js.map +1 -1
- package/features/formModel/CmsAccessControlRuleEvaluator.d.ts +0 -9
- package/features/formModel/CmsAccessControlRuleEvaluator.js +0 -16
- package/features/formModel/CmsAccessControlRuleEvaluator.js.map +0 -1
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import type { IListPresenter } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
|
|
2
|
-
import type { CmsModel } from "../../types.js";
|
|
2
|
+
import type { CmsGroup, CmsModel } from "../../types.js";
|
|
3
3
|
import type { DeleteModelResult } from "../../features/model/deleteModel/abstractions.js";
|
|
4
4
|
export interface IContentModelsPresenterViewModel {
|
|
5
5
|
loading: boolean;
|
|
6
6
|
models: CmsModel[];
|
|
7
7
|
}
|
|
8
|
+
export interface IContentModelsPresenterExportModelsResponse {
|
|
9
|
+
groups: CmsGroup[];
|
|
10
|
+
models: CmsModel[];
|
|
11
|
+
}
|
|
8
12
|
export interface IContentModelsPresenter {
|
|
9
13
|
readonly vm: IContentModelsPresenterViewModel;
|
|
10
14
|
readonly list: IListPresenter<CmsModel>;
|
|
11
15
|
init(): void;
|
|
12
16
|
deleteModel(modelId: string, confirmation: string): Promise<DeleteModelResult>;
|
|
13
17
|
cancelDelete(modelId: string): Promise<void>;
|
|
14
|
-
exportModels(modelIds?: string[]): Promise<
|
|
18
|
+
exportModels(modelIds?: string[]): Promise<IContentModelsPresenterExportModelsResponse | null>;
|
|
15
19
|
}
|
|
16
20
|
export declare const ContentModelsPresenter: import("@webiny/di").Abstraction<IContentModelsPresenter>;
|
|
17
21
|
export declare namespace ContentModelsPresenter {
|
|
18
22
|
type Interface = IContentModelsPresenter;
|
|
19
23
|
type ViewModel = IContentModelsPresenterViewModel;
|
|
24
|
+
type ExportModelResponse = IContentModelsPresenterExportModelsResponse;
|
|
20
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentModels/abstractions.js","sources":["../../../src/presentation/contentModels/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { IListPresenter } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport type { DeleteModelResult } from \"~/features/model/deleteModel/abstractions.js\";\n\nexport interface IContentModelsPresenterViewModel {\n loading: boolean;\n models: CmsModel[];\n}\n\nexport interface IContentModelsPresenter {\n readonly vm: IContentModelsPresenterViewModel;\n readonly list: IListPresenter<CmsModel>;\n init(): void;\n deleteModel(modelId: string, confirmation: string): Promise<DeleteModelResult>;\n cancelDelete(modelId: string): Promise<void>;\n exportModels(modelIds?: string[]): Promise<
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/abstractions.js","sources":["../../../src/presentation/contentModels/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { IListPresenter } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport type { CmsGroup, CmsModel } from \"~/types.js\";\nimport type { DeleteModelResult } from \"~/features/model/deleteModel/abstractions.js\";\n\nexport interface IContentModelsPresenterViewModel {\n loading: boolean;\n models: CmsModel[];\n}\n\nexport interface IContentModelsPresenterExportModelsResponse {\n groups: CmsGroup[];\n models: CmsModel[];\n}\n\nexport interface IContentModelsPresenter {\n readonly vm: IContentModelsPresenterViewModel;\n readonly list: IListPresenter<CmsModel>;\n init(): void;\n deleteModel(modelId: string, confirmation: string): Promise<DeleteModelResult>;\n cancelDelete(modelId: string): Promise<void>;\n exportModels(modelIds?: string[]): Promise<IContentModelsPresenterExportModelsResponse | null>;\n}\n\nexport const ContentModelsPresenter = createAbstraction<IContentModelsPresenter>(\n \"CmsContentModels/Presenter\"\n);\n\nexport namespace ContentModelsPresenter {\n export type Interface = IContentModelsPresenter;\n export type ViewModel = IContentModelsPresenterViewModel;\n export type ExportModelResponse = IContentModelsPresenterExportModelsResponse;\n}\n"],"names":["ContentModelsPresenter","createAbstraction"],"mappings":";AAwBO,MAAMA,yBAAyBC,kBAClC"}
|
|
@@ -5,7 +5,7 @@ interface CloneContentModelDialogProps {
|
|
|
5
5
|
contentModel: CmsModel;
|
|
6
6
|
closeModal: () => void;
|
|
7
7
|
}
|
|
8
|
-
export declare const CloneContentModelDialog: (({ onClose, contentModel, closeModal }: CloneContentModelDialogProps) => React.JSX.Element) & {
|
|
9
|
-
|
|
8
|
+
export declare const CloneContentModelDialog: (({ onClose, contentModel, closeModal }: CloneContentModelDialogProps) => React.JSX.Element) & React.NamedExoticComponent<CloneContentModelDialogProps> & {
|
|
9
|
+
readonly type: ({ onClose, contentModel, closeModal }: CloneContentModelDialogProps) => React.JSX.Element;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
declare const ContentModels: (() => React.JSX.Element) & {
|
|
3
|
-
|
|
2
|
+
declare const ContentModels: (() => React.JSX.Element) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element;
|
|
4
4
|
};
|
|
5
5
|
export default ContentModels;
|
|
@@ -6,7 +6,7 @@ interface ContentModelsDataListProps {
|
|
|
6
6
|
onClone: (contentModel: CmsModel) => void;
|
|
7
7
|
showImportModelModal: () => void;
|
|
8
8
|
}
|
|
9
|
-
declare const ContentModelsDataList: (({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => React.JSX.Element) & {
|
|
10
|
-
|
|
9
|
+
declare const ContentModelsDataList: (({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => React.JSX.Element) & React.NamedExoticComponent<ContentModelsDataListProps> & {
|
|
10
|
+
readonly type: ({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => React.JSX.Element;
|
|
11
11
|
};
|
|
12
12
|
export default ContentModelsDataList;
|
|
@@ -48,7 +48,8 @@ const deserializeSorters = (data)=>{
|
|
|
48
48
|
];
|
|
49
49
|
};
|
|
50
50
|
const DisplayIcon = ({ model })=>{
|
|
51
|
-
|
|
51
|
+
const icon = normalizeIcon(model.icon);
|
|
52
|
+
if (!icon) return null;
|
|
52
53
|
return /*#__PURE__*/ react.createElement("div", {
|
|
53
54
|
className: "text-neutral-muted"
|
|
54
55
|
}, /*#__PURE__*/ react.createElement(Icon, {
|
|
@@ -56,7 +57,7 @@ const DisplayIcon = ({ model })=>{
|
|
|
56
57
|
color: "inherit",
|
|
57
58
|
label: "Content model icon",
|
|
58
59
|
icon: /*#__PURE__*/ react.createElement(FontAwesomeIcon, {
|
|
59
|
-
icon:
|
|
60
|
+
icon: icon
|
|
60
61
|
})
|
|
61
62
|
}));
|
|
62
63
|
};
|
|
@@ -104,10 +105,10 @@ const ContentModelsDataList = observer(({ canCreate, onCreate, onClone, showImpo
|
|
|
104
105
|
(async ()=>{
|
|
105
106
|
try {
|
|
106
107
|
const data = await presenter.exportModels(modelIds);
|
|
107
|
-
if (!data
|
|
108
|
+
if (!data?.models?.length) return void showSnackbar("No data returned from the export query.");
|
|
108
109
|
download(data);
|
|
109
|
-
} catch (
|
|
110
|
-
showSnackbar(
|
|
110
|
+
} catch (ex) {
|
|
111
|
+
showSnackbar(ex.message);
|
|
111
112
|
}
|
|
112
113
|
})();
|
|
113
114
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentModels/components/ContentModelsDataList.js","sources":["../../../../src/presentation/contentModels/components/ContentModelsDataList.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport orderBy from \"lodash/orderBy.js\";\nimport { TimeAgo } from \"@webiny/admin-ui\";\nimport { SearchUI, useRouter, useSnackbar } from \"@webiny/app-admin\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport {\n ReactComponent as DownloadFileIcon,\n ReactComponent as ExportIcon\n} from \"@webiny/icons/file_download.svg\";\nimport { ReactComponent as UploadFileIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as ListIcon } from \"@webiny/icons/list.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as MoreVertIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as CloneIcon } from \"@webiny/icons/flip_to_front.svg\";\nimport { DataList, DataListModal, List } from \"@webiny/admin-ui\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport { usePermission } from \"~/admin/hooks/usePermission.js\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport type { IconProp } from \"@fortawesome/fontawesome-svg-core\";\nimport { ModelIsBeingDeleted } from \"./fullDelete/ModelIsBeingDeleted.js\";\nimport { FullyDeleteModelDialog } from \"./fullDelete/FullyDeleteModelDialog.js\";\nimport { Button, DropdownMenu, Icon, IconButton, Select, Tooltip } from \"@webiny/admin-ui\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/app-headless-cms-common\";\nimport { Routes } from \"~/routes.js\";\nimport { normalizeIcon } from \"~/utils/normalizeIcon.js\";\nimport { useContentModelsPresenter } from \"../useContentModelsPresenter.js\";\nimport { download } from \"../utils/download.js\";\n\nconst t = i18n.namespace(\"FormsApp.ContentModelsDataList\");\n\nconst SORTERS = [\n { label: \"Newest to oldest\", sorter: \"savedOn_DESC\" },\n { label: \"Oldest to newest\", sorter: \"savedOn_ASC\" },\n { label: \"Name A-Z\", sorter: \"name_ASC\" },\n { label: \"Name Z-A\", sorter: \"name_DESC\" }\n];\n\nconst deserializeSorters = (data: string): [string, \"asc\" | \"desc\"] => {\n const [field, order] = data.split(\"_\");\n return [field, order.toLowerCase() === \"asc\" ? \"asc\" : \"desc\"];\n};\n\ninterface ContentModelsDataListProps {\n canCreate: boolean;\n onCreate: () => void;\n onClone: (contentModel: CmsModel) => void;\n showImportModelModal: () => void;\n}\n\ninterface IconProps {\n model: Pick<CmsModel, \"icon\">;\n}\n\nconst DisplayIcon = ({ model }: IconProps) => {\n if (!model.icon) {\n return null;\n }\n return (\n <div className={\"text-neutral-muted\"}>\n <Icon\n size={\"lg\"}\n color={\"inherit\"}\n label={\"Content model icon\"}\n icon={<FontAwesomeIcon icon={normalizeIcon(model.icon) as IconProp} />}\n />\n </div>\n );\n};\n\nconst ContentModelsDataList = observer(\n ({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => {\n const presenter = useContentModelsPresenter();\n const { goToRoute } = useRouter();\n const { showSnackbar } = useSnackbar();\n const { canDelete, canEdit } = usePermission();\n\n const [filter, setFilter] = useState(\"\");\n const [sort, setSort] = useState(SORTERS[0].sorter);\n const [modelToBeDeleted, setModelToBeDeleted] = useState<CmsModel | null>(null);\n\n const models = presenter.vm.models;\n const loading = presenter.vm.loading;\n\n const filteredData = useMemo(() => {\n if (filter === \"\") {\n return models;\n }\n const lc = filter.toLowerCase();\n return models.filter((m: CmsModel) => m.name.toLowerCase().includes(lc));\n }, [models, filter]);\n\n const sortedData = useMemo(() => {\n if (!sort) {\n return filteredData;\n }\n const [key, order] = deserializeSorters(sort);\n return orderBy(filteredData, [key], [order]);\n }, [filteredData, sort]);\n\n const editRecord = (contentModel: CmsModel): void => {\n goToRoute(Routes.ContentModels.Editor, { modelId: contentModel.modelId });\n };\n\n const viewContentEntries = useCallback((contentModel: Pick<CmsModel, \"modelId\">) => {\n return () => {\n goToRoute(Routes.ContentEntries.List, { modelId: contentModel.modelId });\n };\n }, []);\n\n const handleModelsExport = useCallback(\n (modelIds?: string[]) => {\n (async () => {\n try {\n const data = await presenter.exportModels(modelIds);\n if (!data || !data.models || data.models.length === 0) {\n showSnackbar(\"No data returned from the export query.\");\n return;\n }\n download(data);\n } catch (e: any) {\n showSnackbar(e.message);\n }\n })();\n },\n [presenter]\n );\n\n const handleModelExport = useCallback(\n (model: CmsModel) => {\n return () => {\n handleModelsExport([model.modelId]);\n };\n },\n [handleModelsExport]\n );\n\n return (\n <>\n <DataList\n loading={loading}\n data={sortedData}\n title={t`Content Models`}\n actions={\n <div className={\"flex items-center justify-end gap-xs\"}>\n <Tooltip\n content={\"Export all models\"}\n trigger={\n <IconButton\n icon={<DownloadFileIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n onClick={() => handleModelsExport()}\n />\n }\n />\n <Tooltip\n content={\"Import models\"}\n trigger={\n <IconButton\n icon={<UploadFileIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n onClick={() => showImportModelModal()}\n />\n }\n />\n {canCreate ? (\n <Button\n data-testid=\"new-record-button\"\n onClick={onCreate}\n text={t`New`}\n icon={<AddIcon />}\n size={\"sm\"}\n className={\"ml-xs\"}\n />\n ) : null}\n </div>\n }\n search={\n <SearchUI\n value={filter}\n onChange={setFilter}\n inputPlaceholder={t`Search content model...`}\n />\n }\n modalOverlay={\n <DataListModal.Content>\n <Select\n value={sort}\n onChange={setSort}\n label={t`Sort by`}\n options={SORTERS.map(({ label, sorter: value }) => ({\n label,\n value\n }))}\n />\n </DataListModal.Content>\n }\n modalOverlayAction={\n <DataListModal.Trigger data-testid={\"default-data-list.filter\"} />\n }\n refresh={null}\n >\n {({ data = [] }: { data: CmsModel[] }) => {\n return (\n <List data-testid=\"default-data-list\">\n {data.map(contentModel => {\n const disableViewContent = contentModel.fields.length === 0;\n const getMessage = () => {\n if (disableViewContent) {\n return \"To view the entries, you first need to add a field and save the model\";\n }\n if (contentModel.tags.includes(CMS_MODEL_SINGLETON_TAG)) {\n return \"View\";\n }\n return \"View entries\";\n };\n\n const canDeleteModel = canDelete(\n contentModel,\n \"cms.contentModel\"\n );\n const canEditModel = canEdit(contentModel, \"cms.contentModel\");\n\n return (\n <List.Item\n key={contentModel.modelId}\n className={\"group/item\"}\n icon={<DisplayIcon model={contentModel} />}\n title={contentModel.name}\n description={t`Last modified: {time}.`({\n time: contentModel.savedOn ? (\n <TimeAgo datetime={contentModel.savedOn} />\n ) : (\n \"N/A\"\n )\n })}\n actions={\n <>\n <ModelIsBeingDeleted model={contentModel}>\n <span\n className={\n \"invisible group-hover/item:visible\"\n }\n >\n <Tooltip\n side={\"top\"}\n content={getMessage()}\n trigger={\n <Button\n text={\"View entries\"}\n icon={<ListIcon />}\n variant={\"secondary\"}\n size={\"sm\"}\n data-testid={\n \"cms-view-content-model-button\"\n }\n onClick={viewContentEntries(\n contentModel\n )}\n disabled={\n disableViewContent\n }\n />\n }\n />\n </span>\n\n {canEditModel && (\n <span\n className={\n \"invisible group-hover/item:visible\"\n }\n >\n <Tooltip\n side={\"top\"}\n content={\n contentModel.plugin\n ? t`Content model is registered via a plugin.`\n : t`Edit content model`\n }\n trigger={\n <Button\n text={\"Edit\"}\n icon={<EditIcon />}\n variant={\"secondary\"}\n size={\"sm\"}\n disabled={\n contentModel.plugin\n }\n onClick={() =>\n editRecord(\n contentModel\n )\n }\n data-testid={\n \"cms-edit-content-model-button\"\n }\n />\n }\n />\n </span>\n )}\n\n <DropdownMenu\n trigger={\n <IconButton\n icon={<MoreVertIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n />\n }\n >\n {canEditModel && (\n <DropdownMenu.Item\n text={\"Clone\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Clone\"}\n element={<CloneIcon />}\n />\n }\n data-testid={\n \"cms-clone-content-model-button\"\n }\n onClick={() =>\n onClone(contentModel)\n }\n />\n )}\n\n <DropdownMenu.Item\n text={\"Export\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Export\"}\n element={<ExportIcon />}\n />\n }\n data-testid={\n \"cms-export-content-model-button\"\n }\n onClick={handleModelExport(\n contentModel\n )}\n />\n\n {canDeleteModel && (\n <DropdownMenu.Item\n text={\"Delete\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Delete\"}\n element={<DeleteIcon />}\n />\n }\n onClick={() => {\n setModelToBeDeleted(\n contentModel\n );\n }}\n data-testid={\n \"cms-delete-content-model-button\"\n }\n className={\n \"text-destructive-primary! [&_svg]:fill-destructive\"\n }\n />\n )}\n </DropdownMenu>\n </ModelIsBeingDeleted>\n </>\n }\n />\n );\n })}\n </List>\n );\n }}\n </DataList>\n {modelToBeDeleted ? (\n <FullyDeleteModelDialog\n model={modelToBeDeleted}\n onClose={() => {\n setModelToBeDeleted(null);\n }}\n />\n ) : null}\n </>\n );\n }\n);\n\nexport default ContentModelsDataList;\n"],"names":["t","i18n","SORTERS","deserializeSorters","data","field","order","DisplayIcon","model","Icon","FontAwesomeIcon","normalizeIcon","ContentModelsDataList","observer","canCreate","onCreate","onClone","showImportModelModal","presenter","useContentModelsPresenter","goToRoute","useRouter","showSnackbar","useSnackbar","canDelete","canEdit","usePermission","filter","setFilter","useState","sort","setSort","modelToBeDeleted","setModelToBeDeleted","models","loading","filteredData","useMemo","lc","m","sortedData","key","orderBy","editRecord","contentModel","Routes","viewContentEntries","useCallback","handleModelsExport","modelIds","download","e","handleModelExport","DataList","Tooltip","IconButton","DownloadFileIcon","UploadFileIcon","Button","AddIcon","SearchUI","DataListModal","Select","label","value","List","disableViewContent","getMessage","CMS_MODEL_SINGLETON_TAG","canDeleteModel","canEditModel","TimeAgo","ModelIsBeingDeleted","ListIcon","EditIcon","DropdownMenu","MoreVertIcon","CloneIcon","ExportIcon","DeleteIcon","FullyDeleteModelDialog"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAMA,IAAIC,KAAK,SAAS,CAAC;AAEzB,MAAMC,UAAU;IACZ;QAAE,OAAO;QAAoB,QAAQ;IAAe;IACpD;QAAE,OAAO;QAAoB,QAAQ;IAAc;IACnD;QAAE,OAAO;QAAY,QAAQ;IAAW;IACxC;QAAE,OAAO;QAAY,QAAQ;IAAY;CAC5C;AAED,MAAMC,qBAAqB,CAACC;IACxB,MAAM,CAACC,OAAOC,MAAM,GAAGF,KAAK,KAAK,CAAC;IAClC,OAAO;QAACC;QAA+B,UAAxBC,MAAM,WAAW,KAAe,QAAQ;KAAO;AAClE;AAaA,MAAMC,cAAc,CAAC,EAAEC,KAAK,EAAa;IACrC,IA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ation/contentModels/components/ContentModelsDataList.js","sources":["../../../../src/presentation/contentModels/components/ContentModelsDataList.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport orderBy from \"lodash/orderBy.js\";\nimport { TimeAgo } from \"@webiny/admin-ui\";\nimport { SearchUI, useRouter, useSnackbar } from \"@webiny/app-admin\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport {\n ReactComponent as DownloadFileIcon,\n ReactComponent as ExportIcon\n} from \"@webiny/icons/file_download.svg\";\nimport { ReactComponent as UploadFileIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as ListIcon } from \"@webiny/icons/list.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as MoreVertIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as DeleteIcon } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as CloneIcon } from \"@webiny/icons/flip_to_front.svg\";\nimport { DataList, DataListModal, List } from \"@webiny/admin-ui\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport { usePermission } from \"~/admin/hooks/usePermission.js\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport { ModelIsBeingDeleted } from \"./fullDelete/ModelIsBeingDeleted.js\";\nimport { FullyDeleteModelDialog } from \"./fullDelete/FullyDeleteModelDialog.js\";\nimport { Button, DropdownMenu, Icon, IconButton, Select, Tooltip } from \"@webiny/admin-ui\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"@webiny/app-headless-cms-common\";\nimport { Routes } from \"~/routes.js\";\nimport { normalizeIcon } from \"~/utils/normalizeIcon.js\";\nimport { useContentModelsPresenter } from \"../useContentModelsPresenter.js\";\nimport { download } from \"../utils/download.js\";\n\nconst t = i18n.namespace(\"FormsApp.ContentModelsDataList\");\n\nconst SORTERS = [\n { label: \"Newest to oldest\", sorter: \"savedOn_DESC\" },\n { label: \"Oldest to newest\", sorter: \"savedOn_ASC\" },\n { label: \"Name A-Z\", sorter: \"name_ASC\" },\n { label: \"Name Z-A\", sorter: \"name_DESC\" }\n];\n\nconst deserializeSorters = (data: string): [string, \"asc\" | \"desc\"] => {\n const [field, order] = data.split(\"_\");\n return [field, order.toLowerCase() === \"asc\" ? \"asc\" : \"desc\"];\n};\n\ninterface ContentModelsDataListProps {\n canCreate: boolean;\n onCreate: () => void;\n onClone: (contentModel: CmsModel) => void;\n showImportModelModal: () => void;\n}\n\ninterface IconProps {\n model: Pick<CmsModel, \"icon\">;\n}\n\nconst DisplayIcon = ({ model }: IconProps) => {\n const icon = normalizeIcon(model.icon);\n if (!icon) {\n return null;\n }\n return (\n <div className={\"text-neutral-muted\"}>\n <Icon\n size={\"lg\"}\n color={\"inherit\"}\n label={\"Content model icon\"}\n icon={<FontAwesomeIcon icon={icon} />}\n />\n </div>\n );\n};\n\nconst ContentModelsDataList = observer(\n ({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => {\n const presenter = useContentModelsPresenter();\n const { goToRoute } = useRouter();\n const { showSnackbar } = useSnackbar();\n const { canDelete, canEdit } = usePermission();\n\n const [filter, setFilter] = useState(\"\");\n const [sort, setSort] = useState(SORTERS[0].sorter);\n const [modelToBeDeleted, setModelToBeDeleted] = useState<CmsModel | null>(null);\n\n const models = presenter.vm.models;\n const loading = presenter.vm.loading;\n\n const filteredData = useMemo(() => {\n if (filter === \"\") {\n return models;\n }\n const lc = filter.toLowerCase();\n return models.filter((m: CmsModel) => m.name.toLowerCase().includes(lc));\n }, [models, filter]);\n\n const sortedData = useMemo(() => {\n if (!sort) {\n return filteredData;\n }\n const [key, order] = deserializeSorters(sort);\n return orderBy(filteredData, [key], [order]);\n }, [filteredData, sort]);\n\n const editRecord = (contentModel: CmsModel): void => {\n goToRoute(Routes.ContentModels.Editor, { modelId: contentModel.modelId });\n };\n\n const viewContentEntries = useCallback((contentModel: Pick<CmsModel, \"modelId\">) => {\n return () => {\n goToRoute(Routes.ContentEntries.List, { modelId: contentModel.modelId });\n };\n }, []);\n\n const handleModelsExport = useCallback(\n (modelIds?: string[]) => {\n (async () => {\n try {\n const data = await presenter.exportModels(modelIds);\n if (!data?.models?.length) {\n showSnackbar(\"No data returned from the export query.\");\n return;\n }\n download(data);\n } catch (ex: any) {\n showSnackbar(ex.message);\n }\n })();\n },\n [presenter]\n );\n\n const handleModelExport = useCallback(\n (model: CmsModel) => {\n return () => {\n handleModelsExport([model.modelId]);\n };\n },\n [handleModelsExport]\n );\n\n return (\n <>\n <DataList\n loading={loading}\n data={sortedData}\n title={t`Content Models`}\n actions={\n <div className={\"flex items-center justify-end gap-xs\"}>\n <Tooltip\n content={\"Export all models\"}\n trigger={\n <IconButton\n icon={<DownloadFileIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n onClick={() => handleModelsExport()}\n />\n }\n />\n <Tooltip\n content={\"Import models\"}\n trigger={\n <IconButton\n icon={<UploadFileIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n onClick={() => showImportModelModal()}\n />\n }\n />\n {canCreate ? (\n <Button\n data-testid=\"new-record-button\"\n onClick={onCreate}\n text={t`New`}\n icon={<AddIcon />}\n size={\"sm\"}\n className={\"ml-xs\"}\n />\n ) : null}\n </div>\n }\n search={\n <SearchUI\n value={filter}\n onChange={setFilter}\n inputPlaceholder={t`Search content model...`}\n />\n }\n modalOverlay={\n <DataListModal.Content>\n <Select\n value={sort}\n onChange={setSort}\n label={t`Sort by`}\n options={SORTERS.map(({ label, sorter: value }) => ({\n label,\n value\n }))}\n />\n </DataListModal.Content>\n }\n modalOverlayAction={\n <DataListModal.Trigger data-testid={\"default-data-list.filter\"} />\n }\n refresh={null}\n >\n {({ data = [] }: { data: CmsModel[] }) => {\n return (\n <List data-testid=\"default-data-list\">\n {data.map(contentModel => {\n const disableViewContent = contentModel.fields.length === 0;\n const getMessage = () => {\n if (disableViewContent) {\n return \"To view the entries, you first need to add a field and save the model\";\n }\n if (contentModel.tags.includes(CMS_MODEL_SINGLETON_TAG)) {\n return \"View\";\n }\n return \"View entries\";\n };\n\n const canDeleteModel = canDelete(\n contentModel,\n \"cms.contentModel\"\n );\n const canEditModel = canEdit(contentModel, \"cms.contentModel\");\n\n return (\n <List.Item\n key={contentModel.modelId}\n className={\"group/item\"}\n icon={<DisplayIcon model={contentModel} />}\n title={contentModel.name}\n description={t`Last modified: {time}.`({\n time: contentModel.savedOn ? (\n <TimeAgo datetime={contentModel.savedOn} />\n ) : (\n \"N/A\"\n )\n })}\n actions={\n <>\n <ModelIsBeingDeleted model={contentModel}>\n <span\n className={\n \"invisible group-hover/item:visible\"\n }\n >\n <Tooltip\n side={\"top\"}\n content={getMessage()}\n trigger={\n <Button\n text={\"View entries\"}\n icon={<ListIcon />}\n variant={\"secondary\"}\n size={\"sm\"}\n data-testid={\n \"cms-view-content-model-button\"\n }\n onClick={viewContentEntries(\n contentModel\n )}\n disabled={\n disableViewContent\n }\n />\n }\n />\n </span>\n\n {canEditModel && (\n <span\n className={\n \"invisible group-hover/item:visible\"\n }\n >\n <Tooltip\n side={\"top\"}\n content={\n contentModel.plugin\n ? t`Content model is registered via a plugin.`\n : t`Edit content model`\n }\n trigger={\n <Button\n text={\"Edit\"}\n icon={<EditIcon />}\n variant={\"secondary\"}\n size={\"sm\"}\n disabled={\n contentModel.plugin\n }\n onClick={() =>\n editRecord(\n contentModel\n )\n }\n data-testid={\n \"cms-edit-content-model-button\"\n }\n />\n }\n />\n </span>\n )}\n\n <DropdownMenu\n trigger={\n <IconButton\n icon={<MoreVertIcon />}\n size={\"sm\"}\n variant={\"ghost\"}\n />\n }\n >\n {canEditModel && (\n <DropdownMenu.Item\n text={\"Clone\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Clone\"}\n element={<CloneIcon />}\n />\n }\n data-testid={\n \"cms-clone-content-model-button\"\n }\n onClick={() =>\n onClone(contentModel)\n }\n />\n )}\n\n <DropdownMenu.Item\n text={\"Export\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Export\"}\n element={<ExportIcon />}\n />\n }\n data-testid={\n \"cms-export-content-model-button\"\n }\n onClick={handleModelExport(\n contentModel\n )}\n />\n\n {canDeleteModel && (\n <DropdownMenu.Item\n text={\"Delete\"}\n icon={\n <DropdownMenu.Item.Icon\n label={\"Delete\"}\n element={<DeleteIcon />}\n />\n }\n onClick={() => {\n setModelToBeDeleted(\n contentModel\n );\n }}\n data-testid={\n \"cms-delete-content-model-button\"\n }\n className={\n \"text-destructive-primary! [&_svg]:fill-destructive\"\n }\n />\n )}\n </DropdownMenu>\n </ModelIsBeingDeleted>\n </>\n }\n />\n );\n })}\n </List>\n );\n }}\n </DataList>\n {modelToBeDeleted ? (\n <FullyDeleteModelDialog\n model={modelToBeDeleted}\n onClose={() => {\n setModelToBeDeleted(null);\n }}\n />\n ) : null}\n </>\n );\n }\n);\n\nexport default ContentModelsDataList;\n"],"names":["t","i18n","SORTERS","deserializeSorters","data","field","order","DisplayIcon","model","icon","normalizeIcon","Icon","FontAwesomeIcon","ContentModelsDataList","observer","canCreate","onCreate","onClone","showImportModelModal","presenter","useContentModelsPresenter","goToRoute","useRouter","showSnackbar","useSnackbar","canDelete","canEdit","usePermission","filter","setFilter","useState","sort","setSort","modelToBeDeleted","setModelToBeDeleted","models","loading","filteredData","useMemo","lc","m","sortedData","key","orderBy","editRecord","contentModel","Routes","viewContentEntries","useCallback","handleModelsExport","modelIds","download","ex","handleModelExport","DataList","Tooltip","IconButton","DownloadFileIcon","UploadFileIcon","Button","AddIcon","SearchUI","DataListModal","Select","label","value","List","disableViewContent","getMessage","CMS_MODEL_SINGLETON_TAG","canDeleteModel","canEditModel","TimeAgo","ModelIsBeingDeleted","ListIcon","EditIcon","DropdownMenu","MoreVertIcon","CloneIcon","ExportIcon","DeleteIcon","FullyDeleteModelDialog"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMA,IAAIC,KAAK,SAAS,C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oBAACM,aAAa,IAAI;oBACd,MAAM;oBACN,oBACI,oBAACA,aAAa,IAAI,CAAC,IAAI;wBACnB,OAAO;wBACP,uBAAS,oBAACI,2BAAUA;;oBAG5B,SAAS;wBACL9C,oBACIW;oBAER;oBACA,eACI;oBAEJ,WACI;;;QAUxC,MAKfZ,mBAAmB,WAAnBA,GACG,oBAACgD,wBAAsBA;QACnB,OAAOhD;QACP,SAAS;YACLC,oBAAoB;QACxB;SAEJ;AAGhB;AAGJ,yCAAerB"}
|
|
@@ -4,7 +4,7 @@ export interface NewContentModelDialogProps {
|
|
|
4
4
|
open: boolean;
|
|
5
5
|
onClose: DialogProps["onClose"];
|
|
6
6
|
}
|
|
7
|
-
declare const NewContentModelDialog: (({ open, onClose }: NewContentModelDialogProps) => React.JSX.Element) & {
|
|
8
|
-
|
|
7
|
+
declare const NewContentModelDialog: (({ open, onClose }: NewContentModelDialogProps) => React.JSX.Element) & React.NamedExoticComponent<NewContentModelDialogProps> & {
|
|
8
|
+
readonly type: ({ open, onClose }: NewContentModelDialogProps) => React.JSX.Element;
|
|
9
9
|
};
|
|
10
10
|
export default NewContentModelDialog;
|
|
@@ -6,6 +6,11 @@ import { Content } from "./dialog/Content.js";
|
|
|
6
6
|
import { createValidationValue } from "./dialog/validationValue.js";
|
|
7
7
|
import { useDialogState } from "./dialog/state.js";
|
|
8
8
|
import { useContentModelsPresenter } from "../../useContentModelsPresenter.js";
|
|
9
|
+
const getCancelText = (status)=>{
|
|
10
|
+
if (status === FullyDeleteModelStateStatus.PROCESSED) return "OK";
|
|
11
|
+
if (status === FullyDeleteModelStateStatus.ERROR) return "Close";
|
|
12
|
+
return "Cancel";
|
|
13
|
+
};
|
|
9
14
|
const FullyDeleteModelDialog = ({ model: inputModel, onClose })=>{
|
|
10
15
|
const presenter = useContentModelsPresenter();
|
|
11
16
|
const state = useDialogState(inputModel);
|
|
@@ -24,8 +29,8 @@ const FullyDeleteModelDialog = ({ model: inputModel, onClose })=>{
|
|
|
24
29
|
} catch (ex) {
|
|
25
30
|
setStatusError({
|
|
26
31
|
message: ex.message,
|
|
27
|
-
code: "FULLY_DELETE_MODEL_ERROR",
|
|
28
|
-
data: {}
|
|
32
|
+
code: ex.code ?? "FULLY_DELETE_MODEL_ERROR",
|
|
33
|
+
data: ex.data ?? {}
|
|
29
34
|
});
|
|
30
35
|
}
|
|
31
36
|
})();
|
|
@@ -60,7 +65,7 @@ const FullyDeleteModelDialog = ({ model: inputModel, onClose })=>{
|
|
|
60
65
|
title: title,
|
|
61
66
|
actions: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(admin_ui_Dialog.CancelAction, {
|
|
62
67
|
"data-testid": "cms-delete-content-model-close-button",
|
|
63
|
-
text: status
|
|
68
|
+
text: getCancelText(status)
|
|
64
69
|
}), (status === FullyDeleteModelStateStatus.NONE || status === FullyDeleteModelStateStatus.UNDERSTOOD) && /*#__PURE__*/ react.createElement(Button, {
|
|
65
70
|
variant: "primary",
|
|
66
71
|
"data-testid": "cms-delete-content-model-confirm-button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js","sources":["../../../../../src/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\nimport { Dialog } from \"~/admin/components/Dialog.js\";\nimport { Dialog as AdminUiDialog } from \"@webiny/admin-ui\";\nimport { Button } from \"@webiny/admin-ui\";\nimport type { CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"./types.js\";\nimport { Content } from \"./dialog/Content.js\";\nimport { createValidationValue } from \"./dialog/validationValue.js\";\nimport { useDialogState } from \"./dialog/state.js\";\nimport { useContentModelsPresenter } from \"~/presentation/contentModels/useContentModelsPresenter.js\";\n\nexport interface FullyDeleteModelDialogProps {\n model: CmsModel;\n onClose: () => void;\n}\n\nexport const FullyDeleteModelDialog = ({\n model: inputModel,\n onClose\n}: FullyDeleteModelDialogProps) => {\n const presenter = useContentModelsPresenter();\n const state = useDialogState(inputModel);\n\n const {\n model,\n status,\n confirmation,\n setConfirmation,\n setStatusUnderstood,\n setStatusProcessed,\n setStatusConfirmed,\n setStatusError,\n setError\n } = state;\n\n const startProcessing = useCallback(() => {\n const value = createValidationValue(model!);\n if (confirmation !== value) {\n setError({\n message: \"Confirmation value is not correct.\",\n code: \"CONFIRMATION_ERROR\"\n });\n return;\n }\n setStatusConfirmed();\n\n (async () => {\n try {\n const result = await presenter.deleteModel(model!.modelId, confirmation);\n setStatusProcessed(result);\n } catch (ex: any) {\n setStatusError({\n message: ex.message,\n code: \"FULLY_DELETE_MODEL_ERROR\",\n data: {}\n });\n }\n })();\n }, [state]);\n\n const title = useMemo(() => {\n if (model.plugin) {\n return \"Delete all entries of the model?\";\n }\n return \"Delete content model and all its entries?\";\n }, [model.modelId]);\n\n const primaryButtonText = useMemo(() => {\n if (status === FullyDeleteModelStateStatus.UNDERSTOOD) {\n return \"Yes, delete the model\";\n }\n return \"Yes, I understand\";\n }, [status]);\n\n const onYesClick = useMemo(() => {\n if (status === FullyDeleteModelStateStatus.NONE) {\n return setStatusUnderstood;\n }\n return startProcessing;\n }, [setStatusUnderstood, startProcessing, status]);\n\n return (\n <Dialog\n open={!!model}\n onClose={onClose}\n dismissible={false}\n data-testid=\"cms-delete-content-model-dialog\"\n title={title}\n actions={\n <>\n <AdminUiDialog.CancelAction\n data-testid=\"cms-delete-content-model-close-button\"\n text={
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js","sources":["../../../../../src/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\nimport { Dialog } from \"~/admin/components/Dialog.js\";\nimport { Dialog as AdminUiDialog } from \"@webiny/admin-ui\";\nimport { Button } from \"@webiny/admin-ui\";\nimport type { CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"./types.js\";\nimport { Content } from \"./dialog/Content.js\";\nimport { createValidationValue } from \"./dialog/validationValue.js\";\nimport { useDialogState } from \"./dialog/state.js\";\nimport { useContentModelsPresenter } from \"~/presentation/contentModels/useContentModelsPresenter.js\";\n\nexport interface FullyDeleteModelDialogProps {\n model: CmsModel;\n onClose: () => void;\n}\n\nconst getCancelText = (status: FullyDeleteModelStateStatus): string => {\n if (status === FullyDeleteModelStateStatus.PROCESSED) {\n return \"OK\";\n }\n if (status === FullyDeleteModelStateStatus.ERROR) {\n return \"Close\";\n }\n return \"Cancel\";\n};\n\nexport const FullyDeleteModelDialog = ({\n model: inputModel,\n onClose\n}: FullyDeleteModelDialogProps) => {\n const presenter = useContentModelsPresenter();\n const state = useDialogState(inputModel);\n\n const {\n model,\n status,\n confirmation,\n setConfirmation,\n setStatusUnderstood,\n setStatusProcessed,\n setStatusConfirmed,\n setStatusError,\n setError\n } = state;\n\n const startProcessing = useCallback(() => {\n const value = createValidationValue(model!);\n if (confirmation !== value) {\n setError({\n message: \"Confirmation value is not correct.\",\n code: \"CONFIRMATION_ERROR\"\n });\n return;\n }\n setStatusConfirmed();\n\n (async () => {\n try {\n const result = await presenter.deleteModel(model!.modelId, confirmation);\n setStatusProcessed(result);\n } catch (ex: any) {\n setStatusError({\n message: ex.message,\n code: ex.code ?? \"FULLY_DELETE_MODEL_ERROR\",\n data: ex.data ?? {}\n });\n }\n })();\n }, [state]);\n\n const title = useMemo(() => {\n if (model.plugin) {\n return \"Delete all entries of the model?\";\n }\n return \"Delete content model and all its entries?\";\n }, [model.modelId]);\n\n const primaryButtonText = useMemo(() => {\n if (status === FullyDeleteModelStateStatus.UNDERSTOOD) {\n return \"Yes, delete the model\";\n }\n return \"Yes, I understand\";\n }, [status]);\n\n const onYesClick = useMemo(() => {\n if (status === FullyDeleteModelStateStatus.NONE) {\n return setStatusUnderstood;\n }\n return startProcessing;\n }, [setStatusUnderstood, startProcessing, status]);\n\n return (\n <Dialog\n open={!!model}\n onClose={onClose}\n dismissible={false}\n data-testid=\"cms-delete-content-model-dialog\"\n title={title}\n actions={\n <>\n <AdminUiDialog.CancelAction\n data-testid=\"cms-delete-content-model-close-button\"\n text={getCancelText(status)}\n />\n {(status === FullyDeleteModelStateStatus.NONE ||\n status === FullyDeleteModelStateStatus.UNDERSTOOD) && (\n <Button\n variant={\"primary\"}\n data-testid=\"cms-delete-content-model-confirm-button\"\n onClick={onYesClick}\n >\n {primaryButtonText}\n </Button>\n )}\n </>\n }\n >\n <Content\n model={model}\n setConfirmation={setConfirmation}\n confirmation={confirmation}\n error={state.error}\n status={status}\n />\n </Dialog>\n );\n};\n"],"names":["getCancelText","status","FullyDeleteModelStateStatus","FullyDeleteModelDialog","inputModel","onClose","presenter","useContentModelsPresenter","state","useDialogState","model","confirmation","setConfirmation","setStatusUnderstood","setStatusProcessed","setStatusConfirmed","setStatusError","setError","startProcessing","useCallback","value","createValidationValue","result","ex","title","useMemo","primaryButtonText","onYesClick","Dialog","AdminUiDialog","Button","Content"],"mappings":";;;;;;;;AAgBA,MAAMA,gBAAgB,CAACC;IACnB,IAAIA,WAAWC,4BAA4B,SAAS,EAChD,OAAO;IAEX,IAAID,WAAWC,4BAA4B,KAAK,EAC5C,OAAO;IAEX,OAAO;AACX;AAEO,MAAMC,yBAAyB,CAAC,EACnC,OAAOC,UAAU,EACjBC,OAAO,EACmB;IAC1B,MAAMC,YAAYC;IAClB,MAAMC,QAAQC,eAAeL;IAE7B,MAAM,EACFM,KAAK,EACLT,MAAM,EACNU,YAAY,EACZC,eAAe,EACfC,mBAAmB,EACnBC,kBAAkB,EAClBC,kBAAkB,EAClBC,cAAc,EACdC,QAAQ,EACX,GAAGT;IAEJ,MAAMU,kBAAkBC,YAAY;QAChC,MAAMC,QAAQC,sBAAsBX;QACpC,IAAIC,iBAAiBS,OAAO,YACxBH,SAAS;YACL,SAAS;YACT,MAAM;QACV;QAGJF;QAEC;YACG,IAAI;gBACA,MAAMO,SAAS,MAAMhB,UAAU,WAAW,CAACI,MAAO,OAAO,EAAEC;gBAC3DG,mBAAmBQ;YACvB,EAAE,OAAOC,IAAS;gBACdP,eAAe;oBACX,SAASO,GAAG,OAAO;oBACnB,MAAMA,GAAG,IAAI,IAAI;oBACjB,MAAMA,GAAG,IAAI,IAAI,CAAC;gBACtB;YACJ;QACJ;IACJ,GAAG;QAACf;KAAM;IAEV,MAAMgB,QAAQC,QAAQ;QAClB,IAAIf,MAAM,MAAM,EACZ,OAAO;QAEX,OAAO;IACX,GAAG;QAACA,MAAM,OAAO;KAAC;IAElB,MAAMgB,oBAAoBD,QAAQ;QAC9B,IAAIxB,WAAWC,4BAA4B,UAAU,EACjD,OAAO;QAEX,OAAO;IACX,GAAG;QAACD;KAAO;IAEX,MAAM0B,aAAaF,QAAQ;QACvB,IAAIxB,WAAWC,4BAA4B,IAAI,EAC3C,OAAOW;QAEX,OAAOK;IACX,GAAG;QAACL;QAAqBK;QAAiBjB;KAAO;IAEjD,OAAO,WAAP,GACI,oBAAC2B,QAAMA;QACH,MAAM,CAAC,CAAClB;QACR,SAASL;QACT,aAAa;QACb,eAAY;QACZ,OAAOmB;QACP,uBACI,wDACI,oBAACK,gBAAAA,YAA0B;YACvB,eAAY;YACZ,MAAM7B,cAAcC;YAEtBA,AAAAA,CAAAA,WAAWC,4BAA4B,IAAI,IACzCD,WAAWC,4BAA4B,UAAS,mBAChD,oBAAC4B,QAAMA;YACH,SAAS;YACT,eAAY;YACZ,SAASH;WAERD;qBAMjB,oBAACK,SAAOA;QACJ,OAAOrB;QACP,iBAAiBE;QACjB,cAAcD;QACd,OAAOH,MAAM,KAAK;QAClB,QAAQP;;AAIxB"}
|
|
@@ -4,14 +4,19 @@ import { Information } from "./Information.js";
|
|
|
4
4
|
import { Confirmation } from "./Confirmation.js";
|
|
5
5
|
import { OverlayLoader } from "@webiny/admin-ui";
|
|
6
6
|
import { Processed } from "./Processed.js";
|
|
7
|
+
import { FullyDeleteModelError } from "./FullyDeleteModelError.js";
|
|
7
8
|
const Content = ({ confirmation, setConfirmation, error, model, status })=>{
|
|
8
9
|
if (!model) return /*#__PURE__*/ react.createElement("p", null, "Model not found.");
|
|
9
|
-
if (status === FullyDeleteModelStateStatus.NONE) return /*#__PURE__*/ react.createElement(Information, {
|
|
10
|
+
else if (status === FullyDeleteModelStateStatus.NONE) return /*#__PURE__*/ react.createElement(Information, {
|
|
10
11
|
model: model
|
|
11
12
|
});
|
|
12
|
-
if (status === FullyDeleteModelStateStatus.PROCESSED) return /*#__PURE__*/ react.createElement(Processed, {
|
|
13
|
+
else if (status === FullyDeleteModelStateStatus.PROCESSED) return /*#__PURE__*/ react.createElement(Processed, {
|
|
13
14
|
model: model
|
|
14
15
|
});
|
|
16
|
+
else if (status === FullyDeleteModelStateStatus.ERROR && error) return /*#__PURE__*/ react.createElement(FullyDeleteModelError, {
|
|
17
|
+
model: model,
|
|
18
|
+
error: error
|
|
19
|
+
});
|
|
15
20
|
return /*#__PURE__*/ react.createElement(react.Fragment, null, status === FullyDeleteModelStateStatus.CONFIRMED && /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
16
21
|
text: "Starting the deletion process..."
|
|
17
22
|
}), /*#__PURE__*/ react.createElement(Confirmation, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentModels/components/fullDelete/dialog/Content.js","sources":["../../../../../../src/presentation/contentModels/components/fullDelete/dialog/Content.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"../types.js\";\nimport { Information } from \"./Information.js\";\nimport { Confirmation } from \"./Confirmation.js\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { Processed } from \"./Processed.js\";\n\nexport interface IContentProps {\n model: CmsModel | null;\n confirmation: string;\n setConfirmation: (value: string) => void;\n error: CmsErrorResponse | null;\n status: FullyDeleteModelStateStatus;\n}\n\nexport const Content = ({ confirmation, setConfirmation, error, model, status }: IContentProps) => {\n if (!model) {\n return <p>Model not found.</p>;\n } else if (status === FullyDeleteModelStateStatus.NONE) {\n return <Information model={model} />;\n } else if (status === FullyDeleteModelStateStatus.PROCESSED) {\n return <Processed model={model} />;\n }\n\n return (\n <>\n {status === FullyDeleteModelStateStatus.CONFIRMED && (\n <OverlayLoader text={\"Starting the deletion process...\"} />\n )}\n <Confirmation\n model={model}\n setConfirmation={setConfirmation}\n confirmation={confirmation}\n error={error}\n />\n </>\n );\n};\n"],"names":["Content","confirmation","setConfirmation","error","model","status","FullyDeleteModelStateStatus","Information","Processed","OverlayLoader","Confirmation"],"mappings":"
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/dialog/Content.js","sources":["../../../../../../src/presentation/contentModels/components/fullDelete/dialog/Content.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"../types.js\";\nimport { Information } from \"./Information.js\";\nimport { Confirmation } from \"./Confirmation.js\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { Processed } from \"./Processed.js\";\nimport { FullyDeleteModelError } from \"./FullyDeleteModelError.js\";\n\nexport interface IContentProps {\n model: CmsModel | null;\n confirmation: string;\n setConfirmation: (value: string) => void;\n error: CmsErrorResponse | null;\n status: FullyDeleteModelStateStatus;\n}\n\nexport const Content = ({ confirmation, setConfirmation, error, model, status }: IContentProps) => {\n if (!model) {\n return <p>Model not found.</p>;\n } else if (status === FullyDeleteModelStateStatus.NONE) {\n return <Information model={model} />;\n } else if (status === FullyDeleteModelStateStatus.PROCESSED) {\n return <Processed model={model} />;\n } else if (status === FullyDeleteModelStateStatus.ERROR && error) {\n // A refused delete ends the dialog: the error replaces the confirmation (QBZ-38).\n return <FullyDeleteModelError model={model} error={error} />;\n }\n\n return (\n <>\n {status === FullyDeleteModelStateStatus.CONFIRMED && (\n <OverlayLoader text={\"Starting the deletion process...\"} />\n )}\n <Confirmation\n model={model}\n setConfirmation={setConfirmation}\n confirmation={confirmation}\n error={error}\n />\n </>\n );\n};\n"],"names":["Content","confirmation","setConfirmation","error","model","status","FullyDeleteModelStateStatus","Information","Processed","FullyDeleteModelError","OverlayLoader","Confirmation"],"mappings":";;;;;;;AAiBO,MAAMA,UAAU,CAAC,EAAEC,YAAY,EAAEC,eAAe,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAiB;IAC1F,IAAI,CAACD,OACD,OAAO,WAAP,GAAO,oBAAC,WAAE;SACP,IAAIC,WAAWC,4BAA4B,IAAI,EAClD,OAAO,WAAP,GAAO,oBAACC,aAAWA;QAAC,OAAOH;;SACxB,IAAIC,WAAWC,4BAA4B,SAAS,EACvD,OAAO,WAAP,GAAO,oBAACE,WAASA;QAAC,OAAOJ;;SACtB,IAAIC,WAAWC,4BAA4B,KAAK,IAAIH,OAEvD,OAAO,WAAP,GAAO,oBAACM,uBAAqBA;QAAC,OAAOL;QAAO,OAAOD;;IAGvD,OAAO,WAAP,GACI,0CACKE,WAAWC,4BAA4B,SAAS,IAAI,WAAJ,GAC7C,oBAACI,eAAaA;QAAC,MAAM;sBAEzB,oBAACC,cAAYA;QACT,OAAOP;QACP,iBAAiBF;QACjB,cAAcD;QACd,OAAOE;;AAIvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import { AdminUiProvider } from "@webiny/admin-ui";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { FullyDeleteModelStateStatus } from "../types.js";
|
|
6
|
+
import { Content } from "./Content.js";
|
|
7
|
+
vi.mock("@webiny/admin-ui", async (importOriginal)=>{
|
|
8
|
+
const actual = await importOriginal();
|
|
9
|
+
return {
|
|
10
|
+
...actual,
|
|
11
|
+
Alert: (props)=>/*#__PURE__*/ react.createElement("div", {
|
|
12
|
+
role: "alert"
|
|
13
|
+
}, props.children)
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
const model = {
|
|
17
|
+
modelId: "article",
|
|
18
|
+
name: "Article"
|
|
19
|
+
};
|
|
20
|
+
describe("Content of the fully delete model dialog", ()=>{
|
|
21
|
+
it("shows only the error after the server refused the delete", ()=>{
|
|
22
|
+
const view = render(/*#__PURE__*/ react.createElement(AdminUiProvider, null, /*#__PURE__*/ react.createElement(Content, {
|
|
23
|
+
model: model,
|
|
24
|
+
confirmation: "delete article",
|
|
25
|
+
setConfirmation: ()=>void 0,
|
|
26
|
+
error: {
|
|
27
|
+
message: "The model is used by a workflow.",
|
|
28
|
+
code: "X",
|
|
29
|
+
data: {}
|
|
30
|
+
},
|
|
31
|
+
status: FullyDeleteModelStateStatus.ERROR
|
|
32
|
+
})));
|
|
33
|
+
expect(view.getByText("The model is used by a workflow.")).toBeTruthy();
|
|
34
|
+
expect(view.queryByText(/Are you sure/)).toBeNull();
|
|
35
|
+
expect(view.queryAllByTestId("cms-delete-content-model-input")).toHaveLength(0);
|
|
36
|
+
});
|
|
37
|
+
it("keeps the confirmation input with a wrong confirmation text", ()=>{
|
|
38
|
+
const view = render(/*#__PURE__*/ react.createElement(AdminUiProvider, null, /*#__PURE__*/ react.createElement(Content, {
|
|
39
|
+
model: model,
|
|
40
|
+
confirmation: "nope",
|
|
41
|
+
setConfirmation: ()=>void 0,
|
|
42
|
+
error: {
|
|
43
|
+
message: "Confirmation value is not correct.",
|
|
44
|
+
code: "CONFIRMATION_ERROR",
|
|
45
|
+
data: {}
|
|
46
|
+
},
|
|
47
|
+
status: FullyDeleteModelStateStatus.UNDERSTOOD
|
|
48
|
+
})));
|
|
49
|
+
expect(view.getByText("Confirmation value is not correct.")).toBeTruthy();
|
|
50
|
+
expect(view.getAllByTestId("cms-delete-content-model-input").length).toBeGreaterThan(0);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=Content.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/dialog/Content.test.js","sources":["../../../../../../src/presentation/contentModels/components/fullDelete/dialog/Content.test.tsx"],"sourcesContent":["/**\n * @vitest-environment jsdom\n */\nimport React from \"react\";\nimport { render } from \"@testing-library/react\";\nimport { AdminUiProvider } from \"@webiny/admin-ui\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport type { CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"../types.js\";\nimport { Content } from \"./Content.js\";\n\ninterface FakeAlertProps {\n children?: React.ReactNode;\n}\n\n// The real Alert renders svg icons, which this package's tests do not load.\nvi.mock(\"@webiny/admin-ui\", async importOriginal => {\n const actual = await importOriginal<typeof import(\"@webiny/admin-ui\")>();\n return {\n ...actual,\n Alert: (props: FakeAlertProps) => <div role={\"alert\"}>{props.children}</div>\n };\n});\n\nconst model = { modelId: \"article\", name: \"Article\" } as CmsModel;\n\ndescribe(\"Content of the fully delete model dialog\", () => {\n it(\"shows only the error after the server refused the delete\", () => {\n const view = render(\n <AdminUiProvider>\n <Content\n model={model}\n confirmation={\"delete article\"}\n setConfirmation={() => undefined}\n error={{ message: \"The model is used by a workflow.\", code: \"X\", data: {} }}\n status={FullyDeleteModelStateStatus.ERROR}\n />\n </AdminUiProvider>\n );\n\n expect(view.getByText(\"The model is used by a workflow.\")).toBeTruthy();\n expect(view.queryByText(/Are you sure/)).toBeNull();\n expect(view.queryAllByTestId(\"cms-delete-content-model-input\")).toHaveLength(0);\n });\n\n it(\"keeps the confirmation input with a wrong confirmation text\", () => {\n const view = render(\n <AdminUiProvider>\n <Content\n model={model}\n confirmation={\"nope\"}\n setConfirmation={() => undefined}\n error={{\n message: \"Confirmation value is not correct.\",\n code: \"CONFIRMATION_ERROR\",\n data: {}\n }}\n status={FullyDeleteModelStateStatus.UNDERSTOOD}\n />\n </AdminUiProvider>\n );\n\n expect(view.getByText(\"Confirmation value is not correct.\")).toBeTruthy();\n expect(view.getAllByTestId(\"cms-delete-content-model-input\").length).toBeGreaterThan(0);\n });\n});\n"],"names":["vi","importOriginal","actual","props","model","describe","it","view","render","AdminUiProvider","Content","undefined","FullyDeleteModelStateStatus","expect"],"mappings":";;;;;;AAmBAA,GAAG,IAAI,CAAC,oBAAoB,OAAMC;IAC9B,MAAMC,SAAS,MAAMD;IACrB,OAAO;QACH,GAAGC,MAAM;QACT,OAAO,CAACC,QAAAA,WAAAA,GAA0B,oBAAC;gBAAI,MAAM;eAAUA,MAAM,QAAQ;IACzE;AACJ;AAEA,MAAMC,QAAQ;IAAE,SAAS;IAAW,MAAM;AAAU;AAEpDC,SAAS,4CAA4C;IACjDC,GAAG,4DAA4D;QAC3D,MAAMC,OAAOC,OAAO,WAADA,GACf,oBAACC,iBAAeA,MAAAA,WAAAA,GACZ,oBAACC,SAAOA;YACJ,OAAON;YACP,cAAc;YACd,iBAAiB,IAAMO;YACvB,OAAO;gBAAE,SAAS;gBAAoC,MAAM;gBAAK,MAAM,CAAC;YAAE;YAC1E,QAAQC,4BAA4B,KAAK;;QAKrDC,OAAON,KAAK,SAAS,CAAC,qCAAqC,UAAU;QACrEM,OAAON,KAAK,WAAW,CAAC,iBAAiB,QAAQ;QACjDM,OAAON,KAAK,gBAAgB,CAAC,mCAAmC,YAAY,CAAC;IACjF;IAEAD,GAAG,+DAA+D;QAC9D,MAAMC,OAAOC,OAAO,WAADA,GACf,oBAACC,iBAAeA,MAAAA,WAAAA,GACZ,oBAACC,SAAOA;YACJ,OAAON;YACP,cAAc;YACd,iBAAiB,IAAMO;YACvB,OAAO;gBACH,SAAS;gBACT,MAAM;gBACN,MAAM,CAAC;YACX;YACA,QAAQC,4BAA4B,UAAU;;QAK1DC,OAAON,KAAK,SAAS,CAAC,uCAAuC,UAAU;QACvEM,OAAON,KAAK,cAAc,CAAC,kCAAkC,MAAM,EAAE,eAAe,CAAC;IACzF;AACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CmsErrorResponse, CmsModel } from "../../../../../types.js";
|
|
3
|
+
export interface FullyDeleteModelErrorProps {
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
error: CmsErrorResponse;
|
|
6
|
+
}
|
|
7
|
+
export declare const FullyDeleteModelError: ((props: FullyDeleteModelErrorProps) => React.JSX.Element) & {
|
|
8
|
+
original: (props: FullyDeleteModelErrorProps) => React.JSX.Element;
|
|
9
|
+
originalName: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
} & {
|
|
12
|
+
original: ((props: FullyDeleteModelErrorProps) => React.JSX.Element) & {
|
|
13
|
+
original: (props: FullyDeleteModelErrorProps) => React.JSX.Element;
|
|
14
|
+
originalName: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
17
|
+
originalName: string;
|
|
18
|
+
displayName: string;
|
|
19
|
+
} & {
|
|
20
|
+
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<((props: FullyDeleteModelErrorProps) => React.JSX.Element) & {
|
|
21
|
+
original: (props: FullyDeleteModelErrorProps) => React.JSX.Element;
|
|
22
|
+
originalName: string;
|
|
23
|
+
displayName: string;
|
|
24
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
25
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { makeDecoratable } from "@webiny/react-composition";
|
|
3
|
+
import { Alert } from "@webiny/admin-ui";
|
|
4
|
+
const FullyDeleteModelError = makeDecoratable("FullyDeleteModelError", (props)=>/*#__PURE__*/ react.createElement(Alert, {
|
|
5
|
+
type: "danger"
|
|
6
|
+
}, props.error.message));
|
|
7
|
+
export { FullyDeleteModelError };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=FullyDeleteModelError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js","sources":["../../../../../../src/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { Alert } from \"@webiny/admin-ui\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\n\nexport interface FullyDeleteModelErrorProps {\n model: CmsModel;\n error: CmsErrorResponse;\n}\n\n/*\n * The error a refused model delete ends with. Decoratable, so a package that blocks the delete\n * (for example a workflow bound to the model) can explain its own refusal.\n */\nexport const FullyDeleteModelError = makeDecoratable(\n \"FullyDeleteModelError\",\n (props: FullyDeleteModelErrorProps) => {\n return <Alert type={\"danger\"}>{props.error.message}</Alert>;\n }\n);\n"],"names":["FullyDeleteModelError","makeDecoratable","props","Alert"],"mappings":";;;AAcO,MAAMA,wBAAwBC,gBACjC,yBACA,CAACC,QACU,WAAP,GAAO,oBAACC,OAAKA;QAAC,MAAM;OAAWD,MAAM,KAAK,CAAC,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentModels/components/fullDelete/types.js","sources":["../../../../../src/presentation/contentModels/components/fullDelete/types.ts"],"sourcesContent":["import type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { IDeleteCmsModelTask } from \"~/admin/viewsGraphql.js\";\n\nexport enum FullyDeleteModelStateStatus {\n NONE = 0,\n UNDERSTOOD = 1,\n CONFIRMED = 2,\n PROCESSED = 3,\n ERROR = 999\n}\n\nexport interface IFullyDeleteModelState {\n status: FullyDeleteModelStateStatus;\n confirmation: string;\n model: CmsModel;\n error: CmsErrorResponse | null;\n task: IDeleteCmsModelTask | null;\n}\n"],"names":["FullyDeleteModelStateStatus"],"mappings":"AAGO,IAAKA,oCAA2BA,WAAAA,GAAAA,SAA3BA,2BAA2B
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/types.js","sources":["../../../../../src/presentation/contentModels/components/fullDelete/types.ts"],"sourcesContent":["import type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { IDeleteCmsModelTask } from \"~/admin/viewsGraphql.js\";\n\nexport enum FullyDeleteModelStateStatus {\n NONE = 0,\n UNDERSTOOD = 1,\n CONFIRMED = 2,\n PROCESSED = 3,\n ERROR = 999\n}\n\nexport interface IFullyDeleteModelState {\n status: FullyDeleteModelStateStatus;\n confirmation: string;\n model: CmsModel;\n error: CmsErrorResponse | null;\n task: IDeleteCmsModelTask | null;\n}\n"],"names":["FullyDeleteModelStateStatus"],"mappings":"AAGO,IAAKA,oCAA2BA,WAAAA,GAAAA,SAA3BA,2BAA2B;sEAC5B;4EACM;2EACD;2EACA;uEACJ;WALAA"}
|
|
@@ -25,7 +25,7 @@ class FieldEditorPresenterImpl {
|
|
|
25
25
|
}
|
|
26
26
|
init(field, model) {
|
|
27
27
|
this.originalField = cloneDeep(field);
|
|
28
|
-
const fieldType = this.fieldTypes.find((ft)=>ft.type === field.type);
|
|
28
|
+
const fieldType = this.fieldTypes.find((ft)=>ft.matches?.(field)) ?? this.fieldTypes.find((ft)=>ft.type === field.type);
|
|
29
29
|
if (!fieldType) throw new Error(`Unknown field type: ${field.type}`);
|
|
30
30
|
this.context = {
|
|
31
31
|
field,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldEditor/FieldEditorPresenter.js","sources":["../../../src/presentation/fieldEditor/FieldEditorPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed } from \"mobx\";\nimport { FormModelFactory, FormModel } from \"@webiny/app-admin\";\nimport cloneDeep from \"lodash/cloneDeep.js\";\nimport {\n FieldEditorPresenter as PresenterAbstraction,\n CmsFieldEditorGroup,\n CmsFieldEditorGroupModifier\n} from \"./abstractions.js\";\nimport type {\n ICmsFieldEditorFormBuilder,\n ICmsFieldEditorContext,\n ICmsFieldEditorGroup,\n ICmsFieldEditorGroupModifier,\n IFieldEditorPresenter\n} from \"./abstractions.js\";\nimport { CmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport type { ICmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport type { CmsModel, CmsModelField } from \"~/types.js\";\n\ntype FieldsFactory = (\n fields: FormModelFactory.FieldBuilderRegistry\n) => Record<string, FormModelFactory.FieldBuilder>;\n\ntype LayoutFactory = (layout: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[];\n\ninterface CollectedGroup {\n group: ICmsFieldEditorGroup;\n fieldsFns: FieldsFactory[];\n layoutFns: LayoutFactory[];\n}\n\nclass FieldEditorPresenterImpl implements IFieldEditorPresenter {\n private form: FormModel.Interface | null = null;\n private context: ICmsFieldEditorContext | null = null;\n private originalField: CmsModelField | null = null;\n\n constructor(\n private factory: FormModelFactory.Interface,\n private groups: ICmsFieldEditorGroup[],\n private modifiers: ICmsFieldEditorGroupModifier[] | undefined,\n private fieldTypes: ICmsFieldType[]\n ) {\n makeAutoObservable(this, { vm: computed }, { autoBind: true });\n }\n\n get vm() {\n return {\n form: this.form ? this.form.vm : null\n };\n }\n\n init(field: CmsModelField, model: CmsModel) {\n this.originalField = cloneDeep(field);\n\n const fieldType = this.fieldTypes.find(ft => ft.type === field.type);\n if (!fieldType) {\n throw new Error(`Unknown field type: ${field.type}`);\n }\n\n this.context = { field, model, fieldType };\n this.form = this.buildForm(this.context);\n\n const data: Record<string, any> = {};\n for (const group of this.groups) {\n data[group.name] = group.mapToForm(field, this.context);\n }\n\n for (const mod of this.getApplicableModifiers(this.context)) {\n if (mod.mapToForm) {\n const modData = mod.mapToForm(field, this.context);\n data[mod.group] = { ...data[mod.group], ...modData };\n }\n }\n\n this.form.setData(data);\n }\n\n async submit(): Promise<CmsModelField | false> {\n if (!this.form || !this.context || !this.originalField) {\n return false;\n }\n\n const data = await this.form.submit<Record<string, any>>();\n if (!data) {\n return false;\n }\n\n const field = cloneDeep(this.originalField);\n\n for (const group of this.groups) {\n group.mapFromForm(data[group.name] ?? {}, field, this.context);\n }\n\n for (const mod of this.getApplicableModifiers(this.context)) {\n if (mod.mapFromForm) {\n mod.mapFromForm(data[mod.group] ?? {}, field, this.context);\n }\n }\n\n return field;\n }\n\n private buildForm(context: ICmsFieldEditorContext) {\n const collected = this.collectGroups(context);\n\n return this.factory.create({\n fields: registry => {\n const result: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const { group, fieldsFns } of collected) {\n result[group.name] = registry\n .object()\n .label(group.label)\n .renderer(\"passthrough\")\n .fields(childRegistry => {\n const merged: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const fn of fieldsFns) {\n Object.assign(merged, fn(childRegistry));\n }\n return merged;\n });\n }\n return result;\n },\n layout: layout => {\n const tabs = layout\n .tabs(\"field-settings\")\n .renderer(\"tabsHorizontal\", { spacing: \"lg\", size: \"md\", separator: true });\n for (const { group, layoutFns } of collected) {\n tabs.tab(group.name, tab => {\n tab.label(group.label);\n\n if (group.name === \"predefinedValues\") {\n tab.rules([\n {\n type: \"condition\",\n target: \"general.predefinedValuesEnabled\",\n operator: \"isFalsy\",\n value: null,\n action: \"disable\"\n }\n ]);\n }\n\n tab.layout(l => [\n l.object(group.name, inner => layoutFns.flatMap(fn => fn(inner)))\n ]);\n });\n }\n return [tabs];\n }\n });\n }\n\n private collectGroups(context: ICmsFieldEditorContext): CollectedGroup[] {\n return this.groups.map(group => {\n const fieldsFns: FieldsFactory[] = [];\n const layoutFns: LayoutFactory[] = [];\n\n const builder: ICmsFieldEditorFormBuilder = {\n fields(fn: FieldsFactory) {\n fieldsFns.push(fn);\n },\n layout(fn: LayoutFactory) {\n layoutFns.push(fn);\n }\n };\n\n group.buildForm(builder, context);\n\n for (const mod of this.getApplicableModifiers(context)) {\n if (mod.group !== group.name) {\n continue;\n }\n mod.modifyForm(builder, context);\n }\n\n return { group, fieldsFns, layoutFns };\n });\n }\n\n private getApplicableModifiers(\n context: ICmsFieldEditorContext\n ): ICmsFieldEditorGroupModifier[] {\n if (!this.modifiers) {\n return [];\n }\n return this.modifiers.filter(mod => {\n if (mod.shouldApply) {\n return mod.shouldApply(context);\n }\n return true;\n });\n }\n}\n\nexport const FieldEditorPresenterRegistration = PresenterAbstraction.createImplementation({\n implementation: FieldEditorPresenterImpl,\n dependencies: [\n FormModelFactory,\n [CmsFieldEditorGroup, { multiple: true }],\n [CmsFieldEditorGroupModifier, { multiple: true, optional: true }],\n [CmsFieldType, { multiple: true }]\n ]\n});\n"],"names":["FieldEditorPresenterImpl","factory","groups","modifiers","fieldTypes","makeAutoObservable","computed","field","model","cloneDeep","fieldType","ft","Error","data","group","mod","modData","context","collected","registry","result","fieldsFns","childRegistry","merged","fn","Object","layout","tabs","layoutFns","tab","l","inner","builder","FieldEditorPresenterRegistration","PresenterAbstraction","FormModelFactory","CmsFieldEditorGroup","CmsFieldEditorGroupModifier","CmsFieldType"],"mappings":";;;;;AA+BA,MAAMA;IAKF,YACYC,OAAmC,EACnCC,MAA8B,EAC9BC,SAAqD,EACrDC,UAA2B,CACrC;aAJUH,OAAO,GAAPA;aACAC,MAAM,GAANA;aACAC,SAAS,GAATA;aACAC,UAAU,GAAVA;aARJ,IAAI,GAA+B;aACnC,OAAO,GAAkC;aACzC,aAAa,GAAyB;QAQ1CC,mBAAmB,IAAI,EAAE;YAAE,IAAIC;QAAS,GAAG;YAAE,UAAU;QAAK;IAChE;IAEA,IAAI,KAAK;QACL,OAAO;YACH,MAAM,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG;QACrC;IACJ;IAEA,KAAKC,KAAoB,EAAEC,KAAe,EAAE;QACxC,IAAI,CAAC,aAAa,GAAGC,UAAUF;QAE/B,MAAMG,YAAY,IAAI,CAAC,UAAU,CAAC,IAAI,CAACC,CAAAA,KAAMA,GAAG,IAAI,KAAKJ,MAAM,IAAI;QACnE,IAAI,CAACG,WACD,MAAM,IAAIE,MAAM,CAAC,oBAAoB,EAAEL,MAAM,IAAI,EAAE;QAGvD,IAAI,CAAC,OAAO,GAAG;YAAEA;YAAOC;YAAOE;QAAU;Q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sC;gBACxC,QAAOR,EAAiB;oBACpBH,UAAU,IAAI,CAACG;gBACnB;gBACA,QAAOA,EAAiB;oBACpBI,UAAU,IAAI,CAACJ;gBACnB;YACJ;YAEAV,MAAM,SAAS,CAACkB,SAASf;YAEzB,KAAK,MAAMF,OAAO,IAAI,CAAC,sBAAsB,CAACE,SAC1C,IAAIF,IAAI,KAAK,KAAKD,MAAM,IAAI,EAG5BC,IAAI,UAAU,CAACiB,SAASf;YAG5B,OAAO;gBAAEH;gBAAOO;gBAAWO;YAAU;QACzC;IACJ;IAEQ,uBACJX,OAA+B,EACD;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,EACf,OAAO,EAAE;QAEb,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAACF,CAAAA;YACzB,IAAIA,IAAI,WAAW,EACf,OAAOA,IAAI,WAAW,CAACE;YAE3B,OAAO;QACX;IACJ;AACJ;AAEO,MAAMgB,mCAAmCC,qBAAAA,oBAAyC,CAAC;IACtF,gBAAgBlC;IAChB,cAAc;QACVmC;QACA;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzC;YAACC;YAA6B;gBAAE,UAAU;gBAAM,UAAU;YAAK;SAAE;QACjE;YAACC;YAAc;gBAAE,UAAU;YAAK;SAAE;KACrC;AACL"}
|
|
1
|
+
{"version":3,"file":"presentation/fieldEditor/FieldEditorPresenter.js","sources":["../../../src/presentation/fieldEditor/FieldEditorPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed } from \"mobx\";\nimport { FormModelFactory, FormModel } from \"@webiny/app-admin\";\nimport cloneDeep from \"lodash/cloneDeep.js\";\nimport {\n FieldEditorPresenter as PresenterAbstraction,\n CmsFieldEditorGroup,\n CmsFieldEditorGroupModifier\n} from \"./abstractions.js\";\nimport type {\n ICmsFieldEditorFormBuilder,\n ICmsFieldEditorContext,\n ICmsFieldEditorGroup,\n ICmsFieldEditorGroupModifier,\n IFieldEditorPresenter\n} from \"./abstractions.js\";\nimport { CmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport type { ICmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport type { CmsModel, CmsModelField } from \"~/types.js\";\n\ntype FieldsFactory = (\n fields: FormModelFactory.FieldBuilderRegistry\n) => Record<string, FormModelFactory.FieldBuilder>;\n\ntype LayoutFactory = (layout: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[];\n\ninterface CollectedGroup {\n group: ICmsFieldEditorGroup;\n fieldsFns: FieldsFactory[];\n layoutFns: LayoutFactory[];\n}\n\nclass FieldEditorPresenterImpl implements IFieldEditorPresenter {\n private form: FormModel.Interface | null = null;\n private context: ICmsFieldEditorContext | null = null;\n private originalField: CmsModelField | null = null;\n\n constructor(\n private factory: FormModelFactory.Interface,\n private groups: ICmsFieldEditorGroup[],\n private modifiers: ICmsFieldEditorGroupModifier[] | undefined,\n private fieldTypes: ICmsFieldType[]\n ) {\n makeAutoObservable(this, { vm: computed }, { autoBind: true });\n }\n\n get vm() {\n return {\n form: this.form ? this.form.vm : null\n };\n }\n\n init(field: CmsModelField, model: CmsModel) {\n this.originalField = cloneDeep(field);\n\n const fieldType =\n this.fieldTypes.find(ft => ft.matches?.(field)) ??\n this.fieldTypes.find(ft => ft.type === field.type);\n if (!fieldType) {\n throw new Error(`Unknown field type: ${field.type}`);\n }\n\n this.context = { field, model, fieldType };\n this.form = this.buildForm(this.context);\n\n const data: Record<string, any> = {};\n for (const group of this.groups) {\n data[group.name] = group.mapToForm(field, this.context);\n }\n\n for (const mod of this.getApplicableModifiers(this.context)) {\n if (mod.mapToForm) {\n const modData = mod.mapToForm(field, this.context);\n data[mod.group] = { ...data[mod.group], ...modData };\n }\n }\n\n this.form.setData(data);\n }\n\n async submit(): Promise<CmsModelField | false> {\n if (!this.form || !this.context || !this.originalField) {\n return false;\n }\n\n const data = await this.form.submit<Record<string, any>>();\n if (!data) {\n return false;\n }\n\n const field = cloneDeep(this.originalField);\n\n for (const group of this.groups) {\n group.mapFromForm(data[group.name] ?? {}, field, this.context);\n }\n\n for (const mod of this.getApplicableModifiers(this.context)) {\n if (mod.mapFromForm) {\n mod.mapFromForm(data[mod.group] ?? {}, field, this.context);\n }\n }\n\n return field;\n }\n\n private buildForm(context: ICmsFieldEditorContext) {\n const collected = this.collectGroups(context);\n\n return this.factory.create({\n fields: registry => {\n const result: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const { group, fieldsFns } of collected) {\n result[group.name] = registry\n .object()\n .label(group.label)\n .renderer(\"passthrough\")\n .fields(childRegistry => {\n const merged: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const fn of fieldsFns) {\n Object.assign(merged, fn(childRegistry));\n }\n return merged;\n });\n }\n return result;\n },\n layout: layout => {\n const tabs = layout\n .tabs(\"field-settings\")\n .renderer(\"tabsHorizontal\", { spacing: \"lg\", size: \"md\", separator: true });\n for (const { group, layoutFns } of collected) {\n tabs.tab(group.name, tab => {\n tab.label(group.label);\n\n if (group.name === \"predefinedValues\") {\n tab.rules([\n {\n type: \"condition\",\n target: \"general.predefinedValuesEnabled\",\n operator: \"isFalsy\",\n value: null,\n action: \"disable\"\n }\n ]);\n }\n\n tab.layout(l => [\n l.object(group.name, inner => layoutFns.flatMap(fn => fn(inner)))\n ]);\n });\n }\n return [tabs];\n }\n });\n }\n\n private collectGroups(context: ICmsFieldEditorContext): CollectedGroup[] {\n return this.groups.map(group => {\n const fieldsFns: FieldsFactory[] = [];\n const layoutFns: LayoutFactory[] = [];\n\n const builder: ICmsFieldEditorFormBuilder = {\n fields(fn: FieldsFactory) {\n fieldsFns.push(fn);\n },\n layout(fn: LayoutFactory) {\n layoutFns.push(fn);\n }\n };\n\n group.buildForm(builder, context);\n\n for (const mod of this.getApplicableModifiers(context)) {\n if (mod.group !== group.name) {\n continue;\n }\n mod.modifyForm(builder, context);\n }\n\n return { group, fieldsFns, layoutFns };\n });\n }\n\n private getApplicableModifiers(\n context: ICmsFieldEditorContext\n ): ICmsFieldEditorGroupModifier[] {\n if (!this.modifiers) {\n return [];\n }\n return this.modifiers.filter(mod => {\n if (mod.shouldApply) {\n return mod.shouldApply(context);\n }\n return true;\n });\n }\n}\n\nexport const FieldEditorPresenterRegistration = PresenterAbstraction.createImplementation({\n implementation: FieldEditorPresenterImpl,\n dependencies: [\n FormModelFactory,\n [CmsFieldEditorGroup, { multiple: true }],\n [CmsFieldEditorGroupModifier, { multiple: true, optional: true }],\n [CmsFieldType, { multiple: true }]\n ]\n});\n"],"names":["FieldEditorPresenterImpl","factory","groups","modifiers","fieldTypes","makeAutoObservable","computed","field","model","cloneDeep","fieldType","ft","Error","data","group","mod","modData","context","collected","registry","result","fieldsFns","childRegistry","merged","fn","Object","layout","tabs","layoutFns","tab","l","inner","builder","FieldEditorPresenterRegistration","PresenterAbstraction","FormModelFactory","CmsFieldEditorGroup","CmsFieldEditorGroupModifier","CmsFieldType"],"mappings":";;;;;AA+BA,MAAMA;IAKF,YACYC,OAAmC,EACnCC,MAA8B,EAC9BC,SAAqD,EACrDC,UAA2B,CACrC;aAJUH,OAAO,GAAPA;aACAC,MAAM,GAANA;aACAC,SAAS,GAATA;aACAC,UAAU,GAAVA;aARJ,IAAI,GAA+B;aACnC,OAAO,GAAkC;aACzC,aAAa,GAAyB;QAQ1CC,mBAAmB,IAAI,EAAE;YAAE,IAAIC;QAAS,GAAG;YAAE,UAAU;QAAK;IAChE;IAEA,IAAI,KAAK;QACL,OAAO;YACH,MAAM,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG;QACrC;IACJ;IAEA,KAAKC,KAAoB,EAAEC,KAAe,EAAE;QACxC,IAAI,CAAC,aAAa,GAAGC,UAAUF;QAE/B,MAAMG,YACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAACC,CAAAA,KAAMA,GAAG,OAAO,GAAGJ,WACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAACI,CAAAA,KAAMA,GAAG,IAAI,KAAKJ,MAAM,IAAI;QACrD,I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B,EAAoB;QACrE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAACH,CAAAA;YACnB,MAAMO,YAA6B,EAAE;YACrC,MAAMO,YAA6B,EAAE;YAErC,MAAMI,UAAsC;gBACxC,QAAOR,EAAiB;oBACpBH,UAAU,IAAI,CAACG;gBACnB;gBACA,QAAOA,EAAiB;oBACpBI,UAAU,IAAI,CAACJ;gBACnB;YACJ;YAEAV,MAAM,SAAS,CAACkB,SAASf;YAEzB,KAAK,MAAMF,OAAO,IAAI,CAAC,sBAAsB,CAACE,SAC1C,IAAIF,IAAI,KAAK,KAAKD,MAAM,IAAI,EAG5BC,IAAI,UAAU,CAACiB,SAASf;YAG5B,OAAO;gBAAEH;gBAAOO;gBAAWO;YAAU;QACzC;IACJ;IAEQ,uBACJX,OAA+B,EACD;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,EACf,OAAO,EAAE;QAEb,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAACF,CAAAA;YACzB,IAAIA,IAAI,WAAW,EACf,OAAOA,IAAI,WAAW,CAACE;YAE3B,OAAO;QACX;IACJ;AACJ;AAEO,MAAMgB,mCAAmCC,qBAAAA,oBAAyC,CAAC;IACtF,gBAAgBlC;IAChB,cAAc;QACVmC;QACA;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzC;YAACC;YAA6B;gBAAE,UAAU;gBAAM,UAAU;YAAK;SAAE;QACjE;YAACC;YAAc;gBAAE,UAAU;YAAK;SAAE;KACrC;AACL"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { CmsFieldEditorGroup } from "../abstractions.js";
|
|
2
2
|
import { CmsFieldRenderer } from "../../fieldRenderers/abstractions.js";
|
|
3
|
+
const getOptionalValue = (form, path)=>{
|
|
4
|
+
try {
|
|
5
|
+
return form.field(path).getValue();
|
|
6
|
+
} catch {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
3
10
|
class AppearanceGroupImpl {
|
|
4
11
|
constructor(allRenderers){
|
|
5
12
|
this.allRenderers = allRenderers;
|
|
@@ -13,9 +20,14 @@ class AppearanceGroupImpl {
|
|
|
13
20
|
name: fields.text().options(({ form })=>{
|
|
14
21
|
const list = Boolean(form.field("general.list").getValue());
|
|
15
22
|
const predefined = Boolean(form.field("general.predefinedValuesEnabled").getValue());
|
|
23
|
+
const settingsType = getOptionalValue(form, "general.settingsType");
|
|
16
24
|
const liveField = {
|
|
17
25
|
...context.field,
|
|
18
26
|
list,
|
|
27
|
+
settings: "string" == typeof settingsType ? {
|
|
28
|
+
...context.field.settings,
|
|
29
|
+
type: settingsType
|
|
30
|
+
} : context.field.settings,
|
|
19
31
|
predefinedValues: {
|
|
20
32
|
values: context.field.predefinedValues?.values ?? [],
|
|
21
33
|
enabled: predefined
|