diff --git a/app/scenes/DocumentMove.tsx b/app/scenes/DocumentMove.tsx index 319c7b813..3ea204606 100644 --- a/app/scenes/DocumentMove.tsx +++ b/app/scenes/DocumentMove.tsx @@ -20,7 +20,7 @@ type Props = { }; function DocumentMove({ document }: Props) { - const { dialogs } = useStores(); + const { dialogs, policies } = useStores(); const { t } = useTranslation(); const collectionTrees = useCollectionTrees(); const [selectedPath, selectPath] = React.useState( @@ -29,9 +29,16 @@ function DocumentMove({ document }: Props) { const items = React.useMemo(() => { // Filter out the document itself and its existing parent doc, if any. - const nodes = flatten(collectionTrees.map(flattenTree)).filter( - (node) => node.id !== document.id && node.id !== document.parentDocumentId - ); + const nodes = flatten(collectionTrees.map(flattenTree)) + .filter( + (node) => + node.id !== document.id && node.id !== document.parentDocumentId + ) + .filter((node) => + node.collectionId + ? policies.get(node.collectionId)?.abilities.createDocument + : true + ); // If the document we're moving is a template, only show collections as // move targets. @@ -42,6 +49,7 @@ function DocumentMove({ document }: Props) { } return nodes; }, [ + policies, collectionTrees, document.id, document.parentDocumentId, diff --git a/app/scenes/DocumentPublish.tsx b/app/scenes/DocumentPublish.tsx index 9974696b2..da433b3a2 100644 --- a/app/scenes/DocumentPublish.tsx +++ b/app/scenes/DocumentPublish.tsx @@ -21,15 +21,20 @@ type Props = { }; function DocumentPublish({ document }: Props) { - const { dialogs } = useStores(); + const { dialogs, policies } = useStores(); const { t } = useTranslation(); const collectionTrees = useCollectionTrees(); const [selectedPath, selectPath] = React.useState( null ); const publishOptions = React.useMemo( - () => flatten(collectionTrees.map(flattenTree)), - [collectionTrees] + () => + flatten(collectionTrees.map(flattenTree)).filter((node) => + node.collectionId + ? policies.get(node.collectionId)?.abilities.createDocument + : true + ), + [policies, collectionTrees] ); const publish = async () => {