mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
fix: Handle template delete and error cases
This commit is contained in:
@@ -18,7 +18,13 @@ import {
|
||||
createActionWithChildren,
|
||||
createInternalLinkAction,
|
||||
} from "~/actions";
|
||||
import { newDocumentPath, newTemplatePath, urlify } from "~/utils/routeHelpers";
|
||||
import history from "~/utils/history";
|
||||
import {
|
||||
newDocumentPath,
|
||||
newTemplatePath,
|
||||
settingsPath,
|
||||
urlify,
|
||||
} from "~/utils/routeHelpers";
|
||||
import { ActiveTemplateSection, TemplateSection } from "../sections";
|
||||
import Template from "~/models/Template";
|
||||
import { AvatarSize } from "~/components/Avatar";
|
||||
@@ -57,6 +63,7 @@ export const deleteTemplate = createAction({
|
||||
<ConfirmationDialog
|
||||
onSubmit={async () => {
|
||||
await template.delete();
|
||||
history.push(settingsPath("templates"));
|
||||
toast.success(t("Template deleted"));
|
||||
}}
|
||||
savingText={`${t("Deleting")}…`}
|
||||
|
||||
@@ -10,6 +10,7 @@ import Breadcrumb from "~/components/Breadcrumb";
|
||||
import Button from "~/components/Button";
|
||||
import CollectionIcon from "~/components/Icons/CollectionIcon";
|
||||
import LoadingIndicator from "~/components/LoadingIndicator";
|
||||
import Error404 from "~/scenes/Errors/Error404";
|
||||
import Scene from "~/components/Scene";
|
||||
import { TemplateForm } from "~/components/Template/TemplateForm";
|
||||
import { createInternalLinkAction } from "~/actions";
|
||||
@@ -29,7 +30,7 @@ const LoadingState = observer(function LoadingState() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { templates, ui } = useStores();
|
||||
const template = templates.get(id);
|
||||
const { request } = useRequest(() => templates.fetch(id));
|
||||
const { request, error } = useRequest(() => templates.fetch(id));
|
||||
|
||||
useEffect(() => {
|
||||
if (!template) {
|
||||
@@ -46,6 +47,10 @@ const LoadingState = observer(function LoadingState() {
|
||||
};
|
||||
}, [template, ui]);
|
||||
|
||||
if (error) {
|
||||
return <Error404 />;
|
||||
}
|
||||
|
||||
if (!template) {
|
||||
return <LoadingIndicator />;
|
||||
}
|
||||
|
||||
@@ -479,6 +479,7 @@ export class ProsemirrorHelper {
|
||||
node.attrs.href = env.URL + node.attrs.href;
|
||||
}
|
||||
if (node.content) {
|
||||
node.content = node.content.filter(Boolean);
|
||||
node.content.forEach(replace);
|
||||
}
|
||||
|
||||
@@ -502,6 +503,7 @@ export class ProsemirrorHelper {
|
||||
}
|
||||
|
||||
if (node.content) {
|
||||
node.content = node.content.filter(Boolean);
|
||||
node.content.forEach(replace);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user