|
|
|
|
@@ -48,7 +48,11 @@ 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 {
|
|
|
|
|
ActiveDocumentSection,
|
|
|
|
|
DocumentSection,
|
|
|
|
|
TrashSection,
|
|
|
|
|
} from "~/actions/sections";
|
|
|
|
|
import env from "~/env";
|
|
|
|
|
import { setPersistedState } from "~/hooks/usePersistedState";
|
|
|
|
|
import history from "~/utils/history";
|
|
|
|
|
@@ -140,7 +144,7 @@ export const createDocumentFromTemplate = createAction({
|
|
|
|
|
export const createNestedDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("New nested document"),
|
|
|
|
|
analyticsName: "New document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <NewDocumentIcon />,
|
|
|
|
|
keywords: "create",
|
|
|
|
|
visible: ({ currentTeamId, activeDocumentId, stores }) =>
|
|
|
|
|
@@ -157,7 +161,7 @@ export const createNestedDocument = createAction({
|
|
|
|
|
export const starDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Star"),
|
|
|
|
|
analyticsName: "Star document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <StarredIcon />,
|
|
|
|
|
keywords: "favorite bookmark",
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
@@ -183,7 +187,7 @@ export const starDocument = createAction({
|
|
|
|
|
export const unstarDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Unstar"),
|
|
|
|
|
analyticsName: "Unstar document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <UnstarredIcon />,
|
|
|
|
|
keywords: "unfavorite unbookmark",
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
@@ -209,7 +213,7 @@ export const unstarDocument = createAction({
|
|
|
|
|
export const publishDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Publish"),
|
|
|
|
|
analyticsName: "Publish document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <PublishIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
if (!activeDocumentId) {
|
|
|
|
|
@@ -251,7 +255,7 @@ export const publishDocument = createAction({
|
|
|
|
|
export const unpublishDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Unpublish"),
|
|
|
|
|
analyticsName: "Unpublish document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <UnpublishIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
if (!activeDocumentId) {
|
|
|
|
|
@@ -282,7 +286,7 @@ export const unpublishDocument = createAction({
|
|
|
|
|
export const subscribeDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Subscribe"),
|
|
|
|
|
analyticsName: "Subscribe to document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <SubscribeIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
if (!activeDocumentId) {
|
|
|
|
|
@@ -310,7 +314,7 @@ export const subscribeDocument = createAction({
|
|
|
|
|
export const unsubscribeDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Unsubscribe"),
|
|
|
|
|
analyticsName: "Unsubscribe from document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <UnsubscribeIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
if (!activeDocumentId) {
|
|
|
|
|
@@ -340,7 +344,7 @@ export const unsubscribeDocument = createAction({
|
|
|
|
|
export const shareDocument = createAction({
|
|
|
|
|
name: ({ t }) => `${t("Permissions")}…`,
|
|
|
|
|
analyticsName: "Share document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <PadlockIcon />,
|
|
|
|
|
visible: ({ stores, activeDocumentId }) => {
|
|
|
|
|
const can = stores.policies.abilities(activeDocumentId!);
|
|
|
|
|
@@ -377,7 +381,7 @@ export const shareDocument = createAction({
|
|
|
|
|
export const downloadDocumentAsHTML = createAction({
|
|
|
|
|
name: ({ t }) => t("HTML"),
|
|
|
|
|
analyticsName: "Download document as HTML",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
keywords: "html export",
|
|
|
|
|
icon: <DownloadIcon />,
|
|
|
|
|
iconInContextMenu: false,
|
|
|
|
|
@@ -396,7 +400,7 @@ export const downloadDocumentAsHTML = createAction({
|
|
|
|
|
export const downloadDocumentAsPDF = createAction({
|
|
|
|
|
name: ({ t }) => t("PDF"),
|
|
|
|
|
analyticsName: "Download document as PDF",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
keywords: "export",
|
|
|
|
|
icon: <DownloadIcon />,
|
|
|
|
|
iconInContextMenu: false,
|
|
|
|
|
@@ -420,7 +424,7 @@ export const downloadDocumentAsPDF = createAction({
|
|
|
|
|
export const downloadDocumentAsMarkdown = createAction({
|
|
|
|
|
name: ({ t }) => t("Markdown"),
|
|
|
|
|
analyticsName: "Download document as Markdown",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
keywords: "md markdown export",
|
|
|
|
|
icon: <DownloadIcon />,
|
|
|
|
|
iconInContextMenu: false,
|
|
|
|
|
@@ -440,9 +444,11 @@ export const downloadDocument = createAction({
|
|
|
|
|
name: ({ t, isContextMenu }) =>
|
|
|
|
|
isContextMenu ? t("Download") : t("Download document"),
|
|
|
|
|
analyticsName: "Download document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <DownloadIcon />,
|
|
|
|
|
keywords: "export",
|
|
|
|
|
visible: ({ activeDocumentId, stores }) =>
|
|
|
|
|
!!activeDocumentId && stores.policies.abilities(activeDocumentId).download,
|
|
|
|
|
children: [
|
|
|
|
|
downloadDocumentAsHTML,
|
|
|
|
|
downloadDocumentAsPDF,
|
|
|
|
|
@@ -452,7 +458,7 @@ export const downloadDocument = createAction({
|
|
|
|
|
|
|
|
|
|
export const copyDocumentAsMarkdown = createAction({
|
|
|
|
|
name: ({ t }) => t("Copy as Markdown"),
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
keywords: "clipboard",
|
|
|
|
|
visible: ({ activeDocumentId, stores }) =>
|
|
|
|
|
!!activeDocumentId && stores.policies.abilities(activeDocumentId).download,
|
|
|
|
|
@@ -469,7 +475,7 @@ export const copyDocumentAsMarkdown = createAction({
|
|
|
|
|
|
|
|
|
|
export const copyDocumentLink = createAction({
|
|
|
|
|
name: ({ t }) => t("Copy link"),
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
keywords: "clipboard",
|
|
|
|
|
visible: ({ activeDocumentId }) => !!activeDocumentId,
|
|
|
|
|
perform: ({ stores, activeDocumentId, t }) => {
|
|
|
|
|
@@ -486,7 +492,7 @@ export const copyDocumentLink = createAction({
|
|
|
|
|
export const copyDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Copy"),
|
|
|
|
|
analyticsName: "Copy document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <CopyIcon />,
|
|
|
|
|
keywords: "clipboard",
|
|
|
|
|
children: [copyDocumentLink, copyDocumentAsMarkdown],
|
|
|
|
|
@@ -496,7 +502,7 @@ export const duplicateDocument = createAction({
|
|
|
|
|
name: ({ t, isContextMenu }) =>
|
|
|
|
|
isContextMenu ? t("Duplicate") : t("Duplicate document"),
|
|
|
|
|
analyticsName: "Duplicate document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <DuplicateIcon />,
|
|
|
|
|
keywords: "copy",
|
|
|
|
|
visible: ({ activeDocumentId, stores }) =>
|
|
|
|
|
@@ -540,7 +546,7 @@ export const pinDocumentToCollection = createAction({
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
analyticsName: "Pin document to collection",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <PinIcon />,
|
|
|
|
|
iconInContextMenu: false,
|
|
|
|
|
visible: ({ activeCollectionId, activeDocumentId, stores }) => {
|
|
|
|
|
@@ -576,7 +582,7 @@ export const pinDocumentToCollection = createAction({
|
|
|
|
|
export const pinDocumentToHome = createAction({
|
|
|
|
|
name: ({ t }) => t("Pin to home"),
|
|
|
|
|
analyticsName: "Pin document to home",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <PinIcon />,
|
|
|
|
|
iconInContextMenu: false,
|
|
|
|
|
visible: ({ activeDocumentId, currentTeamId, stores }) => {
|
|
|
|
|
@@ -608,7 +614,7 @@ export const pinDocumentToHome = createAction({
|
|
|
|
|
export const pinDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Pin"),
|
|
|
|
|
analyticsName: "Pin document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <PinIcon />,
|
|
|
|
|
children: [pinDocumentToCollection, pinDocumentToHome],
|
|
|
|
|
});
|
|
|
|
|
@@ -616,7 +622,7 @@ export const pinDocument = createAction({
|
|
|
|
|
export const searchInDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Search in document"),
|
|
|
|
|
analyticsName: "Search document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <SearchIcon />,
|
|
|
|
|
visible: ({ stores, activeDocumentId }) => {
|
|
|
|
|
if (!activeDocumentId) {
|
|
|
|
|
@@ -634,7 +640,7 @@ export const printDocument = createAction({
|
|
|
|
|
name: ({ t, isContextMenu }) =>
|
|
|
|
|
isContextMenu ? t("Print") : t("Print document"),
|
|
|
|
|
analyticsName: "Print document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <PrintIcon />,
|
|
|
|
|
visible: ({ activeDocumentId }) => !!(activeDocumentId && window.print),
|
|
|
|
|
perform: () => {
|
|
|
|
|
@@ -693,7 +699,7 @@ export const importDocument = createAction({
|
|
|
|
|
export const createTemplateFromDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Templatize"),
|
|
|
|
|
analyticsName: "Templatize document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <ShapesIcon />,
|
|
|
|
|
keywords: "new create template",
|
|
|
|
|
visible: ({ activeCollectionId, activeDocumentId, stores }) => {
|
|
|
|
|
@@ -793,7 +799,7 @@ export const moveDocumentToCollection = createAction({
|
|
|
|
|
: t("Move");
|
|
|
|
|
},
|
|
|
|
|
analyticsName: "Move document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <MoveIcon />,
|
|
|
|
|
iconInContextMenu: false,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
@@ -822,7 +828,7 @@ export const moveDocumentToCollection = createAction({
|
|
|
|
|
export const moveDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Move"),
|
|
|
|
|
analyticsName: "Move document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <MoveIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
if (!activeDocumentId) {
|
|
|
|
|
@@ -841,7 +847,7 @@ export const moveDocument = createAction({
|
|
|
|
|
export const moveTemplate = createAction({
|
|
|
|
|
name: ({ t }) => t("Move"),
|
|
|
|
|
analyticsName: "Move document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <MoveIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
if (!activeDocumentId) {
|
|
|
|
|
@@ -860,7 +866,7 @@ export const moveTemplate = createAction({
|
|
|
|
|
export const archiveDocument = createAction({
|
|
|
|
|
name: ({ t }) => `${t("Archive")}…`,
|
|
|
|
|
analyticsName: "Archive document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <ArchiveIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
if (!activeDocumentId) {
|
|
|
|
|
@@ -900,7 +906,7 @@ export const archiveDocument = createAction({
|
|
|
|
|
export const deleteDocument = createAction({
|
|
|
|
|
name: ({ t }) => `${t("Delete")}…`,
|
|
|
|
|
analyticsName: "Delete document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <TrashIcon />,
|
|
|
|
|
dangerous: true,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
@@ -934,7 +940,7 @@ export const deleteDocument = createAction({
|
|
|
|
|
export const permanentlyDeleteDocument = createAction({
|
|
|
|
|
name: ({ t }) => t("Permanently delete"),
|
|
|
|
|
analyticsName: "Permanently delete document",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <CrossIcon />,
|
|
|
|
|
dangerous: true,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
@@ -989,7 +995,7 @@ export const permanentlyDeleteDocumentsInTrash = createAction({
|
|
|
|
|
export const openDocumentComments = createAction({
|
|
|
|
|
name: ({ t }) => t("Comments"),
|
|
|
|
|
analyticsName: "Open comments",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <CommentIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
const can = stores.policies.abilities(activeDocumentId ?? "");
|
|
|
|
|
@@ -1011,7 +1017,7 @@ export const openDocumentComments = createAction({
|
|
|
|
|
export const openDocumentHistory = createAction({
|
|
|
|
|
name: ({ t }) => t("History"),
|
|
|
|
|
analyticsName: "Open document history",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <HistoryIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
const can = stores.policies.abilities(activeDocumentId ?? "");
|
|
|
|
|
@@ -1032,7 +1038,7 @@ export const openDocumentHistory = createAction({
|
|
|
|
|
export const openDocumentInsights = createAction({
|
|
|
|
|
name: ({ t }) => t("Insights"),
|
|
|
|
|
analyticsName: "Open document insights",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <GraphIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
const can = stores.policies.abilities(activeDocumentId ?? "");
|
|
|
|
|
@@ -1069,7 +1075,7 @@ export const toggleViewerInsights = createAction({
|
|
|
|
|
: t("Enable viewer insights");
|
|
|
|
|
},
|
|
|
|
|
analyticsName: "Toggle viewer insights",
|
|
|
|
|
section: DocumentSection,
|
|
|
|
|
section: ActiveDocumentSection,
|
|
|
|
|
icon: <EyeIcon />,
|
|
|
|
|
visible: ({ activeDocumentId, stores }) => {
|
|
|
|
|
const can = stores.policies.abilities(activeDocumentId ?? "");
|
|
|
|
|
|