diff --git a/app/actions/definitions/documents.tsx b/app/actions/definitions/documents.tsx index 4271ce2418..68ccd3778f 100644 --- a/app/actions/definitions/documents.tsx +++ b/app/actions/definitions/documents.tsx @@ -37,10 +37,10 @@ import DocumentMove from "~/scenes/DocumentMove"; import DocumentPermanentDelete from "~/scenes/DocumentPermanentDelete"; import DocumentPublish from "~/scenes/DocumentPublish"; import DeleteDocumentsInTrash from "~/scenes/Trash/components/DeleteDocumentsInTrash"; -import DocumentTemplatizeDialog from "~/components/DocumentTemplatizeDialog"; import DuplicateDialog from "~/components/DuplicateDialog"; import SharePopover from "~/components/Sharing/Document"; import { getHeaderExpandedKey } from "~/components/Sidebar/components/Header"; +import DocumentTemplatizeDialog from "~/components/TemplatizeDialog"; import { createAction } from "~/actions"; import { DocumentSection, TrashSection } from "~/actions/sections"; import env from "~/env"; @@ -758,7 +758,7 @@ export const moveTemplateToWorkspace = createAction({ } await document.move({ - template: true, + collectionId: null, }); } }, diff --git a/app/components/TemplatizeDialog/Label.tsx b/app/components/TemplatizeDialog/Label.tsx new file mode 100644 index 0000000000..c211b87d3e --- /dev/null +++ b/app/components/TemplatizeDialog/Label.tsx @@ -0,0 +1,22 @@ +import React from "react"; +import styled from "styled-components"; +import Flex from "~/components/Flex"; + +const Label = ({ icon, value }: { icon: React.ReactNode; value: string }) => ( + + {icon} + {value} + +); + +const IconWrapper = styled.span` + display: flex; + justify-content: center; + align-items: center; + height: 24px; + width: 24px; + overflow: hidden; + flex-shrink: 0; +`; + +export default Label; diff --git a/app/components/TemplatizeDialog/SelectLocation.tsx b/app/components/TemplatizeDialog/SelectLocation.tsx new file mode 100644 index 0000000000..11a612d28f --- /dev/null +++ b/app/components/TemplatizeDialog/SelectLocation.tsx @@ -0,0 +1,124 @@ +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { toast } from "sonner"; +import styled from "styled-components"; +import { AvatarSize } from "~/components/Avatar/Avatar"; +import CollectionIcon from "~/components/Icons/CollectionIcon"; +import InputSelect, { Option } from "~/components/InputSelect"; +import TeamLogo from "~/components/TeamLogo"; +import useCurrentTeam from "~/hooks/useCurrentTeam"; +import usePolicy from "~/hooks/usePolicy"; +import useStores from "~/hooks/useStores"; +import Label from "./Label"; + +type Props = { + id: string; + defaultCollectionId?: string | null; + onSelect: (collectionId: string | null) => void; +}; + +const SelectLocation = ({ id, defaultCollectionId, onSelect }: Props) => { + const { t } = useTranslation(); + const team = useCurrentTeam(); + const { collections, policies } = useStores(); + const can = usePolicy(team); + const [fetching, setFetching] = useState(false); + const [fetchError, setFetchError] = useState(); + + const workspaceOption: Option | null = can.createDocument + ? { + label: ( +