From b3d434e1fc5cdf64575367555fd535f0414ddee9 Mon Sep 17 00:00:00 2001 From: Michael Gartner Date: Tue, 5 Mar 2024 22:55:49 -0800 Subject: [PATCH] include legacy settings for visability --- src/components/LegacySettings.tsx | 39 +++++ src/components/SettingsTable.tsx | 263 +++++++++++++++++------------- src/index.ts | 20 ++- src/settings.ts | 3 +- 4 files changed, 203 insertions(+), 122 deletions(-) create mode 100644 src/components/LegacySettings.tsx diff --git a/src/components/LegacySettings.tsx b/src/components/LegacySettings.tsx new file mode 100644 index 0000000..64d6c7f --- /dev/null +++ b/src/components/LegacySettings.tsx @@ -0,0 +1,39 @@ +import React from "react"; +import { Divider, HTMLTable } from "@blueprintjs/core"; +import { get } from "../settings"; +import { FEATURES } from ".."; + +const LegacySettings = ({ moduleId }: { moduleId: string }) => { + const featureSettings = FEATURES.find((f) => f.id === moduleId)?.settings; + if (!featureSettings) return <>No Settings For {moduleId}; + + const docs = FEATURES.find((f) => f.id === moduleId)?.docs; + + return ( +
+ + {Object.entries(featureSettings).map(([key, value]) => { + const setting = get(value) || "Not Set"; + return ( + + {key} + {setting} + + ); + })} + + + {docs && ( +
+ + Documentation + +
+ )} +
+ ); +}; + +export default LegacySettings; diff --git a/src/components/SettingsTable.tsx b/src/components/SettingsTable.tsx index 0413fdd..e1d5d76 100644 --- a/src/components/SettingsTable.tsx +++ b/src/components/SettingsTable.tsx @@ -2,12 +2,15 @@ import React, { useState } from "react"; import { AnchorButton, Button, + Classes, + Dialog, HTMLTable, Popover, Switch, } from "@blueprintjs/core"; import { OnloadArgs } from "roamjs-components/types"; import { Feature } from "../index"; +import LegacySettings from "./LegacySettings"; const SettingsTable = (FEATURES: Feature[], extensionAPI: OnloadArgs["extensionAPI"]) => () => { @@ -18,7 +21,12 @@ const SettingsTable = }); const [featureToggleSettings, setFeatureToggleSettings] = useState(initialSettings); - + const [isDialogOpen, setIsDialogOpen] = useState(false); + const [currentModuleId, setCurrentModuleId] = useState(""); + const handleOpenDialog = (moduleId: string) => { + setCurrentModuleId(moduleId); + setIsDialogOpen(true); + }; const settingsStyle: React.CSSProperties = { maxWidth: "25px", minWidth: "initial", @@ -46,130 +54,155 @@ const SettingsTable = const isMaxWidth = window.matchMedia("(max-width: 1279px)").matches; return ( - - - - Enabled - Feature - - Info - - {/* Settings */} - Documentation - - - - {FEATURES.map(({ id, name, docs, module, description, gif }, i) => ( - - - { - const updatedSettings = { - ...featureToggleSettings, - [id]: (e.target as HTMLInputElement).checked, - }; - setFeatureToggleSettings(updatedSettings); - extensionAPI.settings.set( - id, - (e.target as HTMLInputElement).checked - ); - module.toggleFeature( - (e.target as HTMLInputElement).checked, - extensionAPI - ); - }} - /> - - + + + + Enabled + Feature + - {name} - - + - -

- {description} -

- - - } + Settings + + Documentation + + + + {FEATURES.map( + ({ id, name, docs, module, description, gif, settings }, i) => ( + -