Move template management to settings (#5811)

This commit is contained in:
Tom Moor
2023-09-10 15:46:12 -04:00
committed by GitHub
parent ac068c0c07
commit 0856f5f6ae
32 changed files with 432 additions and 267 deletions

View File

@@ -1,13 +1,16 @@
import { addDays, differenceInDays } from "date-fns";
import { t } from "i18next";
import floor from "lodash/floor";
import { action, autorun, computed, observable, set } from "mobx";
import { ExportContentType } from "@shared/types";
import type { NavigationNode } from "@shared/types";
import Storage from "@shared/utils/Storage";
import { isRTL } from "@shared/utils/rtl";
import slugify from "@shared/utils/slugify";
import DocumentsStore from "~/stores/DocumentsStore";
import User from "~/models/User";
import { client } from "~/utils/ApiClient";
import { settingsPath } from "~/utils/routeHelpers";
import View from "./View";
import ParanoidModel from "./base/ParanoidModel";
import Field from "./decorators/Field";
@@ -122,6 +125,9 @@ export default class Document extends ParanoidModel {
@observable
archivedAt: string;
/**
* @deprecated Use path instead
*/
@observable
url: string;
@@ -153,9 +159,21 @@ export default class Document extends ParanoidModel {
return isRTL(this.title);
}
@computed
get path(): string {
const prefix = this.template ? settingsPath("templates") : "/doc";
if (!this.title) {
return `${prefix}/untitled-${this.urlId}`;
}
const slugifiedTitle = slugify(this.title);
return `${prefix}/${slugifiedTitle}-${this.urlId}`;
}
@computed
get noun(): string {
return this.template ? "template" : "document";
return this.template ? t("template") : t("document");
}
@computed