-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
documentTypes
prop of PagesPage
also accept a function mappi…
…ng categories to document types (#2116) Previously, only the supported documentTypes of the current category could be passed to the `PagesPage`. That made it impossible to verify if a document can be moved to another category. If a document was moved to a category that didn't support its type, the PageTree crashed. If a mapping function is passed to `documentTypes`, documents can only be moved to categories that support their type. ```diff <PagesPage - documentTypes={pageTreeDocumentTypes} + documentTypes={(category): Record<DocumentType, DocumentInterface> => { + if (category === "TopMenu") { + return { + Page, + PredefinedPage, + }; + } + + return { + Page, + PredefinedPage, + Link, + }; + }} // ... /> ``` Note: If the move is valid is still only verified in the admin interface. However, you have to work actively against the UI to make the move.
- Loading branch information
1 parent
2085ff7
commit acfcef9
Showing
5 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
"@comet/cms-admin": minor | ||
--- | ||
|
||
The `documentTypes` prop of `PagesPage` now also accepts a function mapping categories to document types | ||
|
||
Previously, only the supported documentTypes of the current category could be passed to the `PagesPage`. | ||
That made it impossible to verify if a document can be moved to another category. | ||
If a document was moved to a category that didn't support its type, the PageTree crashed. | ||
|
||
If a mapping function is passed to `documentTypes`, documents can only be moved to categories that support their type. | ||
|
||
```diff | ||
<PagesPage | ||
- documentTypes={pageTreeDocumentTypes} | ||
+ documentTypes={(category): Record<DocumentType, DocumentInterface> => { | ||
+ if (category === "TopMenu") { | ||
+ return { | ||
+ Page, | ||
+ PredefinedPage, | ||
+ }; | ||
+ } | ||
+ | ||
+ return { | ||
+ Page, | ||
+ PredefinedPage, | ||
+ Link, | ||
+ }; | ||
+ }} | ||
// ... | ||
/> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters