mirror of
https://github.com/outline/outline.git
synced 2026-11-26 23:50:14 +03:00
wip
This commit is contained in:
3 files changed
+28
-36
No files matched your search
@@ -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 }) => (
|
||||
<DynamicCollectionIcon 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: <ShapesIcon />,
|
||||
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,
|
||||
|
||||
@@ -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: <PlusIcon />,
|
||||
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")}…`,
|
||||
|
||||
@@ -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: <CreateTemplateDialog />,
|
||||
content: <p>Test</p>,
|
||||
});
|
||||
}, [t, dialogs]);
|
||||
|
||||
useEffect(() => {
|
||||
if (error) {
|
||||
toast.error(t("Could not load templates"));
|
||||
@@ -123,8 +117,9 @@ function Templates() {
|
||||
<Action>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={handleNewTemplate}
|
||||
action={createTemplate}
|
||||
icon={<PlusIcon />}
|
||||
context={context}
|
||||
>
|
||||
{`${t("New template")}…`}
|
||||
</Button>
|
||||
|
||||
Reference in new issue
Block a user