diff --git a/app/actions/definitions/collections.tsx b/app/actions/definitions/collections.tsx
index 4a2da735ed..1bd2a5a28c 100644
--- a/app/actions/definitions/collections.tsx
+++ b/app/actions/definitions/collections.tsx
@@ -6,7 +6,6 @@ import {
PlusIcon,
RestoreIcon,
SearchIcon,
- ShapesIcon,
StarredIcon,
SubscribeIcon,
TrashIcon,
@@ -26,7 +25,7 @@ import { createAction } from "~/actions";
import { ActiveCollectionSection, CollectionSection } from "~/actions/sections";
import { setPersistedState } from "~/hooks/usePersistedState";
import history from "~/utils/history";
-import { newTemplatePath, searchPath } from "~/utils/routeHelpers";
+import { searchPath } from "~/utils/routeHelpers";
const ColorCollectionIcon = ({ collection }: { collection: Collection }) => (
@@ -365,27 +364,6 @@ export const deleteCollection = createAction({
},
});
-export const createTemplate = createAction({
- name: ({ t }) => t("New template"),
- analyticsName: "New template",
- section: ActiveCollectionSection,
- icon: ,
- keywords: "new create template",
- visible: ({ activeCollectionId, stores }) =>
- !!(
- !!activeCollectionId &&
- stores.policies.abilities(activeCollectionId).createDocument
- ),
- perform: ({ activeCollectionId, event }) => {
- if (!activeCollectionId) {
- return;
- }
- event?.preventDefault();
- event?.stopPropagation();
- history.push(newTemplatePath(activeCollectionId));
- },
-});
-
export const rootCollectionActions = [
openCollection,
createCollection,
diff --git a/app/actions/definitions/templates.tsx b/app/actions/definitions/templates.tsx
index 1398084480..862456dbb4 100644
--- a/app/actions/definitions/templates.tsx
+++ b/app/actions/definitions/templates.tsx
@@ -1,10 +1,29 @@
-import { MoveIcon, TrashIcon } from "outline-icons";
+import { MoveIcon, PlusIcon, TrashIcon } from "outline-icons";
import { Trans } from "react-i18next";
import { toast } from "sonner";
import ConfirmationDialog from "~/components/ConfirmationDialog";
import TemplateMove from "~/components/DocumentExplorer/TemplateMove";
import { createAction } from "~/actions";
-import { ActiveTemplateSection } from "../sections";
+import { ActiveTemplateSection, TemplateSection } from "../sections";
+
+export const createTemplate = createAction({
+ name: ({ t }) => t("New template"),
+ analyticsName: "New template",
+ section: TemplateSection,
+ icon: ,
+ keywords: "new create template",
+ visible: ({ currentTeamId, stores }) =>
+ !!stores.policies.abilities(currentTeamId!).createTemplate,
+ perform: ({ activeCollectionId, event }) => {
+ if (!activeCollectionId) {
+ return;
+ }
+ event?.preventDefault();
+ event?.stopPropagation();
+
+ // Trigger dialog
+ },
+});
export const deleteTemplate = createAction({
name: ({ t }) => `${t("Delete")}…`,
diff --git a/app/scenes/Settings/Templates.tsx b/app/scenes/Settings/Templates.tsx
index 02e051c504..a7eac7d05f 100644
--- a/app/scenes/Settings/Templates.tsx
+++ b/app/scenes/Settings/Templates.tsx
@@ -15,13 +15,14 @@ import Heading from "~/components/Heading";
import InputSearch from "~/components/InputSearch";
import Scene from "~/components/Scene";
import Text from "~/components/Text";
+import { createTemplate } from "~/actions/definitions/templates";
+import useActionContext from "~/hooks/useActionContext";
import useCurrentTeam from "~/hooks/useCurrentTeam";
import usePolicy from "~/hooks/usePolicy";
import useQuery from "~/hooks/useQuery";
import useStores from "~/hooks/useStores";
import { useTableRequest } from "~/hooks/useTableRequest";
import { StickyFilters } from "./components/StickyFilters";
-// import { CreateTemplateDialog } from "./components/TemplateDialogs";
import { TemplatesTable } from "./components/TemplatesTable";
function getFilteredTemplates(templates: Template[], query?: string) {
@@ -37,12 +38,13 @@ function getFilteredTemplates(templates: Template[], query?: string) {
function Templates() {
const { t } = useTranslation();
- const { dialogs, templates } = useStores();
+ const { templates } = useStores();
const team = useCurrentTeam();
const can = usePolicy(team);
const history = useHistory();
const location = useLocation();
const params = useQuery();
+ const context = useActionContext();
const [query, setQuery] = useState("");
const reqParams = useMemo(
@@ -94,14 +96,6 @@ function Templates() {
setQuery(value);
}, []);
- const handleNewTemplate = useCallback(() => {
- dialogs.openModal({
- title: t("Create a template"),
- // content: ,
- content:
Test
,
- });
- }, [t, dialogs]);
-
useEffect(() => {
if (error) {
toast.error(t("Could not load templates"));
@@ -123,8 +117,9 @@ function Templates() {
}
+ context={context}
>
{`${t("New template")}…`}