feat(ee): templates (#2215)

* feat(ee): templates
* fix tree
* fix
This commit is contained in:
Philip Okugbe
2026-05-19 02:41:52 +01:00
committed by GitHub
parent 0d6538ab1a
commit 6cf8101ab3
25 changed files with 752 additions and 76 deletions
@@ -416,7 +416,9 @@ const TEMPLATE_EXCLUDED_SLASH_ITEMS = new Set([
"Video",
"File attachment",
"Draw.io (diagrams.net)",
"Excalidraw diagram",
"Excalidraw (Whiteboard)",
"Audio",
"Synced block"
]);
const TemplateSlashCommand = Command.configure({
@@ -18,6 +18,7 @@ import {
IconSettings,
IconStar,
IconStarFilled,
IconTemplate,
IconTrash,
} from "@tabler/icons-react";
import {
@@ -53,6 +54,10 @@ import {
import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
import { useToggleSidebar } from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar.ts";
import { searchSpotlight } from "@/features/search/constants";
import TemplatePickerModal from "@/ee/template/components/template-picker-modal";
import { useHasFeature } from "@/ee/hooks/use-feature";
import { Feature } from "@/ee/features";
import { ErrorBoundary } from "react-error-boundary";
export function SpaceSidebar() {
const { t } = useTranslation();
@@ -246,6 +251,11 @@ function SpaceMenu({
useDisclosure(false);
const [exportOpened, { open: openExportModal, close: closeExportModal }] =
useDisclosure(false);
const [
templatePickerOpened,
{ open: openTemplatePicker, close: closeTemplatePicker },
] = useDisclosure(false);
const hasTemplates = useHasFeature(Feature.TEMPLATES);
const { data: watchStatus } = useSpaceWatchStatusQuery(spaceId);
const watchMutation = useWatchSpaceMutation();
@@ -315,6 +325,18 @@ function SpaceMenu({
{isWatching ? t("Stop watching space") : t("Watch space")}
</Menu.Item>
{hasTemplates && canManagePages && (
<>
<Menu.Divider />
<Menu.Item
onClick={openTemplatePicker}
leftSection={<IconTemplate size={16} />}
>
{t("Templates")}
</Menu.Item>
</>
)}
{canManagePages && (
<>
<Menu.Divider />
@@ -370,6 +392,16 @@ function SpaceMenu({
/>
</>
)}
{hasTemplates && templatePickerOpened && (
<ErrorBoundary fallbackRender={() => null}>
<TemplatePickerModal
opened={templatePickerOpened}
onClose={closeTemplatePicker}
initialSpaceId={spaceId}
/>
</ErrorBoundary>
)}
</>
);
}