fix: Do not copy edit path from headers
chore: Rename url -> path in routeHelpers closes #5229
This commit is contained in:
@@ -9,7 +9,12 @@ import Breadcrumb from "~/components/Breadcrumb";
|
||||
import CollectionIcon from "~/components/Icons/CollectionIcon";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import { MenuInternalLink } from "~/types";
|
||||
import { collectionUrl } from "~/utils/routeHelpers";
|
||||
import {
|
||||
archivePath,
|
||||
collectionPath,
|
||||
templatesPath,
|
||||
trashPath,
|
||||
} from "~/utils/routeHelpers";
|
||||
|
||||
type Props = {
|
||||
document: Document;
|
||||
@@ -24,7 +29,7 @@ function useCategory(document: Document): MenuInternalLink | null {
|
||||
type: "route",
|
||||
icon: <TrashIcon />,
|
||||
title: t("Trash"),
|
||||
to: "/trash",
|
||||
to: trashPath(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,7 +38,7 @@ function useCategory(document: Document): MenuInternalLink | null {
|
||||
type: "route",
|
||||
icon: <ArchiveIcon />,
|
||||
title: t("Archive"),
|
||||
to: "/archive",
|
||||
to: archivePath(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,7 +47,7 @@ function useCategory(document: Document): MenuInternalLink | null {
|
||||
type: "route",
|
||||
icon: <ShapesIcon />,
|
||||
title: t("Templates"),
|
||||
to: "/templates",
|
||||
to: templatesPath(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -66,14 +71,14 @@ const DocumentBreadcrumb: React.FC<Props> = ({
|
||||
type: "route",
|
||||
title: collection.name,
|
||||
icon: <CollectionIcon collection={collection} expanded />,
|
||||
to: collectionUrl(collection.url),
|
||||
to: collectionPath(collection.url),
|
||||
};
|
||||
} else if (document.collectionId && !collection) {
|
||||
collectionNode = {
|
||||
type: "route",
|
||||
title: t("Deleted Collection"),
|
||||
icon: undefined,
|
||||
to: collectionUrl("deleted-collection"),
|
||||
to: collectionPath("deleted-collection"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useHistory } from "react-router-dom";
|
||||
import ConfirmationDialog from "~/components/ConfirmationDialog";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import useToasts from "~/hooks/useToasts";
|
||||
import { documentUrl } from "~/utils/routeHelpers";
|
||||
import { documentPath } from "~/utils/routeHelpers";
|
||||
|
||||
type Props = {
|
||||
documentId: string;
|
||||
@@ -23,7 +23,7 @@ function DocumentTemplatizeDialog({ documentId }: Props) {
|
||||
const handleSubmit = React.useCallback(async () => {
|
||||
const template = await document?.templatize();
|
||||
if (template) {
|
||||
history.push(documentUrl(template));
|
||||
history.push(documentPath(template));
|
||||
showToast(t("Template created, go ahead and customize it"), {
|
||||
type: "info",
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ import Time from "~/components/Time";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import RevisionMenu from "~/menus/RevisionMenu";
|
||||
import Logger from "~/utils/Logger";
|
||||
import { documentHistoryUrl } from "~/utils/routeHelpers";
|
||||
import { documentHistoryPath } from "~/utils/routeHelpers";
|
||||
|
||||
type Props = {
|
||||
document: Document;
|
||||
@@ -62,7 +62,7 @@ const EventListItem = ({ event, latest, document, ...rest }: Props) => {
|
||||
icon = <EditIcon size={16} />;
|
||||
meta = t("{{userName}} edited", opts);
|
||||
to = {
|
||||
pathname: documentHistoryUrl(document, event.modelId || ""),
|
||||
pathname: documentHistoryPath(document, event.modelId || ""),
|
||||
state: { retainScrollPosition: true },
|
||||
};
|
||||
break;
|
||||
@@ -71,7 +71,7 @@ const EventListItem = ({ event, latest, document, ...rest }: Props) => {
|
||||
icon = <LightningIcon size={16} />;
|
||||
meta = t("Latest");
|
||||
to = {
|
||||
pathname: documentHistoryUrl(document),
|
||||
pathname: documentHistoryPath(document),
|
||||
state: { retainScrollPosition: true },
|
||||
};
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user