diff --git a/app/menus/DocumentMenu.js b/app/menus/DocumentMenu.js
index 2b9138f310..cba822ce2b 100644
--- a/app/menus/DocumentMenu.js
+++ b/app/menus/DocumentMenu.js
@@ -331,7 +331,7 @@ function DocumentMenu({
to: newDocumentUrl(collection?.id, {
parentDocumentId: document.id,
}),
- visible: !!can.createChildDocument,
+ visible: !!can.createChildDocument && !!collection?.id,
icon: ,
},
{
diff --git a/app/scenes/Document/components/Header.js b/app/scenes/Document/components/Header.js
index 95ef119e0f..ab7b7cbb6a 100644
--- a/app/scenes/Document/components/Header.js
+++ b/app/scenes/Document/components/Header.js
@@ -178,7 +178,7 @@ function DocumentHeader({
)}
- {!isEditing && !isMobile && !isTemplate && hasCollection && (
+ {!isEditing && !isMobile && !isTemplate && (
diff --git a/app/scenes/Document/components/PublishDialog.js b/app/scenes/Document/components/PublishDialog.js
index 59e4613fc2..7f3b4a0699 100644
--- a/app/scenes/Document/components/PublishDialog.js
+++ b/app/scenes/Document/components/PublishDialog.js
@@ -53,29 +53,32 @@ const PublishDialog = ({ dialog, document, onSave }: Props) => {
}
}, []);
- const handlePublishFromModal = async (selectedPath) => {
- if (!document) return;
- if (!selectedPath) {
- showToast(t("Please select a path"));
- return;
- }
+ const handlePublishFromModal = React.useCallback(
+ async (selectedPath) => {
+ if (!document) return;
+ if (!selectedPath) {
+ showToast(t("Please select a path"));
+ return;
+ }
- if (selectedPath.type === "collection") {
- await onSave({
- done: true,
- publish: true,
- collectionId: selectedPath.collectionId,
- });
- } else {
- await onSave({
- done: true,
- publish: true,
- collectionId: selectedPath.collectionId,
- parentDocumentId: selectedPath.id,
- });
- }
- dialog.setVisible(false);
- };
+ if (selectedPath.type === "collection") {
+ await onSave({
+ done: true,
+ publish: true,
+ collectionId: selectedPath.collectionId,
+ });
+ } else {
+ await onSave({
+ done: true,
+ publish: true,
+ collectionId: selectedPath.collectionId,
+ parentDocumentId: selectedPath.id,
+ });
+ }
+ dialog.setVisible(false);
+ },
+ [dialog, document, onSave, showToast, t]
+ );
const selected = React.useCallback(
(result) => {
@@ -100,12 +103,10 @@ const PublishDialog = ({ dialog, document, onSave }: Props) => {
let paths = collections.pathsToDocuments;
paths = paths.filter((path) => {
- if (path.type === "collection" && policies.abilities(path.id).update)
- return true;
-
if (
- path.type === "document" &&
- policies.abilities(path.collectionId).update
+ (path.type === "collection" && policies.abilities(path.id).update) ||
+ (path.type === "document" &&
+ policies.abilities(path.collectionId).update)
)
return true;
@@ -164,6 +165,7 @@ const PublishDialog = ({ dialog, document, onSave }: Props) => {
const result = data[index];
return (
{
- if (path.type === "collection" && policies.abilities(path.id).update)
- return true;
-
if (
- path.type === "document" &&
- policies.abilities(path.collectionId).update
+ (path.type === "collection" && policies.abilities(path.id).update) ||
+ (path.type === "document" &&
+ policies.abilities(path.collectionId).update)
)
return true;
@@ -153,7 +151,7 @@ function DocumentMove({ document, onRequestClose }: Props) {
return (