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