canopycms 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/plugin.d.ts +8 -0
- package/dist/auth/plugin.d.ts.map +1 -1
- package/dist/build-mode.d.ts +15 -5
- package/dist/build-mode.d.ts.map +1 -1
- package/dist/build-mode.js +18 -8
- package/dist/build-mode.js.map +1 -1
- package/dist/cli/init.d.ts +2 -2
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +37 -36
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/template-files/ai-config.ts.template +21 -0
- package/dist/cli/template-files/ai-route.ts.template +10 -0
- package/dist/cli/template-files/canopy.ts.template +24 -0
- package/dist/cli/templates.d.ts +5 -1
- package/dist/cli/templates.d.ts.map +1 -1
- package/dist/cli/templates.js +9 -2
- package/dist/cli/templates.js.map +1 -1
- package/dist/config/schemas/config.d.ts +4 -0
- package/dist/config/schemas/config.d.ts.map +1 -1
- package/dist/config/schemas/config.js +2 -0
- package/dist/config/schemas/config.js.map +1 -1
- package/dist/config/types.d.ts +5 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/content-reader.js +2 -2
- package/dist/content-reader.js.map +1 -1
- package/dist/context.js +5 -5
- package/dist/context.js.map +1 -1
- package/dist/operating-mode/client-unsafe-strategy.d.ts.map +1 -1
- package/dist/operating-mode/client-unsafe-strategy.js +15 -18
- package/dist/operating-mode/client-unsafe-strategy.js.map +1 -1
- package/dist/operating-mode/types.d.ts +8 -0
- package/dist/operating-mode/types.d.ts.map +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -1
- package/package.json +5 -4
- package/src/cli/init.ts +43 -38
- package/dist/__integration__/fixtures/content-seeds.d.ts +0 -43
- package/dist/__integration__/fixtures/content-seeds.d.ts.map +0 -1
- package/dist/__integration__/fixtures/content-seeds.js +0 -99
- package/dist/__integration__/fixtures/content-seeds.js.map +0 -1
- package/dist/__integration__/fixtures/schemas.d.ts +0 -12
- package/dist/__integration__/fixtures/schemas.d.ts.map +0 -1
- package/dist/__integration__/fixtures/schemas.js +0 -65
- package/dist/__integration__/fixtures/schemas.js.map +0 -1
- package/dist/__integration__/test-utils/api-client.d.ts +0 -123
- package/dist/__integration__/test-utils/api-client.d.ts.map +0 -1
- package/dist/__integration__/test-utils/api-client.js +0 -118
- package/dist/__integration__/test-utils/api-client.js.map +0 -1
- package/dist/__integration__/test-utils/multi-user.d.ts +0 -25
- package/dist/__integration__/test-utils/multi-user.d.ts.map +0 -1
- package/dist/__integration__/test-utils/multi-user.js +0 -105
- package/dist/__integration__/test-utils/multi-user.js.map +0 -1
- package/dist/__integration__/test-utils/test-workspace.d.ts +0 -25
- package/dist/__integration__/test-utils/test-workspace.d.ts.map +0 -1
- package/dist/__integration__/test-utils/test-workspace.js +0 -102
- package/dist/__integration__/test-utils/test-workspace.js.map +0 -1
- package/dist/editor/BranchManager.stories.d.ts +0 -8
- package/dist/editor/BranchManager.stories.d.ts.map +0 -1
- package/dist/editor/BranchManager.stories.js +0 -74
- package/dist/editor/BranchManager.stories.js.map +0 -1
- package/dist/editor/CanopyEditor.stories.d.ts +0 -7
- package/dist/editor/CanopyEditor.stories.d.ts.map +0 -1
- package/dist/editor/CanopyEditor.stories.js +0 -99
- package/dist/editor/CanopyEditor.stories.js.map +0 -1
- package/dist/editor/CommentsPanel.stories.d.ts +0 -10
- package/dist/editor/CommentsPanel.stories.d.ts.map +0 -1
- package/dist/editor/CommentsPanel.stories.js +0 -175
- package/dist/editor/CommentsPanel.stories.js.map +0 -1
- package/dist/editor/Editor.stories.d.ts +0 -7
- package/dist/editor/Editor.stories.d.ts.map +0 -1
- package/dist/editor/Editor.stories.js +0 -95
- package/dist/editor/Editor.stories.js.map +0 -1
- package/dist/editor/EditorPanes.stories.d.ts +0 -7
- package/dist/editor/EditorPanes.stories.d.ts.map +0 -1
- package/dist/editor/EditorPanes.stories.js +0 -116
- package/dist/editor/EditorPanes.stories.js.map +0 -1
- package/dist/editor/EntryNavigator.stories.d.ts +0 -8
- package/dist/editor/EntryNavigator.stories.d.ts.map +0 -1
- package/dist/editor/EntryNavigator.stories.js +0 -42
- package/dist/editor/EntryNavigator.stories.js.map +0 -1
- package/dist/editor/FormRenderer.stories.d.ts +0 -7
- package/dist/editor/FormRenderer.stories.d.ts.map +0 -1
- package/dist/editor/FormRenderer.stories.js +0 -115
- package/dist/editor/FormRenderer.stories.js.map +0 -1
- package/dist/editor/GroupManager.stories.d.ts +0 -19
- package/dist/editor/GroupManager.stories.d.ts.map +0 -1
- package/dist/editor/GroupManager.stories.js +0 -265
- package/dist/editor/GroupManager.stories.js.map +0 -1
- package/dist/editor/PermissionManager.stories.d.ts +0 -20
- package/dist/editor/PermissionManager.stories.d.ts.map +0 -1
- package/dist/editor/PermissionManager.stories.js +0 -506
- package/dist/editor/PermissionManager.stories.js.map +0 -1
- package/dist/editor/comments/FieldWrapper.stories.d.ts +0 -10
- package/dist/editor/comments/FieldWrapper.stories.d.ts.map +0 -1
- package/dist/editor/comments/FieldWrapper.stories.js +0 -173
- package/dist/editor/comments/FieldWrapper.stories.js.map +0 -1
- package/dist/editor/fields/BlockField.stories.d.ts +0 -7
- package/dist/editor/fields/BlockField.stories.d.ts.map +0 -1
- package/dist/editor/fields/BlockField.stories.js +0 -50
- package/dist/editor/fields/BlockField.stories.js.map +0 -1
- package/dist/editor/fields/fields.stories.d.ts +0 -8
- package/dist/editor/fields/fields.stories.d.ts.map +0 -1
- package/dist/editor/fields/fields.stories.js +0 -34
- package/dist/editor/fields/fields.stories.js.map +0 -1
- package/dist/test-utils/api-test-helpers.d.ts +0 -238
- package/dist/test-utils/api-test-helpers.d.ts.map +0 -1
- package/dist/test-utils/api-test-helpers.js +0 -347
- package/dist/test-utils/api-test-helpers.js.map +0 -1
- package/dist/test-utils/console-spy.d.ts +0 -56
- package/dist/test-utils/console-spy.d.ts.map +0 -1
- package/dist/test-utils/console-spy.js +0 -81
- package/dist/test-utils/console-spy.js.map +0 -1
- package/dist/test-utils/git-helpers.d.ts +0 -21
- package/dist/test-utils/git-helpers.d.ts.map +0 -1
- package/dist/test-utils/git-helpers.js +0 -23
- package/dist/test-utils/git-helpers.js.map +0 -1
- package/dist/test-utils/index.d.ts +0 -5
- package/dist/test-utils/index.d.ts.map +0 -1
- package/dist/test-utils/index.js +0 -4
- package/dist/test-utils/index.js.map +0 -1
- package/src/__integration__/errors/invalid-content.test.ts +0 -238
- package/src/__integration__/errors/permission-denied.test.ts +0 -220
- package/src/__integration__/fixtures/content-seeds.ts +0 -105
- package/src/__integration__/fixtures/schemas.ts +0 -67
- package/src/__integration__/initialization/prod-sim-init.test.ts +0 -139
- package/src/__integration__/permissions/path-permissions.test.ts +0 -314
- package/src/__integration__/permissions/role-permissions.test.ts +0 -354
- package/src/__integration__/permissions/settings-branch-isolation.test.ts +0 -317
- package/src/__integration__/settings/groups-api.test.ts +0 -403
- package/src/__integration__/test-utils/api-client.ts +0 -167
- package/src/__integration__/test-utils/multi-user.ts +0 -129
- package/src/__integration__/test-utils/test-workspace.ts +0 -130
- package/src/__integration__/user/user-context.test.ts +0 -174
- package/src/__integration__/validation/input-validation.test.ts +0 -166
- package/src/__integration__/workflows/api-editing-workflow.test.ts +0 -244
- package/src/__integration__/workflows/conflict-resolution.test.ts +0 -259
- package/src/__integration__/workflows/editing-workflow.test.ts +0 -205
- package/src/__integration__/workflows/review-workflow.test.ts +0 -260
- package/src/ai/__tests__/build.integration.test.ts +0 -224
- package/src/ai/__tests__/generate.integration.test.ts +0 -495
- package/src/ai/__tests__/handler.integration.test.ts +0 -212
- package/src/ai/__tests__/json-to-markdown.test.ts +0 -553
- package/src/ai/generate.ts +0 -410
- package/src/ai/handler.ts +0 -123
- package/src/ai/index.ts +0 -26
- package/src/ai/json-to-markdown.ts +0 -424
- package/src/ai/resolve-branch.ts +0 -34
- package/src/ai/types.ts +0 -160
- package/src/api/AGENTS.md +0 -81
- package/src/api/__test__/mock-client.ts +0 -404
- package/src/api/assets.test.ts +0 -140
- package/src/api/assets.ts +0 -154
- package/src/api/branch-merge.test.ts +0 -163
- package/src/api/branch-merge.ts +0 -113
- package/src/api/branch-review.test.ts +0 -297
- package/src/api/branch-review.ts +0 -136
- package/src/api/branch-status.test.ts +0 -85
- package/src/api/branch-status.ts +0 -153
- package/src/api/branch-withdraw.test.ts +0 -146
- package/src/api/branch-withdraw.ts +0 -81
- package/src/api/branch-workflow.integration.test.ts +0 -578
- package/src/api/branch.test.ts +0 -620
- package/src/api/branch.ts +0 -492
- package/src/api/client.test.ts +0 -349
- package/src/api/client.ts +0 -506
- package/src/api/comments.test.ts +0 -285
- package/src/api/comments.ts +0 -210
- package/src/api/content.test.ts +0 -345
- package/src/api/content.ts +0 -454
- package/src/api/entries.test.ts +0 -1339
- package/src/api/entries.ts +0 -650
- package/src/api/github-sync.ts +0 -144
- package/src/api/groups.test.ts +0 -1013
- package/src/api/groups.ts +0 -375
- package/src/api/guards.test.ts +0 -533
- package/src/api/guards.ts +0 -271
- package/src/api/index.ts +0 -87
- package/src/api/permissions.test.ts +0 -766
- package/src/api/permissions.ts +0 -334
- package/src/api/reference-options.ts +0 -118
- package/src/api/resolve-references.ts +0 -107
- package/src/api/route-builder.ts +0 -289
- package/src/api/schema.test.ts +0 -840
- package/src/api/schema.ts +0 -936
- package/src/api/security.test.ts +0 -233
- package/src/api/settings-helpers.ts +0 -84
- package/src/api/types.ts +0 -40
- package/src/api/user.test.ts +0 -127
- package/src/api/user.ts +0 -42
- package/src/api/validators.test.ts +0 -275
- package/src/api/validators.ts +0 -176
- package/src/asset-store.test.ts +0 -37
- package/src/asset-store.ts +0 -110
- package/src/auth/cache.ts +0 -7
- package/src/auth/caching-auth-plugin.test.ts +0 -154
- package/src/auth/caching-auth-plugin.ts +0 -109
- package/src/auth/context-helpers.ts +0 -75
- package/src/auth/file-based-auth-cache.test.ts +0 -257
- package/src/auth/file-based-auth-cache.ts +0 -279
- package/src/auth/index.ts +0 -12
- package/src/auth/plugin.ts +0 -51
- package/src/auth/types.ts +0 -38
- package/src/authorization/__tests__/branch.test.ts +0 -260
- package/src/authorization/__tests__/content.test.ts +0 -142
- package/src/authorization/__tests__/path.test.ts +0 -133
- package/src/authorization/__tests__/permissions-loader.test.ts +0 -200
- package/src/authorization/branch.ts +0 -94
- package/src/authorization/content.ts +0 -93
- package/src/authorization/groups/index.ts +0 -11
- package/src/authorization/groups/loader.ts +0 -127
- package/src/authorization/groups/schema.ts +0 -48
- package/src/authorization/helpers.ts +0 -48
- package/src/authorization/index.ts +0 -84
- package/src/authorization/path.ts +0 -112
- package/src/authorization/permissions/index.ts +0 -11
- package/src/authorization/permissions/loader.ts +0 -116
- package/src/authorization/permissions/schema.ts +0 -66
- package/src/authorization/test-utils.ts +0 -15
- package/src/authorization/types.ts +0 -66
- package/src/authorization/validation.test.ts +0 -100
- package/src/authorization/validation.ts +0 -62
- package/src/branch-metadata.test.ts +0 -168
- package/src/branch-metadata.ts +0 -166
- package/src/branch-registry.test.ts +0 -248
- package/src/branch-registry.ts +0 -152
- package/src/branch-schema-cache.test.ts +0 -275
- package/src/branch-schema-cache.ts +0 -189
- package/src/branch-workspace.test.ts +0 -183
- package/src/branch-workspace.ts +0 -124
- package/src/build/generate-ai-content.ts +0 -78
- package/src/build/index.ts +0 -8
- package/src/build-mode.ts +0 -27
- package/src/cli/generate-ai-content.ts +0 -100
- package/src/cli/init.test.ts +0 -240
- package/src/cli/templates/canopy.ts.template +0 -55
- package/src/cli/templates.ts +0 -47
- package/src/client.ts +0 -12
- package/src/comment-store.test.ts +0 -442
- package/src/comment-store.ts +0 -301
- package/src/config/__tests__/config.test.ts +0 -513
- package/src/config/flatten.ts +0 -174
- package/src/config/helpers.ts +0 -167
- package/src/config/index.ts +0 -86
- package/src/config/schemas/collection.ts +0 -67
- package/src/config/schemas/config.ts +0 -77
- package/src/config/schemas/field.ts +0 -108
- package/src/config/schemas/media.ts +0 -27
- package/src/config/schemas/permissions.ts +0 -21
- package/src/config/types.ts +0 -321
- package/src/config/validation.ts +0 -70
- package/src/config-test.ts +0 -65
- package/src/config.ts +0 -11
- package/src/content-id-index.test.ts +0 -512
- package/src/content-id-index.ts +0 -479
- package/src/content-reader.test.ts +0 -478
- package/src/content-reader.ts +0 -214
- package/src/content-store.test.ts +0 -1126
- package/src/content-store.ts +0 -793
- package/src/context.ts +0 -111
- package/src/editor/BranchManager.stories.tsx +0 -80
- package/src/editor/BranchManager.test.tsx +0 -324
- package/src/editor/BranchManager.tsx +0 -461
- package/src/editor/CanopyEditor.stories.tsx +0 -128
- package/src/editor/CanopyEditor.test.tsx +0 -81
- package/src/editor/CanopyEditor.tsx +0 -73
- package/src/editor/CanopyEditorPage.test.tsx +0 -59
- package/src/editor/CanopyEditorPage.tsx +0 -25
- package/src/editor/CommentsPanel.stories.tsx +0 -184
- package/src/editor/CommentsPanel.tsx +0 -338
- package/src/editor/Editor.integration.test.tsx +0 -227
- package/src/editor/Editor.stories.tsx +0 -119
- package/src/editor/Editor.tsx +0 -1221
- package/src/editor/EditorPanes.stories.tsx +0 -256
- package/src/editor/EditorPanes.test.tsx +0 -77
- package/src/editor/EditorPanes.tsx +0 -180
- package/src/editor/EntryNavigator.stories.tsx +0 -65
- package/src/editor/EntryNavigator.test.tsx +0 -598
- package/src/editor/EntryNavigator.tsx +0 -665
- package/src/editor/FormRenderer.stories.tsx +0 -212
- package/src/editor/FormRenderer.test.tsx +0 -194
- package/src/editor/FormRenderer.tsx +0 -432
- package/src/editor/GroupManager.stories.tsx +0 -301
- package/src/editor/GroupManager.test.tsx +0 -682
- package/src/editor/GroupManager.tsx +0 -9
- package/src/editor/PermissionManager.stories.tsx +0 -539
- package/src/editor/PermissionManager.test.tsx +0 -864
- package/src/editor/PermissionManager.tsx +0 -12
- package/src/editor/canopy-path.test.ts +0 -23
- package/src/editor/canopy-path.ts +0 -52
- package/src/editor/client-reference-resolver.ts +0 -118
- package/src/editor/comments/BranchComments.tsx +0 -93
- package/src/editor/comments/EntryComments.tsx +0 -94
- package/src/editor/comments/FieldWrapper.stories.tsx +0 -210
- package/src/editor/comments/FieldWrapper.tsx +0 -129
- package/src/editor/comments/InlineCommentThread.test.tsx +0 -384
- package/src/editor/comments/InlineCommentThread.tsx +0 -246
- package/src/editor/comments/ThreadCarousel.test.tsx +0 -393
- package/src/editor/comments/ThreadCarousel.tsx +0 -525
- package/src/editor/components/ConfirmDeleteModal.tsx +0 -49
- package/src/editor/components/EditorContext.tsx +0 -49
- package/src/editor/components/EditorFooter.tsx +0 -47
- package/src/editor/components/EditorHeader.tsx +0 -492
- package/src/editor/components/EditorSidebar.tsx +0 -193
- package/src/editor/components/EntryCreateModal.tsx +0 -193
- package/src/editor/components/RenameEntryModal.tsx +0 -152
- package/src/editor/components/UserBadge.test.tsx +0 -274
- package/src/editor/components/UserBadge.tsx +0 -240
- package/src/editor/components/index.ts +0 -6
- package/src/editor/context/ApiClientContext.tsx +0 -56
- package/src/editor/context/EditorStateContext.tsx +0 -221
- package/src/editor/context/index.ts +0 -40
- package/src/editor/editor-config.test.ts +0 -385
- package/src/editor/editor-config.ts +0 -94
- package/src/editor/editor-utils.test.ts +0 -772
- package/src/editor/editor-utils.ts +0 -303
- package/src/editor/env.ts +0 -4
- package/src/editor/fields/BlockField.stories.tsx +0 -79
- package/src/editor/fields/BlockField.tsx +0 -267
- package/src/editor/fields/CodeField.tsx +0 -41
- package/src/editor/fields/MarkdownField.tsx +0 -205
- package/src/editor/fields/ObjectField.tsx +0 -71
- package/src/editor/fields/ReferenceField.tsx +0 -138
- package/src/editor/fields/SelectField.tsx +0 -76
- package/src/editor/fields/TextField.tsx +0 -35
- package/src/editor/fields/ToggleField.tsx +0 -37
- package/src/editor/fields/fields.stories.tsx +0 -40
- package/src/editor/group-manager/ExternalGroupsTab.tsx +0 -114
- package/src/editor/group-manager/GroupCard.tsx +0 -102
- package/src/editor/group-manager/GroupForm.tsx +0 -66
- package/src/editor/group-manager/InternalGroupsTab.tsx +0 -147
- package/src/editor/group-manager/MemberList.tsx +0 -184
- package/src/editor/group-manager/hooks/useExternalGroupSearch.ts +0 -63
- package/src/editor/group-manager/hooks/useGroupState.ts +0 -134
- package/src/editor/group-manager/hooks/useUserSearch.ts +0 -84
- package/src/editor/group-manager/index.tsx +0 -210
- package/src/editor/group-manager/types.ts +0 -28
- package/src/editor/hooks/README.md +0 -26
- package/src/editor/hooks/__test__/test-utils.tsx +0 -183
- package/src/editor/hooks/index.ts +0 -23
- package/src/editor/hooks/useBranchActions.test.tsx +0 -267
- package/src/editor/hooks/useBranchActions.tsx +0 -121
- package/src/editor/hooks/useBranchManager.test.tsx +0 -391
- package/src/editor/hooks/useBranchManager.tsx +0 -326
- package/src/editor/hooks/useCommentSystem.test.ts +0 -615
- package/src/editor/hooks/useCommentSystem.ts +0 -347
- package/src/editor/hooks/useDraftManager.test.ts +0 -375
- package/src/editor/hooks/useDraftManager.ts +0 -259
- package/src/editor/hooks/useEditorLayout.test.ts +0 -147
- package/src/editor/hooks/useEditorLayout.ts +0 -67
- package/src/editor/hooks/useEntryManager.test.ts +0 -588
- package/src/editor/hooks/useEntryManager.ts +0 -387
- package/src/editor/hooks/useGroupManager.test.ts +0 -277
- package/src/editor/hooks/useGroupManager.ts +0 -139
- package/src/editor/hooks/usePermissionManager.test.ts +0 -211
- package/src/editor/hooks/usePermissionManager.ts +0 -113
- package/src/editor/hooks/useReferenceResolution.ts +0 -248
- package/src/editor/hooks/useSchemaManager.test.ts +0 -370
- package/src/editor/hooks/useSchemaManager.ts +0 -310
- package/src/editor/hooks/useUserContext.tsx +0 -57
- package/src/editor/hooks/useUserMetadata.test.ts +0 -191
- package/src/editor/hooks/useUserMetadata.ts +0 -71
- package/src/editor/permission-manager/GroupSelector.tsx +0 -73
- package/src/editor/permission-manager/PermissionEditor.tsx +0 -321
- package/src/editor/permission-manager/PermissionLevelBadge.tsx +0 -53
- package/src/editor/permission-manager/PermissionTree.tsx +0 -237
- package/src/editor/permission-manager/UserSelector.tsx +0 -95
- package/src/editor/permission-manager/constants.tsx +0 -18
- package/src/editor/permission-manager/hooks/useGroupsAndUsers.ts +0 -153
- package/src/editor/permission-manager/hooks/usePermissionTree.ts +0 -200
- package/src/editor/permission-manager/index.tsx +0 -294
- package/src/editor/permission-manager/types.ts +0 -58
- package/src/editor/permission-manager/utils.ts +0 -179
- package/src/editor/preview-bridge.test.tsx +0 -50
- package/src/editor/preview-bridge.tsx +0 -294
- package/src/editor/schema-editor/CollectionEditor.test.tsx +0 -238
- package/src/editor/schema-editor/CollectionEditor.tsx +0 -520
- package/src/editor/schema-editor/EntryTypeEditor.test.tsx +0 -215
- package/src/editor/schema-editor/EntryTypeEditor.tsx +0 -367
- package/src/editor/schema-editor/index.ts +0 -19
- package/src/editor/setup-test-dom.ts +0 -10
- package/src/editor/test-setup.ts +0 -33
- package/src/editor/theme.tsx +0 -119
- package/src/editor/utils/env.ts +0 -39
- package/src/entry-schema-registry.test.ts +0 -281
- package/src/entry-schema-registry.ts +0 -121
- package/src/entry-schema.ts +0 -84
- package/src/git-manager.test.ts +0 -552
- package/src/git-manager.ts +0 -667
- package/src/github-service.test.ts +0 -312
- package/src/github-service.ts +0 -295
- package/src/http/handler.test.ts +0 -275
- package/src/http/handler.ts +0 -280
- package/src/http/index.ts +0 -11
- package/src/http/router.ts +0 -164
- package/src/http/types.ts +0 -44
- package/src/id.test.ts +0 -48
- package/src/id.ts +0 -22
- package/src/index.ts +0 -26
- package/src/operating-mode/__tests__/strategies.test.ts +0 -511
- package/src/operating-mode/client-safe-strategy.ts +0 -184
- package/src/operating-mode/client-unsafe-strategy.ts +0 -303
- package/src/operating-mode/client.ts +0 -13
- package/src/operating-mode/index.ts +0 -34
- package/src/operating-mode/types.ts +0 -186
- package/src/paths/__tests__/branch.test.ts +0 -53
- package/src/paths/__tests__/normalize.test.ts +0 -141
- package/src/paths/__tests__/resolve.test.ts +0 -207
- package/src/paths/__tests__/validation.test.ts +0 -61
- package/src/paths/branch.ts +0 -115
- package/src/paths/index.ts +0 -73
- package/src/paths/normalize-server.ts +0 -40
- package/src/paths/normalize.ts +0 -107
- package/src/paths/resolve.ts +0 -61
- package/src/paths/test-utils.ts +0 -37
- package/src/paths/types.ts +0 -68
- package/src/paths/validation.test.ts +0 -480
- package/src/paths/validation.ts +0 -391
- package/src/reference-resolver.test.ts +0 -107
- package/src/reference-resolver.ts +0 -157
- package/src/schema/index.ts +0 -29
- package/src/schema/meta-loader.ts +0 -366
- package/src/schema/resolver.ts +0 -83
- package/src/schema/schema-store-types.ts +0 -56
- package/src/schema/schema-store.test.ts +0 -816
- package/src/schema/schema-store.ts +0 -795
- package/src/schema/types.ts +0 -33
- package/src/schema-meta-loader.test.ts +0 -447
- package/src/server.ts +0 -15
- package/src/services.test.ts +0 -559
- package/src/services.ts +0 -373
- package/src/settings-branch-utils.ts +0 -53
- package/src/settings-workspace.ts +0 -156
- package/src/task-queue/README.md +0 -144
- package/src/task-queue/index.ts +0 -14
- package/src/task-queue/task-queue.test.ts +0 -524
- package/src/task-queue/task-queue.ts +0 -514
- package/src/task-queue/types.ts +0 -41
- package/src/test-utils/api-test-helpers.ts +0 -445
- package/src/test-utils/console-spy.test.ts +0 -14
- package/src/test-utils/console-spy.ts +0 -125
- package/src/test-utils/git-helpers.ts +0 -31
- package/src/test-utils/index.ts +0 -4
- package/src/types.ts +0 -54
- package/src/user.ts +0 -118
- package/src/utils/debug.test.ts +0 -114
- package/src/utils/debug.ts +0 -127
- package/src/utils/error.test.ts +0 -92
- package/src/utils/error.ts +0 -83
- package/src/utils/format.ts +0 -12
- package/src/validation/__tests__/field-traversal.test.ts +0 -263
- package/src/validation/deletion-checker.ts +0 -234
- package/src/validation/field-traversal.ts +0 -146
- package/src/validation/reference-validator.ts +0 -168
- package/src/worker/cms-worker-rebase.test.ts +0 -473
- package/src/worker/cms-worker.ts +0 -777
- package/src/worker/integration.test.ts +0 -289
- package/src/worker/task-queue-config.ts +0 -25
- package/src/worker/task-queue.test.ts +0 -452
- package/src/worker/task-queue.ts +0 -58
- /package/{src/cli/templates → dist/cli/template-files}/Dockerfile.cms.template +0 -0
- /package/{src/cli/templates → dist/cli/template-files}/canopycms.config.ts.template +0 -0
- /package/{src/cli/templates → dist/cli/template-files}/deploy-cms.yml.template +0 -0
- /package/{src/cli/templates → dist/cli/template-files}/edit-page.tsx.template +0 -0
- /package/{src/cli/templates → dist/cli/template-files}/route.ts.template +0 -0
- /package/{src/cli/templates → dist/cli/template-files}/schemas.ts.template +0 -0
package/src/editor/Editor.tsx
DELETED
|
@@ -1,1221 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { useEffect, useMemo, useState, useRef } from 'react'
|
|
4
|
-
|
|
5
|
-
import { ActionIcon, Box, Drawer, Group, Menu, Paper, Text, Title, useTree } from '@mantine/core'
|
|
6
|
-
import {
|
|
7
|
-
IconChevronDown,
|
|
8
|
-
IconChevronUp,
|
|
9
|
-
IconDots,
|
|
10
|
-
IconFolderPlus,
|
|
11
|
-
IconPlus,
|
|
12
|
-
} from '@tabler/icons-react'
|
|
13
|
-
import { notifications } from '@mantine/notifications'
|
|
14
|
-
|
|
15
|
-
// TreeController type from Mantine's useTree hook
|
|
16
|
-
type TreeController = ReturnType<typeof useTree>
|
|
17
|
-
|
|
18
|
-
import type { ContentFormat, EntrySchema } from '../config'
|
|
19
|
-
import { EntryNavigator, type EntryNavCollection } from './EntryNavigator'
|
|
20
|
-
import type { FormValue } from './FormRenderer'
|
|
21
|
-
import { FormRenderer } from './FormRenderer'
|
|
22
|
-
import { PreviewFrame } from './preview-bridge'
|
|
23
|
-
import type { OperatingMode } from '../operating-mode'
|
|
24
|
-
import { EditorPanes } from './EditorPanes'
|
|
25
|
-
import { CanopyCMSProvider, type CanopyThemeOptions } from './theme'
|
|
26
|
-
import { BranchManager } from './BranchManager'
|
|
27
|
-
import { CommentsPanel } from './CommentsPanel'
|
|
28
|
-
import { GroupManager } from './GroupManager'
|
|
29
|
-
import { PermissionManager } from './PermissionManager'
|
|
30
|
-
import type { CommentThread } from '../comment-store'
|
|
31
|
-
import { buildPreviewSrc, buildCollectionLabels, buildBreadcrumbSegments } from './editor-utils'
|
|
32
|
-
import {
|
|
33
|
-
useEditorLayout,
|
|
34
|
-
useDraftManager,
|
|
35
|
-
useEntryManager,
|
|
36
|
-
useGroupManager,
|
|
37
|
-
usePermissionManager,
|
|
38
|
-
useCommentSystem,
|
|
39
|
-
useBranchManager,
|
|
40
|
-
useUserContext,
|
|
41
|
-
useSchemaManager,
|
|
42
|
-
} from './hooks'
|
|
43
|
-
import { useBranchActions } from './hooks/useBranchActions'
|
|
44
|
-
import { EditorFooter, EditorHeader, EditorSidebar } from './components'
|
|
45
|
-
import { RenameEntryModal } from './components/RenameEntryModal'
|
|
46
|
-
import { EntryCreateModal } from './components/EntryCreateModal'
|
|
47
|
-
import { ConfirmDeleteModal } from './components/ConfirmDeleteModal'
|
|
48
|
-
import { CollectionEditor, type ExistingCollection, type ExistingEntryType } from './schema-editor'
|
|
49
|
-
import type { LogicalPath, ContentId } from '../paths/types'
|
|
50
|
-
import { useApiClient } from './context'
|
|
51
|
-
|
|
52
|
-
export interface EditorEntry {
|
|
53
|
-
path: LogicalPath // Logical path (no IDs/extensions)
|
|
54
|
-
contentId: ContentId // 12-char content ID (required - used for draft keying)
|
|
55
|
-
label: string
|
|
56
|
-
status?: string
|
|
57
|
-
schema: EntrySchema
|
|
58
|
-
apiPath: string
|
|
59
|
-
previewSrc?: string
|
|
60
|
-
collectionPath?: LogicalPath
|
|
61
|
-
collectionName?: string
|
|
62
|
-
slug?: string
|
|
63
|
-
format?: ContentFormat
|
|
64
|
-
type?: 'entry'
|
|
65
|
-
canEdit?: boolean
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Summary of an entry type for UI display.
|
|
70
|
-
* Contains just enough info to show type picker and create entries.
|
|
71
|
-
*/
|
|
72
|
-
export interface EditorEntryType {
|
|
73
|
-
name: string
|
|
74
|
-
label?: string
|
|
75
|
-
format: ContentFormat
|
|
76
|
-
default?: boolean
|
|
77
|
-
maxItems?: number
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface EditorCollection {
|
|
81
|
-
path: LogicalPath // Logical path
|
|
82
|
-
contentId?: ContentId // 12-char content ID (optional, from directory name)
|
|
83
|
-
name: string
|
|
84
|
-
label?: string
|
|
85
|
-
format: ContentFormat // Default entry type's format (for backwards compatibility)
|
|
86
|
-
type: 'collection' | 'entry'
|
|
87
|
-
entryTypes?: EditorEntryType[] // All entry types in this collection
|
|
88
|
-
order?: readonly string[] // Embedded IDs for ordering entries and children
|
|
89
|
-
children?: EditorCollection[]
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface EditorProps {
|
|
93
|
-
entries: EditorEntry[]
|
|
94
|
-
title: string
|
|
95
|
-
subtitle?: string
|
|
96
|
-
siteTitle?: string
|
|
97
|
-
siteSubtitle?: string
|
|
98
|
-
branchName?: string
|
|
99
|
-
operatingMode: OperatingMode
|
|
100
|
-
collections?: EditorCollection[]
|
|
101
|
-
contentRoot?: string
|
|
102
|
-
initialSelectedId?: string
|
|
103
|
-
initialValues?: Record<string, FormValue>
|
|
104
|
-
renderPreview?: (entry: EditorEntry, value: FormValue | undefined) => React.ReactNode
|
|
105
|
-
onCreateEntry?: (collectionPath: LogicalPath) => Promise<void> | void
|
|
106
|
-
themeOptions?: CanopyThemeOptions
|
|
107
|
-
previewBaseByCollection?: Record<string, string>
|
|
108
|
-
currentUser?: string
|
|
109
|
-
canResolveComments?: boolean
|
|
110
|
-
// Auth UI handlers from config
|
|
111
|
-
AccountComponent?: React.ComponentType
|
|
112
|
-
onAccountClick?: () => void
|
|
113
|
-
onLogoutClick?: () => void
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* High-level editor wrapper that wires entry navigation, form rendering,
|
|
118
|
-
* saving/loading, and preview rendering using entry definitions.
|
|
119
|
-
*/
|
|
120
|
-
export const Editor: React.FC<EditorProps> = ({
|
|
121
|
-
entries,
|
|
122
|
-
title,
|
|
123
|
-
subtitle,
|
|
124
|
-
siteTitle = title,
|
|
125
|
-
siteSubtitle = subtitle,
|
|
126
|
-
branchName = '',
|
|
127
|
-
collections,
|
|
128
|
-
contentRoot,
|
|
129
|
-
initialSelectedId,
|
|
130
|
-
initialValues,
|
|
131
|
-
renderPreview,
|
|
132
|
-
onCreateEntry,
|
|
133
|
-
themeOptions,
|
|
134
|
-
operatingMode,
|
|
135
|
-
previewBaseByCollection,
|
|
136
|
-
currentUser = 'current-user',
|
|
137
|
-
canResolveComments = true,
|
|
138
|
-
AccountComponent,
|
|
139
|
-
onAccountClick,
|
|
140
|
-
onLogoutClick,
|
|
141
|
-
}) => {
|
|
142
|
-
// Per-resource loading states
|
|
143
|
-
const [branchesLoading, setBranchesLoading] = useState(false)
|
|
144
|
-
const [entriesLoading, setEntriesLoading] = useState(false)
|
|
145
|
-
const [commentsLoading] = useState(false)
|
|
146
|
-
const busy = branchesLoading || entriesLoading || commentsLoading
|
|
147
|
-
|
|
148
|
-
const [groupManagerOpen, setGroupManagerOpen] = useState(false)
|
|
149
|
-
const [permissionManagerOpen, setPermissionManagerOpen] = useState(false)
|
|
150
|
-
const [branchManagerOpen, setBranchManagerOpen] = useState(false)
|
|
151
|
-
|
|
152
|
-
// Schema editor state
|
|
153
|
-
const [collectionEditorOpen, setCollectionEditorOpen] = useState(false)
|
|
154
|
-
const [editingCollection, setEditingCollection] = useState<ExistingCollection | null>(null)
|
|
155
|
-
const [collectionEditorParentPath, setCollectionEditorParentPath] = useState<
|
|
156
|
-
LogicalPath | undefined
|
|
157
|
-
>(undefined)
|
|
158
|
-
const [collectionEditorError, setCollectionEditorError] = useState<string | null>(null)
|
|
159
|
-
const [availableSchemas, setAvailableSchemas] = useState<string[]>([])
|
|
160
|
-
|
|
161
|
-
// Rename entry modal state
|
|
162
|
-
const [renameModalOpen, setRenameModalOpen] = useState(false)
|
|
163
|
-
const [renamingEntry, setRenamingEntry] = useState<EditorEntry | null>(null)
|
|
164
|
-
const [renameModalError, setRenameModalError] = useState<string | null>(null)
|
|
165
|
-
const [renameModalSaving, setRenameModalSaving] = useState(false)
|
|
166
|
-
|
|
167
|
-
// Delete confirmation modal state
|
|
168
|
-
const [deleteCollectionModalOpen, setDeleteCollectionModalOpen] = useState(false)
|
|
169
|
-
const [deletingCollectionPath, setDeletingCollectionPath] = useState<LogicalPath | null>(null)
|
|
170
|
-
const [deleteEntryModalOpen, setDeleteEntryModalOpen] = useState(false)
|
|
171
|
-
const [deletingEntryPath, setDeletingEntryPath] = useState<LogicalPath | null>(null)
|
|
172
|
-
const [deleteInProgress, setDeleteInProgress] = useState(false)
|
|
173
|
-
|
|
174
|
-
// Preview data with resolved references for live preview
|
|
175
|
-
const [previewData, setPreviewData] = useState<FormValue>({})
|
|
176
|
-
const [previewLoadingState, setPreviewLoadingState] = useState<FormValue>({})
|
|
177
|
-
|
|
178
|
-
// API client for schema operations
|
|
179
|
-
const apiClient = useApiClient()
|
|
180
|
-
|
|
181
|
-
// Fetch current user context for permission checks
|
|
182
|
-
const { userContext } = useUserContext()
|
|
183
|
-
|
|
184
|
-
// Use custom hooks for layout, entry, draft, group, permission, comment, and branch management
|
|
185
|
-
const { layout, setLayout, highlightEnabled, setHighlightEnabled, headerRef, headerHeight } =
|
|
186
|
-
useEditorLayout()
|
|
187
|
-
|
|
188
|
-
// Comments state (shared between useCommentSystem and useBranchManager)
|
|
189
|
-
const [commentsForBranchSummaries, setCommentsForBranchSummaries] = useState<CommentThread[]>([])
|
|
190
|
-
|
|
191
|
-
// 1. Branch manager (provides branchNameState, no dependencies)
|
|
192
|
-
const {
|
|
193
|
-
branchName: branchNameState,
|
|
194
|
-
setBranchName,
|
|
195
|
-
branchSummaries,
|
|
196
|
-
currentBranch,
|
|
197
|
-
handleSubmit,
|
|
198
|
-
handleWithdraw,
|
|
199
|
-
handleRequestChanges,
|
|
200
|
-
handleDelete,
|
|
201
|
-
handleReloadBranchData,
|
|
202
|
-
loadBranches,
|
|
203
|
-
} = useBranchManager({
|
|
204
|
-
initialBranch: branchName,
|
|
205
|
-
operatingMode,
|
|
206
|
-
setBusy: setBranchesLoading,
|
|
207
|
-
comments: commentsForBranchSummaries,
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
// 2. Entry manager (depends on branchNameState, owns selectedPath)
|
|
211
|
-
const {
|
|
212
|
-
selectedPath,
|
|
213
|
-
setSelectedPath,
|
|
214
|
-
entries: entriesState,
|
|
215
|
-
collections: collectionsFromApi,
|
|
216
|
-
currentEntry,
|
|
217
|
-
navigatorOpen,
|
|
218
|
-
setNavigatorOpen,
|
|
219
|
-
refreshEntries,
|
|
220
|
-
handleCreateEntry,
|
|
221
|
-
renameEntry,
|
|
222
|
-
loadEntry,
|
|
223
|
-
saveEntry,
|
|
224
|
-
createModalOpen,
|
|
225
|
-
createModalCollection,
|
|
226
|
-
createModalError,
|
|
227
|
-
createModalCreating,
|
|
228
|
-
handleCreateModalSubmit,
|
|
229
|
-
closeCreateModal,
|
|
230
|
-
} = useEntryManager({
|
|
231
|
-
initialEntries: entries,
|
|
232
|
-
initialSelectedId,
|
|
233
|
-
branchName: branchNameState,
|
|
234
|
-
collections,
|
|
235
|
-
previewBaseByCollection,
|
|
236
|
-
resolvePreviewSrc: (entry) =>
|
|
237
|
-
buildPreviewSrc(entry, {
|
|
238
|
-
branchName: branchNameState,
|
|
239
|
-
previewBaseByCollection,
|
|
240
|
-
contentRoot,
|
|
241
|
-
}),
|
|
242
|
-
setBusy: setEntriesLoading,
|
|
243
|
-
contentRoot,
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
// Use collections from API (falls back to props if not loaded yet)
|
|
247
|
-
const activeCollections = collectionsFromApi.length > 0 ? collectionsFromApi : collections
|
|
248
|
-
|
|
249
|
-
// 3. Draft manager (depends on branchNameState, selectedPath from useEntryManager)
|
|
250
|
-
const {
|
|
251
|
-
drafts,
|
|
252
|
-
setDrafts,
|
|
253
|
-
setLoadedValues,
|
|
254
|
-
effectiveValue,
|
|
255
|
-
modifiedCount,
|
|
256
|
-
editedFiles,
|
|
257
|
-
handleSave,
|
|
258
|
-
handleDiscardDrafts,
|
|
259
|
-
handleDiscardFileDraft,
|
|
260
|
-
handleReload,
|
|
261
|
-
isSelectedDirty,
|
|
262
|
-
} = useDraftManager({
|
|
263
|
-
branchName: branchNameState,
|
|
264
|
-
selectedPath,
|
|
265
|
-
currentEntry,
|
|
266
|
-
entries: entriesState,
|
|
267
|
-
initialValues,
|
|
268
|
-
loadEntry,
|
|
269
|
-
saveEntry,
|
|
270
|
-
setBusy: setEntriesLoading,
|
|
271
|
-
})
|
|
272
|
-
|
|
273
|
-
// 4. Branch actions (depends on isSelectedDirty, setBranchName)
|
|
274
|
-
const { handleBranchChange, handleCreateBranch } = useBranchActions({
|
|
275
|
-
branchName: branchNameState,
|
|
276
|
-
setBranchName,
|
|
277
|
-
isSelectedDirty,
|
|
278
|
-
onReloadBranches: () => loadBranches(),
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
// 5. Comment system (depends on branchNameState)
|
|
282
|
-
const {
|
|
283
|
-
comments,
|
|
284
|
-
focusedFieldPath,
|
|
285
|
-
highlightThreadId,
|
|
286
|
-
commentsPanelOpen,
|
|
287
|
-
setCommentsPanelOpen,
|
|
288
|
-
handleAddComment,
|
|
289
|
-
handleResolveThread,
|
|
290
|
-
handleJumpToField,
|
|
291
|
-
handleJumpToEntry,
|
|
292
|
-
handleJumpToBranch,
|
|
293
|
-
} = useCommentSystem({
|
|
294
|
-
branchName: branchNameState,
|
|
295
|
-
selectedPath,
|
|
296
|
-
currentEntry,
|
|
297
|
-
currentUser,
|
|
298
|
-
canResolveComments,
|
|
299
|
-
setSelectedPath,
|
|
300
|
-
setBranchManagerOpen,
|
|
301
|
-
onCommentsChange: setCommentsForBranchSummaries,
|
|
302
|
-
})
|
|
303
|
-
|
|
304
|
-
const {
|
|
305
|
-
groupsData,
|
|
306
|
-
groupsLoading,
|
|
307
|
-
handleSaveGroups,
|
|
308
|
-
handleSearchUsers,
|
|
309
|
-
handleGetUserMetadata,
|
|
310
|
-
handleSearchExternalGroups,
|
|
311
|
-
} = useGroupManager({ isOpen: groupManagerOpen })
|
|
312
|
-
|
|
313
|
-
const { permissionsData, permissionsLoading, handleSavePermissions, handleListGroups } =
|
|
314
|
-
usePermissionManager({
|
|
315
|
-
isOpen: permissionManagerOpen,
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
// 6. Schema manager (depends on branchNameState)
|
|
319
|
-
const {
|
|
320
|
-
createCollection,
|
|
321
|
-
updateCollection,
|
|
322
|
-
deleteCollection,
|
|
323
|
-
addEntryType,
|
|
324
|
-
updateEntryType,
|
|
325
|
-
removeEntryType,
|
|
326
|
-
updateOrder,
|
|
327
|
-
deleteEntry,
|
|
328
|
-
isLoading: schemaLoading,
|
|
329
|
-
} = useSchemaManager({
|
|
330
|
-
branchName: branchNameState,
|
|
331
|
-
onSchemaChange: () => refreshEntries(branchNameState),
|
|
332
|
-
})
|
|
333
|
-
|
|
334
|
-
const collectionLabels = useMemo(
|
|
335
|
-
() => buildCollectionLabels(activeCollections),
|
|
336
|
-
[activeCollections],
|
|
337
|
-
)
|
|
338
|
-
const schema = currentEntry?.schema ?? []
|
|
339
|
-
|
|
340
|
-
// Effect to load entry data when selection changes
|
|
341
|
-
|
|
342
|
-
useEffect(() => {
|
|
343
|
-
const load = async () => {
|
|
344
|
-
const contentId = currentEntry?.contentId
|
|
345
|
-
if (!currentEntry || !contentId || drafts[contentId]) return
|
|
346
|
-
setEntriesLoading(true)
|
|
347
|
-
try {
|
|
348
|
-
const loaded = await loadEntry(currentEntry)
|
|
349
|
-
setLoadedValues((prev) => ({ ...prev, [contentId]: loaded }))
|
|
350
|
-
setDrafts((prev) => {
|
|
351
|
-
if (prev[contentId] !== undefined) return prev // preserve localStorage draft
|
|
352
|
-
return { ...prev, [contentId]: loaded }
|
|
353
|
-
})
|
|
354
|
-
} catch (err) {
|
|
355
|
-
console.error(err)
|
|
356
|
-
notifications.show({ message: 'Failed to load entry', color: 'red' })
|
|
357
|
-
} finally {
|
|
358
|
-
setEntriesLoading(false)
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
load().catch((err) => {
|
|
362
|
-
console.error(err)
|
|
363
|
-
setEntriesLoading(false)
|
|
364
|
-
notifications.show({ message: 'Failed to load entry', color: 'red' })
|
|
365
|
-
})
|
|
366
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- stable setters, run only on entry/path change
|
|
367
|
-
}, [currentEntry, drafts, selectedPath])
|
|
368
|
-
|
|
369
|
-
// Load available schemas when branch changes
|
|
370
|
-
useEffect(() => {
|
|
371
|
-
if (!branchNameState) return
|
|
372
|
-
const loadSchemas = async () => {
|
|
373
|
-
try {
|
|
374
|
-
const result = await apiClient.schema.get({ branch: branchNameState })
|
|
375
|
-
if (result.ok && result.data) {
|
|
376
|
-
setAvailableSchemas(Object.keys(result.data.entrySchemas ?? {}))
|
|
377
|
-
}
|
|
378
|
-
} catch (err) {
|
|
379
|
-
console.error('Failed to load available schemas:', err)
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
loadSchemas()
|
|
383
|
-
}, [branchNameState, apiClient])
|
|
384
|
-
|
|
385
|
-
// Schema editor handlers
|
|
386
|
-
const handleOpenCollectionEditor = async (
|
|
387
|
-
collection: EditorCollection | null,
|
|
388
|
-
parentPath?: LogicalPath,
|
|
389
|
-
) => {
|
|
390
|
-
if (collection) {
|
|
391
|
-
// Edit mode - fetch full collection data with usage counts
|
|
392
|
-
try {
|
|
393
|
-
const result = await apiClient.schema.getCollection({
|
|
394
|
-
branch: branchNameState,
|
|
395
|
-
collectionPath: collection.path,
|
|
396
|
-
})
|
|
397
|
-
|
|
398
|
-
if (result.ok && result.data && result.data.collection) {
|
|
399
|
-
// Use entry types with usage counts from API if available
|
|
400
|
-
const entries: ExistingEntryType[] = result.data.entryTypesWithUsage
|
|
401
|
-
? result.data.entryTypesWithUsage.map(
|
|
402
|
-
(et): ExistingEntryType => ({
|
|
403
|
-
name: et.name,
|
|
404
|
-
label: et.label,
|
|
405
|
-
format: et.format,
|
|
406
|
-
schema: et.schemaRef,
|
|
407
|
-
default: et.default,
|
|
408
|
-
maxItems: et.maxItems,
|
|
409
|
-
usageCount: et.usageCount,
|
|
410
|
-
}),
|
|
411
|
-
)
|
|
412
|
-
: (collection.entryTypes ?? []).map(
|
|
413
|
-
(et): ExistingEntryType => ({
|
|
414
|
-
name: et.name,
|
|
415
|
-
label: et.label,
|
|
416
|
-
format: et.format,
|
|
417
|
-
schema: '', // Fallback if entryTypesWithUsage not available
|
|
418
|
-
default: et.default,
|
|
419
|
-
maxItems: et.maxItems,
|
|
420
|
-
}),
|
|
421
|
-
)
|
|
422
|
-
|
|
423
|
-
const existingCollection: ExistingCollection = {
|
|
424
|
-
name: collection.name,
|
|
425
|
-
label: collection.label,
|
|
426
|
-
logicalPath: collection.path,
|
|
427
|
-
entries,
|
|
428
|
-
}
|
|
429
|
-
setEditingCollection(existingCollection)
|
|
430
|
-
} else {
|
|
431
|
-
// Fallback to using EditorCollection data
|
|
432
|
-
const existingCollection: ExistingCollection = {
|
|
433
|
-
name: collection.name,
|
|
434
|
-
label: collection.label,
|
|
435
|
-
logicalPath: collection.path,
|
|
436
|
-
entries: (collection.entryTypes ?? []).map(
|
|
437
|
-
(et): ExistingEntryType => ({
|
|
438
|
-
name: et.name,
|
|
439
|
-
label: et.label,
|
|
440
|
-
format: et.format,
|
|
441
|
-
schema: '',
|
|
442
|
-
default: et.default,
|
|
443
|
-
maxItems: et.maxItems,
|
|
444
|
-
}),
|
|
445
|
-
),
|
|
446
|
-
}
|
|
447
|
-
setEditingCollection(existingCollection)
|
|
448
|
-
}
|
|
449
|
-
} catch {
|
|
450
|
-
// Fallback on error
|
|
451
|
-
const existingCollection: ExistingCollection = {
|
|
452
|
-
name: collection.name,
|
|
453
|
-
label: collection.label,
|
|
454
|
-
logicalPath: collection.path,
|
|
455
|
-
entries: (collection.entryTypes ?? []).map(
|
|
456
|
-
(et): ExistingEntryType => ({
|
|
457
|
-
name: et.name,
|
|
458
|
-
label: et.label,
|
|
459
|
-
format: et.format,
|
|
460
|
-
schema: '',
|
|
461
|
-
default: et.default,
|
|
462
|
-
maxItems: et.maxItems,
|
|
463
|
-
}),
|
|
464
|
-
),
|
|
465
|
-
}
|
|
466
|
-
setEditingCollection(existingCollection)
|
|
467
|
-
}
|
|
468
|
-
setCollectionEditorParentPath(undefined)
|
|
469
|
-
} else {
|
|
470
|
-
// Create mode
|
|
471
|
-
setEditingCollection(null)
|
|
472
|
-
setCollectionEditorParentPath(parentPath)
|
|
473
|
-
}
|
|
474
|
-
setCollectionEditorError(null)
|
|
475
|
-
setCollectionEditorOpen(true)
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
const handleCloseCollectionEditor = () => {
|
|
479
|
-
setCollectionEditorOpen(false)
|
|
480
|
-
setEditingCollection(null)
|
|
481
|
-
setCollectionEditorParentPath(undefined)
|
|
482
|
-
setCollectionEditorError(null)
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const handleCollectionSave = async (
|
|
486
|
-
data: Parameters<typeof createCollection>[0] | Parameters<typeof updateCollection>[1],
|
|
487
|
-
isNew: boolean,
|
|
488
|
-
) => {
|
|
489
|
-
setCollectionEditorError(null)
|
|
490
|
-
try {
|
|
491
|
-
if (isNew) {
|
|
492
|
-
const result = await createCollection(data as Parameters<typeof createCollection>[0])
|
|
493
|
-
if (result) {
|
|
494
|
-
handleCloseCollectionEditor()
|
|
495
|
-
}
|
|
496
|
-
} else if (editingCollection) {
|
|
497
|
-
const success = await updateCollection(
|
|
498
|
-
editingCollection.logicalPath,
|
|
499
|
-
data as Parameters<typeof updateCollection>[1],
|
|
500
|
-
)
|
|
501
|
-
if (success) {
|
|
502
|
-
handleCloseCollectionEditor()
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
} catch (err) {
|
|
506
|
-
setCollectionEditorError(err instanceof Error ? err.message : 'Operation failed')
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
const handleDeleteCollection = (collectionPath: LogicalPath) => {
|
|
511
|
-
setDeletingCollectionPath(collectionPath)
|
|
512
|
-
setDeleteCollectionModalOpen(true)
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
const confirmDeleteCollection = async () => {
|
|
516
|
-
if (!deletingCollectionPath) return
|
|
517
|
-
setDeleteInProgress(true)
|
|
518
|
-
try {
|
|
519
|
-
await deleteCollection(deletingCollectionPath)
|
|
520
|
-
setDeleteCollectionModalOpen(false)
|
|
521
|
-
setDeletingCollectionPath(null)
|
|
522
|
-
} finally {
|
|
523
|
-
setDeleteInProgress(false)
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
const handleDeleteEntry = (entryPath: LogicalPath) => {
|
|
528
|
-
setDeletingEntryPath(entryPath)
|
|
529
|
-
setDeleteEntryModalOpen(true)
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
const confirmDeleteEntry = async () => {
|
|
533
|
-
if (!deletingEntryPath) return
|
|
534
|
-
setDeleteInProgress(true)
|
|
535
|
-
try {
|
|
536
|
-
const success = await deleteEntry(deletingEntryPath)
|
|
537
|
-
if (success && selectedPath === deletingEntryPath) {
|
|
538
|
-
// If we deleted the currently selected entry, clear selection
|
|
539
|
-
setSelectedPath('')
|
|
540
|
-
}
|
|
541
|
-
setDeleteEntryModalOpen(false)
|
|
542
|
-
setDeletingEntryPath(null)
|
|
543
|
-
} finally {
|
|
544
|
-
setDeleteInProgress(false)
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
const handleRenameEntry = (entryPath: string) => {
|
|
549
|
-
// Find the entry being renamed
|
|
550
|
-
const entry = entriesState.find((e) => e.path === entryPath)
|
|
551
|
-
if (!entry) {
|
|
552
|
-
notifications.show({ message: 'Entry not found', color: 'red' })
|
|
553
|
-
return
|
|
554
|
-
}
|
|
555
|
-
setRenamingEntry(entry)
|
|
556
|
-
setRenameModalError(null)
|
|
557
|
-
setRenameModalOpen(true)
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
const handleRenameSubmit = async (newSlug: string) => {
|
|
561
|
-
if (!renamingEntry) return
|
|
562
|
-
setRenameModalSaving(true)
|
|
563
|
-
setRenameModalError(null)
|
|
564
|
-
try {
|
|
565
|
-
await renameEntry(renamingEntry.path, newSlug)
|
|
566
|
-
setRenameModalOpen(false)
|
|
567
|
-
setRenamingEntry(null)
|
|
568
|
-
} catch (err) {
|
|
569
|
-
const errorMessage = err instanceof Error ? err.message : 'Rename failed'
|
|
570
|
-
setRenameModalError(errorMessage)
|
|
571
|
-
} finally {
|
|
572
|
-
setRenameModalSaving(false)
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
const handleReorderEntry = async (
|
|
577
|
-
collectionPath: LogicalPath,
|
|
578
|
-
contentId: string,
|
|
579
|
-
direction: 'up' | 'down',
|
|
580
|
-
) => {
|
|
581
|
-
// Find the collection to get its current order array
|
|
582
|
-
const findCollection = (
|
|
583
|
-
cols: EditorCollection[] | undefined,
|
|
584
|
-
path: string,
|
|
585
|
-
): EditorCollection | undefined => {
|
|
586
|
-
if (!cols) return undefined
|
|
587
|
-
for (const col of cols) {
|
|
588
|
-
if (col.path === path) return col
|
|
589
|
-
const found = findCollection(col.children, path)
|
|
590
|
-
if (found) return found
|
|
591
|
-
}
|
|
592
|
-
return undefined
|
|
593
|
-
}
|
|
594
|
-
const collection = findCollection(activeCollections, collectionPath)
|
|
595
|
-
if (!collection) return
|
|
596
|
-
|
|
597
|
-
// Use the collection's order array as the source of truth
|
|
598
|
-
// If no order array exists, build one from current entries and children
|
|
599
|
-
let currentOrder: string[]
|
|
600
|
-
if (collection.order && collection.order.length > 0) {
|
|
601
|
-
currentOrder = [...collection.order]
|
|
602
|
-
} else {
|
|
603
|
-
// Fallback: build order from entries and children
|
|
604
|
-
const collectionEntries = entriesState.filter((e) => e.collectionPath === collectionPath)
|
|
605
|
-
const entryIds = collectionEntries
|
|
606
|
-
.map((e) => e.contentId)
|
|
607
|
-
.filter((id): id is ContentId => !!id)
|
|
608
|
-
const subCollectionIds = (collection.children ?? [])
|
|
609
|
-
.map((child) => child.contentId)
|
|
610
|
-
.filter((id): id is ContentId => !!id)
|
|
611
|
-
currentOrder = [...entryIds, ...subCollectionIds]
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
// Find current position
|
|
615
|
-
const currentIndex = currentOrder.indexOf(contentId)
|
|
616
|
-
if (currentIndex === -1) return
|
|
617
|
-
|
|
618
|
-
// Calculate new position
|
|
619
|
-
const newIndex = direction === 'up' ? currentIndex - 1 : currentIndex + 1
|
|
620
|
-
if (newIndex < 0 || newIndex >= currentOrder.length) return
|
|
621
|
-
|
|
622
|
-
// Swap positions
|
|
623
|
-
const newOrder = [...currentOrder]
|
|
624
|
-
;[newOrder[currentIndex], newOrder[newIndex]] = [newOrder[newIndex], newOrder[currentIndex]]
|
|
625
|
-
|
|
626
|
-
// Update via API
|
|
627
|
-
await updateOrder(collectionPath, newOrder)
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
// Determine if we should hide the root collection (but keep its context for ordering)
|
|
631
|
-
const hiddenRootPath = useMemo(() => {
|
|
632
|
-
if (activeCollections?.length === 1 && activeCollections[0].path === contentRoot) {
|
|
633
|
-
return contentRoot
|
|
634
|
-
}
|
|
635
|
-
return undefined
|
|
636
|
-
}, [activeCollections, contentRoot])
|
|
637
|
-
|
|
638
|
-
const navCollections = useMemo<EntryNavCollection[] | undefined>(() => {
|
|
639
|
-
if (!activeCollections) return undefined
|
|
640
|
-
|
|
641
|
-
const grouped = new Map<string, EntryNavCollection['entries']>()
|
|
642
|
-
entriesState.forEach((entry) => {
|
|
643
|
-
if (!entry.collectionPath) return
|
|
644
|
-
const list = grouped.get(entry.collectionPath) ?? []
|
|
645
|
-
list.push({
|
|
646
|
-
path: entry.path,
|
|
647
|
-
label: entry.label,
|
|
648
|
-
status: entry.status,
|
|
649
|
-
contentId: entry.contentId,
|
|
650
|
-
conflictNotice: !!(
|
|
651
|
-
entry.contentId && currentBranch?.conflictFiles?.includes(entry.contentId)
|
|
652
|
-
),
|
|
653
|
-
})
|
|
654
|
-
grouped.set(entry.collectionPath, list)
|
|
655
|
-
})
|
|
656
|
-
|
|
657
|
-
const build = (node: EditorCollection): EntryNavCollection => {
|
|
658
|
-
const entries = grouped.get(node.path) ?? []
|
|
659
|
-
const children = node.children?.map((child) => build(child)) ?? []
|
|
660
|
-
|
|
661
|
-
// Pass entries, children, and order to EntryNavigator for interleaved ordering
|
|
662
|
-
return {
|
|
663
|
-
path: node.path,
|
|
664
|
-
label: node.label ?? node.name,
|
|
665
|
-
type: node.type,
|
|
666
|
-
contentId: node.contentId,
|
|
667
|
-
order: node.order,
|
|
668
|
-
entries: entries.length > 0 ? entries : undefined,
|
|
669
|
-
children: children.length > 0 ? children : undefined,
|
|
670
|
-
conflictNotice: !!(
|
|
671
|
-
node.contentId && currentBranch?.conflictFiles?.includes(node.contentId)
|
|
672
|
-
),
|
|
673
|
-
onAdd:
|
|
674
|
-
node.type !== 'entry'
|
|
675
|
-
? () => (onCreateEntry ? onCreateEntry(node.path) : handleCreateEntry(node.path))
|
|
676
|
-
: undefined,
|
|
677
|
-
onEdit: node.type === 'collection' ? () => handleOpenCollectionEditor(node) : undefined,
|
|
678
|
-
onAddSubCollection:
|
|
679
|
-
node.type === 'collection'
|
|
680
|
-
? () => handleOpenCollectionEditor(null, node.path)
|
|
681
|
-
: undefined,
|
|
682
|
-
onDelete: node.type === 'collection' ? () => handleDeleteCollection(node.path) : undefined,
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
return activeCollections.map((node) => build(node))
|
|
686
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- handler refs are stable, rebuild only on data changes
|
|
687
|
-
}, [
|
|
688
|
-
activeCollections,
|
|
689
|
-
entriesState,
|
|
690
|
-
onCreateEntry,
|
|
691
|
-
handleCreateEntry,
|
|
692
|
-
contentRoot,
|
|
693
|
-
currentBranch,
|
|
694
|
-
])
|
|
695
|
-
|
|
696
|
-
// Tree expansion state - persists across drawer close/open
|
|
697
|
-
const treeExpandedStateRef = useRef<Record<string, boolean>>({})
|
|
698
|
-
|
|
699
|
-
// Tree controller ref for collapse/expand all functionality
|
|
700
|
-
const treeControllerRef = useRef<TreeController | null>(null)
|
|
701
|
-
|
|
702
|
-
const handleTreeControllerReady = (controller: TreeController) => {
|
|
703
|
-
treeControllerRef.current = controller
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
const handleExpandedStateChange = (state: Record<string, boolean>) => {
|
|
707
|
-
treeExpandedStateRef.current = state
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
const handleCollapseAll = () => {
|
|
711
|
-
treeControllerRef.current?.collapseAllNodes()
|
|
712
|
-
// Sync the ref to empty state
|
|
713
|
-
treeExpandedStateRef.current = {}
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
const handleExpandAll = () => {
|
|
717
|
-
treeControllerRef.current?.expandAllNodes()
|
|
718
|
-
// Sync the ref with all expanded nodes from controller
|
|
719
|
-
treeExpandedStateRef.current = treeControllerRef.current?.expandedState ?? {}
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
const previewFrameData = Object.keys(previewData).length > 0 ? previewData : effectiveValue
|
|
723
|
-
|
|
724
|
-
// Helper component for centered messages
|
|
725
|
-
const CenteredMessage = ({ children }: { children: React.ReactNode }) => (
|
|
726
|
-
<div
|
|
727
|
-
style={{
|
|
728
|
-
display: 'flex',
|
|
729
|
-
alignItems: 'center',
|
|
730
|
-
justifyContent: 'center',
|
|
731
|
-
height: '100%',
|
|
732
|
-
}}
|
|
733
|
-
>
|
|
734
|
-
<Text size="sm" c="dimmed">
|
|
735
|
-
{children}
|
|
736
|
-
</Text>
|
|
737
|
-
</div>
|
|
738
|
-
)
|
|
739
|
-
|
|
740
|
-
const defaultPreview =
|
|
741
|
-
currentEntry?.previewSrc && previewFrameData ? (
|
|
742
|
-
<PreviewFrame
|
|
743
|
-
src={currentEntry.previewSrc}
|
|
744
|
-
path={currentEntry.previewSrc}
|
|
745
|
-
data={previewFrameData}
|
|
746
|
-
isLoading={previewLoadingState}
|
|
747
|
-
style={{
|
|
748
|
-
width: '100%',
|
|
749
|
-
height: '100%',
|
|
750
|
-
border: '1px solid var(--mantine-color-gray-3)',
|
|
751
|
-
}}
|
|
752
|
-
highlightEnabled={highlightEnabled}
|
|
753
|
-
/>
|
|
754
|
-
) : (
|
|
755
|
-
<Paper
|
|
756
|
-
withBorder
|
|
757
|
-
shadow="xs"
|
|
758
|
-
h="100%"
|
|
759
|
-
bg="white"
|
|
760
|
-
style={{
|
|
761
|
-
display: 'flex',
|
|
762
|
-
alignItems: 'center',
|
|
763
|
-
justifyContent: 'center',
|
|
764
|
-
}}
|
|
765
|
-
>
|
|
766
|
-
<Text size="sm" c="dimmed">
|
|
767
|
-
Select an item to start editing.
|
|
768
|
-
</Text>
|
|
769
|
-
</Paper>
|
|
770
|
-
)
|
|
771
|
-
|
|
772
|
-
const sidebarWidth = 64
|
|
773
|
-
const footerHeight = 40
|
|
774
|
-
|
|
775
|
-
const headerTitle = currentEntry?.label ?? currentEntry?.slug ?? title
|
|
776
|
-
const breadcrumbSegments = useMemo(
|
|
777
|
-
() => buildBreadcrumbSegments(currentEntry, collectionLabels),
|
|
778
|
-
[collectionLabels, currentEntry],
|
|
779
|
-
)
|
|
780
|
-
|
|
781
|
-
return (
|
|
782
|
-
<CanopyCMSProvider {...(themeOptions ?? {})}>
|
|
783
|
-
<Box bg="gray.0" style={{ minHeight: '100vh', width: '100%' }}>
|
|
784
|
-
<EditorHeader
|
|
785
|
-
ref={headerRef}
|
|
786
|
-
siteTitle={siteTitle}
|
|
787
|
-
siteSubtitle={siteSubtitle}
|
|
788
|
-
headerTitle={headerTitle}
|
|
789
|
-
currentEntry={currentEntry}
|
|
790
|
-
branchName={branchNameState}
|
|
791
|
-
operatingMode={operatingMode}
|
|
792
|
-
branchStatus={currentBranch?.status}
|
|
793
|
-
busy={busy}
|
|
794
|
-
breadcrumbSegments={breadcrumbSegments}
|
|
795
|
-
editedFiles={editedFiles}
|
|
796
|
-
modifiedCount={modifiedCount}
|
|
797
|
-
unresolvedCommentCount={comments.filter((t) => !t.resolved).length}
|
|
798
|
-
comments={comments}
|
|
799
|
-
hasUnsavedChanges={isSelectedDirty()}
|
|
800
|
-
userContext={userContext}
|
|
801
|
-
branchCreatedBy={currentBranch?.createdBy}
|
|
802
|
-
branchAccess={currentBranch?.access}
|
|
803
|
-
onNavigatorOpen={() => setNavigatorOpen(true)}
|
|
804
|
-
onFileReload={handleReload}
|
|
805
|
-
onFileDiscardDraft={handleDiscardFileDraft}
|
|
806
|
-
onEntrySelect={setSelectedPath}
|
|
807
|
-
onBranchReloadData={handleReloadBranchData}
|
|
808
|
-
onBranchDiscardDrafts={handleDiscardDrafts}
|
|
809
|
-
onBranchManagerOpen={() => setBranchManagerOpen(true)}
|
|
810
|
-
onCommentsPanelOpen={() => setCommentsPanelOpen(true)}
|
|
811
|
-
onSave={handleSave}
|
|
812
|
-
onSubmit={() => branchNameState && handleSubmit(branchNameState)}
|
|
813
|
-
onWithdraw={() => branchNameState && handleWithdraw(branchNameState)}
|
|
814
|
-
/>
|
|
815
|
-
|
|
816
|
-
<Box
|
|
817
|
-
style={{
|
|
818
|
-
paddingTop: headerHeight,
|
|
819
|
-
paddingBottom: footerHeight,
|
|
820
|
-
paddingRight: sidebarWidth,
|
|
821
|
-
minHeight: '100vh',
|
|
822
|
-
width: '100%',
|
|
823
|
-
}}
|
|
824
|
-
>
|
|
825
|
-
<Box
|
|
826
|
-
style={{
|
|
827
|
-
height: `calc(100vh - ${headerHeight + footerHeight}px)`,
|
|
828
|
-
minHeight: 0,
|
|
829
|
-
position: 'relative',
|
|
830
|
-
}}
|
|
831
|
-
>
|
|
832
|
-
<Box style={{ flex: 1, minHeight: 0, height: '100%', width: '100%' }}>
|
|
833
|
-
<EditorPanes
|
|
834
|
-
layout={layout}
|
|
835
|
-
onLayoutChange={(next) => setLayout(next)}
|
|
836
|
-
preview={
|
|
837
|
-
renderPreview && currentEntry
|
|
838
|
-
? renderPreview(currentEntry, effectiveValue)
|
|
839
|
-
: defaultPreview
|
|
840
|
-
}
|
|
841
|
-
form={
|
|
842
|
-
!currentEntry ? (
|
|
843
|
-
<CenteredMessage>Select an item to start editing.</CenteredMessage>
|
|
844
|
-
) : currentEntry.canEdit === false ? (
|
|
845
|
-
<CenteredMessage>
|
|
846
|
-
You don't have permission to edit this content.
|
|
847
|
-
</CenteredMessage>
|
|
848
|
-
) : schema.length > 0 && effectiveValue ? (
|
|
849
|
-
<FormRenderer
|
|
850
|
-
fields={schema}
|
|
851
|
-
value={effectiveValue}
|
|
852
|
-
onChange={(next) => {
|
|
853
|
-
const contentId = currentEntry?.contentId
|
|
854
|
-
if (contentId) {
|
|
855
|
-
setDrafts((prev) => ({ ...prev, [contentId]: next }))
|
|
856
|
-
}
|
|
857
|
-
}}
|
|
858
|
-
branch={branchNameState}
|
|
859
|
-
onResolvedValueChange={setPreviewData}
|
|
860
|
-
onLoadingStateChange={setPreviewLoadingState}
|
|
861
|
-
comments={comments}
|
|
862
|
-
currentEntryPath={selectedPath}
|
|
863
|
-
currentUserId={currentUser}
|
|
864
|
-
canResolve={canResolveComments}
|
|
865
|
-
focusedFieldPath={focusedFieldPath}
|
|
866
|
-
highlightThreadId={highlightThreadId}
|
|
867
|
-
onAddComment={handleAddComment}
|
|
868
|
-
onResolveThread={handleResolveThread}
|
|
869
|
-
conflictNotice={
|
|
870
|
-
!!(
|
|
871
|
-
currentEntry?.contentId &&
|
|
872
|
-
currentBranch?.conflictFiles?.includes(currentEntry.contentId)
|
|
873
|
-
)
|
|
874
|
-
}
|
|
875
|
-
/>
|
|
876
|
-
) : (
|
|
877
|
-
<CenteredMessage>No fields to edit.</CenteredMessage>
|
|
878
|
-
)
|
|
879
|
-
}
|
|
880
|
-
/>
|
|
881
|
-
</Box>
|
|
882
|
-
<EditorSidebar
|
|
883
|
-
layout={layout}
|
|
884
|
-
highlightEnabled={highlightEnabled}
|
|
885
|
-
sidebarWidth={sidebarWidth}
|
|
886
|
-
headerHeight={headerHeight}
|
|
887
|
-
footerHeight={footerHeight}
|
|
888
|
-
onLayoutChange={setLayout}
|
|
889
|
-
onHighlightToggle={() => setHighlightEnabled(!highlightEnabled)}
|
|
890
|
-
onPermissionManagerOpen={() => setPermissionManagerOpen(true)}
|
|
891
|
-
onGroupManagerOpen={() => setGroupManagerOpen(true)}
|
|
892
|
-
AccountComponent={AccountComponent}
|
|
893
|
-
onAccountClick={onAccountClick}
|
|
894
|
-
onLogoutClick={onLogoutClick}
|
|
895
|
-
/>
|
|
896
|
-
</Box>
|
|
897
|
-
</Box>
|
|
898
|
-
|
|
899
|
-
<EditorFooter />
|
|
900
|
-
|
|
901
|
-
<Drawer.Root
|
|
902
|
-
opened={navigatorOpen}
|
|
903
|
-
onClose={() => setNavigatorOpen(false)}
|
|
904
|
-
position="left"
|
|
905
|
-
size={360}
|
|
906
|
-
>
|
|
907
|
-
<Drawer.Overlay blur={2} />
|
|
908
|
-
<Drawer.Content>
|
|
909
|
-
<Drawer.Header>
|
|
910
|
-
<Drawer.Title>Content</Drawer.Title>
|
|
911
|
-
<Group gap="xs">
|
|
912
|
-
{navCollections &&
|
|
913
|
-
navCollections.length > 0 &&
|
|
914
|
-
(navCollections[0].onAdd || navCollections[0].onAddSubCollection) && (
|
|
915
|
-
<Menu shadow="md" width={200} withinPortal position="bottom-end">
|
|
916
|
-
<Menu.Target>
|
|
917
|
-
<ActionIcon
|
|
918
|
-
variant="subtle"
|
|
919
|
-
color="gray"
|
|
920
|
-
size="sm"
|
|
921
|
-
aria-label="Content actions"
|
|
922
|
-
>
|
|
923
|
-
<IconDots size={16} />
|
|
924
|
-
</ActionIcon>
|
|
925
|
-
</Menu.Target>
|
|
926
|
-
<Menu.Dropdown>
|
|
927
|
-
{navCollections[0].onAdd && (
|
|
928
|
-
<Menu.Item
|
|
929
|
-
leftSection={<IconPlus size={14} />}
|
|
930
|
-
onClick={() => navCollections[0].onAdd?.()}
|
|
931
|
-
>
|
|
932
|
-
Add Entry
|
|
933
|
-
</Menu.Item>
|
|
934
|
-
)}
|
|
935
|
-
{navCollections[0].onAddSubCollection && (
|
|
936
|
-
<Menu.Item
|
|
937
|
-
leftSection={<IconFolderPlus size={14} />}
|
|
938
|
-
onClick={() => navCollections[0].onAddSubCollection?.()}
|
|
939
|
-
>
|
|
940
|
-
Add Collection
|
|
941
|
-
</Menu.Item>
|
|
942
|
-
)}
|
|
943
|
-
</Menu.Dropdown>
|
|
944
|
-
</Menu>
|
|
945
|
-
)}
|
|
946
|
-
<ActionIcon
|
|
947
|
-
variant="subtle"
|
|
948
|
-
color="gray"
|
|
949
|
-
size="sm"
|
|
950
|
-
onClick={handleCollapseAll}
|
|
951
|
-
title="Collapse all folders"
|
|
952
|
-
aria-label="Collapse all folders"
|
|
953
|
-
>
|
|
954
|
-
<IconChevronUp size={16} />
|
|
955
|
-
</ActionIcon>
|
|
956
|
-
<ActionIcon
|
|
957
|
-
variant="subtle"
|
|
958
|
-
color="gray"
|
|
959
|
-
size="sm"
|
|
960
|
-
onClick={handleExpandAll}
|
|
961
|
-
title="Expand all folders"
|
|
962
|
-
aria-label="Expand all folders"
|
|
963
|
-
>
|
|
964
|
-
<IconChevronDown size={16} />
|
|
965
|
-
</ActionIcon>
|
|
966
|
-
<Drawer.CloseButton />
|
|
967
|
-
</Group>
|
|
968
|
-
</Drawer.Header>
|
|
969
|
-
<Drawer.Body p={0}>
|
|
970
|
-
<Box px="md">
|
|
971
|
-
<EntryNavigator
|
|
972
|
-
collections={navCollections}
|
|
973
|
-
items={
|
|
974
|
-
navCollections
|
|
975
|
-
? undefined
|
|
976
|
-
: entriesState.map((e) => ({
|
|
977
|
-
path: e.path,
|
|
978
|
-
label: e.label,
|
|
979
|
-
status: e.status,
|
|
980
|
-
}))
|
|
981
|
-
}
|
|
982
|
-
selectedPath={selectedPath}
|
|
983
|
-
onSelect={(id) => {
|
|
984
|
-
setSelectedPath(id)
|
|
985
|
-
setNavigatorOpen(false)
|
|
986
|
-
}}
|
|
987
|
-
onTreeControllerReady={handleTreeControllerReady}
|
|
988
|
-
expandedStateRef={treeExpandedStateRef}
|
|
989
|
-
onExpandedStateChange={handleExpandedStateChange}
|
|
990
|
-
onDeleteEntry={handleDeleteEntry}
|
|
991
|
-
onRenameEntry={handleRenameEntry}
|
|
992
|
-
onReorderEntry={handleReorderEntry}
|
|
993
|
-
hiddenRootPath={hiddenRootPath}
|
|
994
|
-
/>
|
|
995
|
-
</Box>
|
|
996
|
-
</Drawer.Body>
|
|
997
|
-
</Drawer.Content>
|
|
998
|
-
</Drawer.Root>
|
|
999
|
-
<Drawer
|
|
1000
|
-
opened={branchManagerOpen}
|
|
1001
|
-
onClose={() => setBranchManagerOpen(false)}
|
|
1002
|
-
position="right"
|
|
1003
|
-
title={
|
|
1004
|
-
<div>
|
|
1005
|
-
<Title order={4}>Branches</Title>
|
|
1006
|
-
<Text size="xs" c="dimmed">
|
|
1007
|
-
Manage access, status, and lifecycle
|
|
1008
|
-
</Text>
|
|
1009
|
-
</div>
|
|
1010
|
-
}
|
|
1011
|
-
padding="md"
|
|
1012
|
-
size={420}
|
|
1013
|
-
overlayProps={{ blur: 2 }}
|
|
1014
|
-
>
|
|
1015
|
-
<BranchManager
|
|
1016
|
-
branches={branchSummaries}
|
|
1017
|
-
mode={operatingMode}
|
|
1018
|
-
user={userContext}
|
|
1019
|
-
onSelect={async (name) => {
|
|
1020
|
-
try {
|
|
1021
|
-
await handleBranchChange(name)
|
|
1022
|
-
setBranchManagerOpen(false)
|
|
1023
|
-
} catch (err) {
|
|
1024
|
-
console.error('Branch change failed or was cancelled:', err)
|
|
1025
|
-
// Don't close branch manager if there was an error or user cancelled
|
|
1026
|
-
}
|
|
1027
|
-
}}
|
|
1028
|
-
onCreate={(branch) => {
|
|
1029
|
-
handleCreateBranch(branch).catch((err) => console.error(err))
|
|
1030
|
-
}}
|
|
1031
|
-
onSubmit={(name) => {
|
|
1032
|
-
handleSubmit(name).catch((err) => console.error(err))
|
|
1033
|
-
}}
|
|
1034
|
-
onWithdraw={(name) => {
|
|
1035
|
-
handleWithdraw(name).catch((err) => console.error(err))
|
|
1036
|
-
}}
|
|
1037
|
-
onRequestChanges={(name) => {
|
|
1038
|
-
handleRequestChanges(name).catch((err) => console.error(err))
|
|
1039
|
-
}}
|
|
1040
|
-
onDelete={(name) => {
|
|
1041
|
-
handleDelete(name).catch((err) => console.error(err))
|
|
1042
|
-
}}
|
|
1043
|
-
onClose={() => setBranchManagerOpen(false)}
|
|
1044
|
-
comments={comments}
|
|
1045
|
-
currentUserId={currentUser}
|
|
1046
|
-
canResolve={canResolveComments}
|
|
1047
|
-
onAddComment={handleAddComment}
|
|
1048
|
-
onResolveThread={handleResolveThread}
|
|
1049
|
-
highlightThreadId={highlightThreadId}
|
|
1050
|
-
onGetUserMetadata={handleGetUserMetadata}
|
|
1051
|
-
/>
|
|
1052
|
-
</Drawer>
|
|
1053
|
-
{commentsPanelOpen && branchNameState && (
|
|
1054
|
-
<CommentsPanel
|
|
1055
|
-
branchName={branchNameState}
|
|
1056
|
-
comments={comments}
|
|
1057
|
-
canResolve={true}
|
|
1058
|
-
onAddComment={handleAddComment}
|
|
1059
|
-
onResolveThread={handleResolveThread}
|
|
1060
|
-
onClose={() => setCommentsPanelOpen(false)}
|
|
1061
|
-
onJumpToField={handleJumpToField}
|
|
1062
|
-
onGetUserMetadata={handleGetUserMetadata}
|
|
1063
|
-
onJumpToEntry={handleJumpToEntry}
|
|
1064
|
-
onJumpToBranch={handleJumpToBranch}
|
|
1065
|
-
/>
|
|
1066
|
-
)}
|
|
1067
|
-
|
|
1068
|
-
{/* Group Manager Modal */}
|
|
1069
|
-
<Drawer
|
|
1070
|
-
opened={groupManagerOpen}
|
|
1071
|
-
onClose={() => setGroupManagerOpen(false)}
|
|
1072
|
-
position="right"
|
|
1073
|
-
title={
|
|
1074
|
-
<div>
|
|
1075
|
-
<Title order={4}>Groups</Title>
|
|
1076
|
-
<Text size="xs" c="dimmed">
|
|
1077
|
-
Manage groups and organizations
|
|
1078
|
-
</Text>
|
|
1079
|
-
</div>
|
|
1080
|
-
}
|
|
1081
|
-
padding="md"
|
|
1082
|
-
size={600}
|
|
1083
|
-
overlayProps={{ blur: 2 }}
|
|
1084
|
-
>
|
|
1085
|
-
<GroupManager
|
|
1086
|
-
internalGroups={groupsData}
|
|
1087
|
-
loading={groupsLoading}
|
|
1088
|
-
canEdit={true}
|
|
1089
|
-
onSave={handleSaveGroups}
|
|
1090
|
-
onSearchUsers={handleSearchUsers}
|
|
1091
|
-
onGetUserMetadata={handleGetUserMetadata}
|
|
1092
|
-
onSearchExternalGroups={handleSearchExternalGroups}
|
|
1093
|
-
onClose={() => setGroupManagerOpen(false)}
|
|
1094
|
-
/>
|
|
1095
|
-
</Drawer>
|
|
1096
|
-
|
|
1097
|
-
{/* Permission Manager Modal */}
|
|
1098
|
-
<Drawer
|
|
1099
|
-
opened={permissionManagerOpen}
|
|
1100
|
-
onClose={() => setPermissionManagerOpen(false)}
|
|
1101
|
-
position="right"
|
|
1102
|
-
title={
|
|
1103
|
-
<div>
|
|
1104
|
-
<Title order={4}>Permissions</Title>
|
|
1105
|
-
<Text size="xs" c="dimmed">
|
|
1106
|
-
Manage content access by path (read, edit, review)
|
|
1107
|
-
</Text>
|
|
1108
|
-
</div>
|
|
1109
|
-
}
|
|
1110
|
-
padding="md"
|
|
1111
|
-
size={700}
|
|
1112
|
-
overlayProps={{ blur: 2 }}
|
|
1113
|
-
>
|
|
1114
|
-
<PermissionManager
|
|
1115
|
-
collections={activeCollections}
|
|
1116
|
-
contentRoot={contentRoot}
|
|
1117
|
-
permissions={permissionsData}
|
|
1118
|
-
loading={permissionsLoading}
|
|
1119
|
-
canEdit={true}
|
|
1120
|
-
onSave={handleSavePermissions}
|
|
1121
|
-
onSearchUsers={handleSearchUsers}
|
|
1122
|
-
onGetUserMetadata={handleGetUserMetadata}
|
|
1123
|
-
onListGroups={handleListGroups}
|
|
1124
|
-
onClose={() => setPermissionManagerOpen(false)}
|
|
1125
|
-
/>
|
|
1126
|
-
</Drawer>
|
|
1127
|
-
|
|
1128
|
-
{/* Collection Editor Modal */}
|
|
1129
|
-
<CollectionEditor
|
|
1130
|
-
isOpen={collectionEditorOpen}
|
|
1131
|
-
editingCollection={editingCollection}
|
|
1132
|
-
parentPath={collectionEditorParentPath}
|
|
1133
|
-
availableSchemas={availableSchemas}
|
|
1134
|
-
onSave={handleCollectionSave}
|
|
1135
|
-
onAddEntryType={
|
|
1136
|
-
editingCollection ? (path, entryType) => addEntryType(path, entryType) : undefined
|
|
1137
|
-
}
|
|
1138
|
-
onUpdateEntryType={
|
|
1139
|
-
editingCollection
|
|
1140
|
-
? (path, name, updates) => updateEntryType(path, name, updates)
|
|
1141
|
-
: undefined
|
|
1142
|
-
}
|
|
1143
|
-
onRemoveEntryType={
|
|
1144
|
-
editingCollection ? (path, name) => removeEntryType(path, name) : undefined
|
|
1145
|
-
}
|
|
1146
|
-
onClose={handleCloseCollectionEditor}
|
|
1147
|
-
isSaving={schemaLoading}
|
|
1148
|
-
error={collectionEditorError}
|
|
1149
|
-
/>
|
|
1150
|
-
|
|
1151
|
-
{/* Rename Entry Modal */}
|
|
1152
|
-
{renamingEntry && (
|
|
1153
|
-
<RenameEntryModal
|
|
1154
|
-
isOpen={renameModalOpen}
|
|
1155
|
-
entryLabel={renamingEntry.label}
|
|
1156
|
-
currentSlug={renamingEntry.slug || ''}
|
|
1157
|
-
onSave={handleRenameSubmit}
|
|
1158
|
-
onClose={() => {
|
|
1159
|
-
setRenameModalOpen(false)
|
|
1160
|
-
setRenamingEntry(null)
|
|
1161
|
-
setRenameModalError(null)
|
|
1162
|
-
}}
|
|
1163
|
-
isSaving={renameModalSaving}
|
|
1164
|
-
error={renameModalError}
|
|
1165
|
-
/>
|
|
1166
|
-
)}
|
|
1167
|
-
|
|
1168
|
-
{/* Entry Create Modal */}
|
|
1169
|
-
{createModalCollection && (
|
|
1170
|
-
<EntryCreateModal
|
|
1171
|
-
isOpen={createModalOpen}
|
|
1172
|
-
collectionLabel={createModalCollection.label || createModalCollection.name}
|
|
1173
|
-
entryTypes={
|
|
1174
|
-
createModalCollection.entryTypes?.map((et) => ({
|
|
1175
|
-
name: et.name,
|
|
1176
|
-
label: et.label,
|
|
1177
|
-
format: et.format,
|
|
1178
|
-
default: et.default,
|
|
1179
|
-
maxItems: et.maxItems,
|
|
1180
|
-
})) || []
|
|
1181
|
-
}
|
|
1182
|
-
onCreate={handleCreateModalSubmit}
|
|
1183
|
-
onClose={closeCreateModal}
|
|
1184
|
-
isCreating={createModalCreating}
|
|
1185
|
-
error={createModalError}
|
|
1186
|
-
/>
|
|
1187
|
-
)}
|
|
1188
|
-
|
|
1189
|
-
{/* Delete Collection Confirmation Modal */}
|
|
1190
|
-
<ConfirmDeleteModal
|
|
1191
|
-
isOpen={deleteCollectionModalOpen}
|
|
1192
|
-
title="Delete Collection"
|
|
1193
|
-
message="Are you sure you want to delete this collection? This cannot be undone."
|
|
1194
|
-
confirmLabel="Delete Collection"
|
|
1195
|
-
onConfirm={confirmDeleteCollection}
|
|
1196
|
-
onClose={() => {
|
|
1197
|
-
setDeleteCollectionModalOpen(false)
|
|
1198
|
-
setDeletingCollectionPath(null)
|
|
1199
|
-
}}
|
|
1200
|
-
loading={deleteInProgress}
|
|
1201
|
-
/>
|
|
1202
|
-
|
|
1203
|
-
{/* Delete Entry Confirmation Modal */}
|
|
1204
|
-
<ConfirmDeleteModal
|
|
1205
|
-
isOpen={deleteEntryModalOpen}
|
|
1206
|
-
title="Delete Entry"
|
|
1207
|
-
message="Are you sure you want to delete this entry? This cannot be undone."
|
|
1208
|
-
confirmLabel="Delete Entry"
|
|
1209
|
-
onConfirm={confirmDeleteEntry}
|
|
1210
|
-
onClose={() => {
|
|
1211
|
-
setDeleteEntryModalOpen(false)
|
|
1212
|
-
setDeletingEntryPath(null)
|
|
1213
|
-
}}
|
|
1214
|
-
loading={deleteInProgress}
|
|
1215
|
-
/>
|
|
1216
|
-
</Box>
|
|
1217
|
-
</CanopyCMSProvider>
|
|
1218
|
-
)
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
export default Editor
|