mirror of
https://github.com/docmost/docmost.git
synced 2026-07-09 20:04:37 +10:00
fix: templates ui fixes (#2316)
* fix: editor menus * fix: templates creation UI gating
This commit is contained in:
@@ -990,6 +990,8 @@
|
||||
"Are you sure you want to delete this template?": "Are you sure you want to delete this template?",
|
||||
"Template scope updated": "Template scope updated",
|
||||
"Choose which space this template belongs to": "Choose which space this template belongs to",
|
||||
"Only workspace admins can create global templates.": "Only workspace admins can create global templates.",
|
||||
"You need edit access to this space to create templates.": "You need edit access to this space to create templates.",
|
||||
"Scope": "Scope",
|
||||
"Select scope": "Select scope",
|
||||
"Title": "Title",
|
||||
|
||||
@@ -38,6 +38,10 @@ import { FixedToolbar } from "@/features/editor/components/fixed-toolbar/fixed-t
|
||||
import { EditorLinkMenu } from "@/features/editor/components/link/link-menu";
|
||||
import { EditorBubbleMenu } from "@/features/editor/components/bubble-menu/bubble-menu";
|
||||
import { EditorAiMenu } from "@/ee/ai/components/editor/ai-menu/ai-menu";
|
||||
import TableMenu from "@/features/editor/components/table/table-menu.tsx";
|
||||
import { TableHandlesLayer } from "@/features/editor/components/table/handle/table-handles-layer";
|
||||
import CalloutMenu from "@/features/editor/components/callout/callout-menu.tsx";
|
||||
import ColumnsMenu from "@/features/editor/components/columns/columns-menu.tsx";
|
||||
|
||||
import classes from "./template-editor.module.css";
|
||||
|
||||
@@ -85,6 +89,8 @@ export default function TemplateEditor() {
|
||||
extensions: templateExtensions,
|
||||
content: "",
|
||||
editorProps: {
|
||||
scrollThreshold: 80,
|
||||
scrollMargin: 80,
|
||||
handleDOMEvents: {
|
||||
keydown: (_view, event) => {
|
||||
if (["ArrowUp", "ArrowDown", "Enter"].includes(event.key)) {
|
||||
@@ -398,9 +404,18 @@ export default function TemplateEditor() {
|
||||
<EditorAiMenu editor={editor} />
|
||||
<EditorBubbleMenu editor={editor} templateMode />
|
||||
<EditorLinkMenu editor={editor} />
|
||||
<TableMenu editor={editor} />
|
||||
<TableHandlesLayer editor={editor} />
|
||||
<CalloutMenu editor={editor} />
|
||||
<ColumnsMenu editor={editor} />
|
||||
</>
|
||||
)}
|
||||
<div style={{ paddingBottom: "20vh" }} />
|
||||
<div
|
||||
onClick={() => {
|
||||
if (editor && !editor.isDestroyed) editor.commands.focus("end");
|
||||
}}
|
||||
style={{ paddingBottom: "20vh" }}
|
||||
/>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -29,11 +29,17 @@ import UseTemplateModal from "@/ee/template/components/use-template-modal";
|
||||
import TemplatePreviewModal from "@/ee/template/components/template-preview-modal";
|
||||
import useUserRole from "@/hooks/use-user-role";
|
||||
import CreateTemplateModal from "@/ee/template/components/create-template-modal";
|
||||
import { useAtomValue } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom";
|
||||
|
||||
export default function TemplateList() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const { isAdmin: isWorkspaceAdmin } = useUserRole();
|
||||
const workspace = useAtomValue(workspaceAtom);
|
||||
const canCreateTemplate =
|
||||
isWorkspaceAdmin ||
|
||||
workspace?.settings?.templates?.allowMemberTemplates === true;
|
||||
const [spaceFilter, setSpaceFilter] = useState<string | null>(null);
|
||||
const [selectedTemplate, setSelectedTemplate] = useState<ITemplate | null>(
|
||||
null,
|
||||
@@ -105,7 +111,7 @@ export default function TemplateList() {
|
||||
<Container size="900" pt="xl">
|
||||
<Group justify="space-between" mb="xl">
|
||||
<Title order={3}>{t("Templates")}</Title>
|
||||
{isWorkspaceAdmin && (
|
||||
{canCreateTemplate && (
|
||||
<Button
|
||||
leftSection={<IconPlus size={16} />}
|
||||
onClick={openCreateModal}
|
||||
|
||||
@@ -76,7 +76,7 @@ export function useCreateTemplateMutation() {
|
||||
onError: (error) => {
|
||||
const errorMessage = error["response"]?.data?.message;
|
||||
notifications.show({
|
||||
message: errorMessage || t("Failed to create template"),
|
||||
message: errorMessage ? t(errorMessage) : t("Failed to create template"),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
@@ -117,7 +117,7 @@ export function useUpdateTemplateMutation() {
|
||||
onError: (error) => {
|
||||
const errorMessage = error["response"]?.data?.message;
|
||||
notifications.show({
|
||||
message: errorMessage || t("Failed to update template"),
|
||||
message: errorMessage ? t(errorMessage) : t("Failed to update template"),
|
||||
color: "red",
|
||||
});
|
||||
},
|
||||
|
||||
+1
-1
Submodule apps/server/src/ee updated: 4ab5ff2198...224d73f925
Reference in New Issue
Block a user