Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion apps/roam/src/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { LeftSidebarPersonalSections } from "./LeftSidebarPersonalSettings";
import { LeftSidebarGlobalSections } from "./LeftSidebarGlobalSettings";
import posthog from "posthog-js";
import { bulkReadSettings } from "./utils/accessors";
import { onSettingChange, settingKeys } from "./utils/settingsEmitter";

type SectionHeaderProps = {
children: React.ReactNode;
Expand Down Expand Up @@ -90,6 +91,14 @@ export const SettingsDialog = ({
);
// eslint-disable-next-line react-hooks/exhaustive-deps
const settings = useMemo(() => bulkReadSettings(), [activeTabId]);
const [leftSidebarEnabled, setLeftSidebarEnabled] = useState(
settings.featureFlags["Enable left sidebar"],
);
useEffect(() => {
return onSettingChange(settingKeys.leftSidebarFlag, (newValue) => {
setLeftSidebarEnabled(Boolean(newValue));
});
Comment thread
sid597 marked this conversation as resolved.
}, []);
const [showAdminPanel, setShowAdminPanel] = useState(
window.roamAlphaAPI.graph.name === "discourse-graphs" || false,
);
Expand All @@ -114,6 +123,13 @@ export const SettingsDialog = ({
window.addEventListener("keydown", handleKeyPress);
return () => window.removeEventListener("keydown", handleKeyPress);
}, []);
const leftSidebarTabHidden =
!leftSidebarEnabled &&
(activeTabId === "left-sidebar-personal-settings" ||
activeTabId === "left-sidebar-global-settings");
const visibleTabId = leftSidebarTabHidden
? "discourse-graph-home-personal"
: activeTabId;
return (
<Dialog
isOpen={isOpen}
Expand Down Expand Up @@ -161,7 +177,7 @@ export const SettingsDialog = ({
tabId: String(id),
});
}}
selectedTabId={activeTabId}
selectedTabId={visibleTabId}
vertical={true}
renderActiveTabPanelOnly={true}
>
Expand Down Expand Up @@ -202,6 +218,7 @@ export const SettingsDialog = ({
/>
<Tab
id="left-sidebar-personal-settings"
hidden={!leftSidebarEnabled}
title="Left sidebar"
className="overflow-y-auto"
panel={
Expand Down Expand Up @@ -235,6 +252,7 @@ export const SettingsDialog = ({
/>
<Tab
id="left-sidebar-global-settings"
hidden={!leftSidebarEnabled}
title="Left sidebar"
className="overflow-y-auto"
panel={
Expand Down