Skip to content

Commit 90b93bb

Browse files
committed
use flag panel instead of checkbox
1 parent 16b87c3 commit 90b93bb

File tree

1 file changed

+12
-36
lines changed

1 file changed

+12
-36
lines changed

apps/roam/src/components/settings/GeneralSettings.tsx

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,14 @@ import FlagPanel from "roamjs-components/components/ConfigPanels/FlagPanel";
44
import { getFormattedConfigTree } from "~/utils/discourseConfigRef";
55
import refreshConfigTree from "~/utils/refreshConfigTree";
66
import { DEFAULT_CANVAS_PAGE_FORMAT } from "~/index";
7-
import { Alert, Checkbox, Intent } from "@blueprintjs/core";
8-
import Description from "roamjs-components/components/Description";
9-
import createBlock from "roamjs-components/writes/createBlock";
10-
import deleteBlock from "roamjs-components/writes/deleteBlock";
7+
import { Alert, Intent } from "@blueprintjs/core";
118

129
const DiscourseGraphHome = () => {
1310
const settings = useMemo(() => {
1411
refreshConfigTree();
1512
return getFormattedConfigTree();
1613
}, []);
1714

18-
const [leftSidebarEnabled, setLeftSidebarEnabled] = useState(
19-
settings.leftSidebarEnabled.value || false,
20-
);
21-
const [leftSidebarUid, setLeftSidebarUid] = useState(
22-
settings.leftSidebarEnabled.uid,
23-
);
2415
const [isAlertOpen, setIsAlertOpen] = useState(false);
2516

2617
return (
@@ -42,35 +33,20 @@ const DiscourseGraphHome = () => {
4233
value={settings.canvasPageFormat.value}
4334
defaultValue={DEFAULT_CANVAS_PAGE_FORMAT}
4435
/>
45-
<Checkbox
46-
checked={leftSidebarEnabled}
47-
onChange={(e) => {
48-
const checked = (e.target as HTMLInputElement).checked;
49-
if (checked) {
50-
void createBlock({
51-
parentUid: settings.settingsUid,
52-
node: { text: "(BETA) Left Sidebar" },
53-
}).then((uid) => {
54-
setLeftSidebarUid(uid);
55-
setLeftSidebarEnabled(true);
36+
<FlagPanel
37+
title="(BETA) Left Sidebar"
38+
description="Whether or not to enable the left sidebar."
39+
order={2}
40+
uid={settings.leftSidebarEnabled.uid}
41+
parentUid={settings.settingsUid}
42+
value={settings.leftSidebarEnabled.value || false}
43+
options={{
44+
onChange: (checked: boolean) => {
45+
if (checked) {
5646
setIsAlertOpen(true);
57-
});
58-
} else {
59-
if (leftSidebarUid) {
60-
void deleteBlock(leftSidebarUid);
61-
setLeftSidebarUid(undefined);
6247
}
63-
setLeftSidebarEnabled(false);
64-
}
48+
},
6549
}}
66-
labelElement={
67-
<>
68-
(BETA) Left Sidebar
69-
<Description
70-
description={"Whether or not to enable the left sidebar."}
71-
/>
72-
</>
73-
}
7450
/>
7551
<Alert
7652
isOpen={isAlertOpen}

0 commit comments

Comments
 (0)