diff --git a/apps/roam/src/components/Export.tsx b/apps/roam/src/components/Export.tsx index 016d0714d..6b6cea207 100644 --- a/apps/roam/src/components/Export.tsx +++ b/apps/roam/src/components/Export.tsx @@ -128,7 +128,7 @@ export type ExportDialogProps = { title?: string; columns?: Column[]; isExportDiscourseGraph?: boolean; - initialPanel?: "sendTo" | "export"; + initialPanel?: "sendTo" | "export" | "publish"; }; type ExportDialogComponent = ( @@ -141,6 +141,14 @@ const EXPORT_DESTINATIONS = [ { id: "github", label: "Send to GitHub", active: true }, ]; const SEND_TO_DESTINATIONS = ["page", "graph"]; +const INITIAL_PANEL_TO_TAB_ID: Record< + NonNullable, + string +> = { + sendTo: "sendto", + export: "export", + publish: "publish", +}; const exportDestinationById = Object.fromEntries( EXPORT_DESTINATIONS.map((ed) => [ed.id, ed]), @@ -230,10 +238,12 @@ const ExportDialog: ExportDialogComponent = ({ useState<(typeof SEND_TO_DESTINATIONS)[number]>("page"); const isSendToGraph = activeSendToDestination === "graph"; const [livePages, setLivePages] = useState([]); + const syncEnabled = useMemo(() => isSyncEnabled(), []); const [selectedTabId, setSelectedTabId] = useState("sendto"); useEffect(() => { - if (initialPanel === "export") setSelectedTabId("export"); - }, [initialPanel]); + if (initialPanel === "publish" && !syncEnabled) return; + if (initialPanel) setSelectedTabId(INITIAL_PANEL_TO_TAB_ID[initialPanel]); + }, [initialPanel, syncEnabled]); const [includeDiscourseContext, setIncludeDiscourseContext] = useState(false); const [gitHubAccessToken, setGitHubAccessToken] = useState( getSetting("oauth-github", null), @@ -241,7 +251,6 @@ const ExportDialog: ExportDialogComponent = ({ const [canSendToGitHub, setCanSendToGitHub] = useState(false); - const syncEnabled = useMemo(() => isSyncEnabled(), []); const [myGroups, setMyGroups] = useState([]); const [groupsLoading, setGroupsLoading] = useState(false); const [groupsLoaded, setGroupsLoaded] = useState(false); diff --git a/apps/roam/src/components/PublishNodeTitleButton.tsx b/apps/roam/src/components/PublishNodeTitleButton.tsx new file mode 100644 index 000000000..af7c67a5e --- /dev/null +++ b/apps/roam/src/components/PublishNodeTitleButton.tsx @@ -0,0 +1,53 @@ +import { Button } from "@blueprintjs/core"; +import posthog from "posthog-js"; +import React from "react"; +import { handleTitleAdditions } from "~/utils/handleTitleAdditions"; +import { openShareNodeDialog } from "~/utils/openShareNodeDialog"; + +const PUBLISH_TITLE_BUTTON_ATTRIBUTE = "data-roamjs-publish-node-title-button"; + +const PublishNodeTitleButton = ({ + uid, + title, + nodeType, +}: { + uid: string; + title: string; + nodeType: string; +}): JSX.Element => ( +