fix: Cannot edit templates in settings with separate editing mode
This commit is contained in:
@@ -265,7 +265,8 @@ function DocumentMenu({
|
|||||||
type: "route",
|
type: "route",
|
||||||
title: t("Edit"),
|
title: t("Edit"),
|
||||||
to: documentEditPath(document),
|
to: documentEditPath(document),
|
||||||
visible: !!can.update && user.separateEditMode,
|
visible:
|
||||||
|
!!can.update && user.separateEditMode && !document.template,
|
||||||
icon: <EditIcon />,
|
icon: <EditIcon />,
|
||||||
},
|
},
|
||||||
actionToMenuItem(createNestedDocument, context),
|
actionToMenuItem(createNestedDocument, context),
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import useStores from "~/hooks/useStores";
|
|||||||
import Logger from "~/utils/Logger";
|
import Logger from "~/utils/Logger";
|
||||||
import { NotFoundError, OfflineError } from "~/utils/errors";
|
import { NotFoundError, OfflineError } from "~/utils/errors";
|
||||||
import history from "~/utils/history";
|
import history from "~/utils/history";
|
||||||
import { matchDocumentEdit } from "~/utils/routeHelpers";
|
import { matchDocumentEdit, settingsPath } from "~/utils/routeHelpers";
|
||||||
import Loading from "./Loading";
|
import Loading from "./Loading";
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
@@ -71,7 +71,8 @@ function DataLoader({ match, children }: Props) {
|
|||||||
const sharedTree = document
|
const sharedTree = document
|
||||||
? documents.getSharedTree(document.id)
|
? documents.getSharedTree(document.id)
|
||||||
: undefined;
|
: undefined;
|
||||||
const isEditRoute = match.path === matchDocumentEdit;
|
const isEditRoute =
|
||||||
|
match.path === matchDocumentEdit || match.path.startsWith(settingsPath());
|
||||||
const isEditing = isEditRoute || !auth.user?.separateEditMode;
|
const isEditing = isEditRoute || !auth.user?.separateEditMode;
|
||||||
const can = usePolicy(document?.id);
|
const can = usePolicy(document?.id);
|
||||||
const location = useLocation<LocationState>();
|
const location = useLocation<LocationState>();
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ function DocumentHeader({
|
|||||||
<ShareButton document={document} />
|
<ShareButton document={document} />
|
||||||
</Action>
|
</Action>
|
||||||
)}
|
)}
|
||||||
{isEditing && (
|
{(isEditing || isTemplate) && (
|
||||||
<Action>
|
<Action>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
tooltip={t("Save")}
|
tooltip={t("Save")}
|
||||||
@@ -260,28 +260,18 @@ function DocumentHeader({
|
|||||||
placement="bottom"
|
placement="bottom"
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleSave}
|
context={context}
|
||||||
|
action={isTemplate ? navigateToTemplateSettings : undefined}
|
||||||
|
onClick={isTemplate ? undefined : handleSave}
|
||||||
disabled={savingIsDisabled}
|
disabled={savingIsDisabled}
|
||||||
neutral={isDraft}
|
neutral={isDraft}
|
||||||
|
hideIcon
|
||||||
>
|
>
|
||||||
{isDraft ? t("Save draft") : t("Done editing")}
|
{isDraft ? t("Save draft") : t("Done editing")}
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Action>
|
</Action>
|
||||||
)}
|
)}
|
||||||
{isTemplate && (
|
|
||||||
<Action>
|
|
||||||
<Button
|
|
||||||
context={context}
|
|
||||||
action={navigateToTemplateSettings}
|
|
||||||
disabled={savingIsDisabled}
|
|
||||||
neutral={isDraft}
|
|
||||||
hideIcon
|
|
||||||
>
|
|
||||||
{t("Done editing")}
|
|
||||||
</Button>
|
|
||||||
</Action>
|
|
||||||
)}
|
|
||||||
{can.update &&
|
{can.update &&
|
||||||
!isEditing &&
|
!isEditing &&
|
||||||
user?.separateEditMode &&
|
user?.separateEditMode &&
|
||||||
|
|||||||
Reference in New Issue
Block a user