-
-
Notifications
You must be signed in to change notification settings - Fork 18
BL-15855 upgrade config-r #7675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
devin-ai-integration[bot] marked this conversation as resolved.
Show resolved
Hide resolved
devin-ai-integration[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,11 @@ | ||
| import { css } from "@emotion/react"; | ||
| import * as React from "react"; | ||
| import { ConfigrGroup, ConfigrPane } from "@sillsdev/config-r"; | ||
| import { | ||
| ConfigrGroup, | ||
| ConfigrPage, | ||
| ConfigrPane, | ||
| ConfigrStatic, | ||
| } from "@sillsdev/config-r"; | ||
| import { | ||
| BloomDialog, | ||
| DialogBottomButtons, | ||
|
|
@@ -27,15 +32,30 @@ export const CollectionSettingsDialog: React.FunctionComponent = () => { | |
| ); | ||
|
|
||
| const [settingsString, setSettingsString] = React.useState<string>("{}"); | ||
| // Fetch collection settings when the dialog opens so we sync with host state. | ||
| React.useEffect(() => { | ||
| if (propsForBloomDialog.open) | ||
| get("collection/settings", (result) => { | ||
| setSettingsString(result.data); | ||
| }); | ||
| }, [propsForBloomDialog.open]); | ||
|
|
||
| const [settingsToReturnLater, setSettingsToReturnLater] = | ||
| React.useState(""); | ||
| const [settingsToReturnLater, setSettingsToReturnLater] = React.useState< | ||
| string | object | undefined | ||
| >(undefined); | ||
|
Comment on lines
+43
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Stale settingsToReturnLater in CollectionSettingsDialog after Cancel The
This is pre-existing (the old code had the same issue with Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not fully understanding this. But it seems to be saying we have an existing bug here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see. This is for a new collection settings dialog we aren't using. |
||
|
|
||
| const normalizeConfigrSettings = ( | ||
| settingsValue: string | object | undefined, | ||
| ): object | undefined => { | ||
| if (!settingsValue) { | ||
| return undefined; | ||
| } | ||
| if (typeof settingsValue === "string") { | ||
| return JSON.parse(settingsValue) as object; | ||
| } | ||
| return settingsValue; | ||
| }; | ||
| // Parse the settings JSON for Configr's initial values once it arrives. | ||
| React.useEffect(() => { | ||
| if (settingsString === "{}") { | ||
| return; // leave settings as undefined | ||
|
|
@@ -66,33 +86,76 @@ export const CollectionSettingsDialog: React.FunctionComponent = () => { | |
| height: 100%; | ||
| `} | ||
| > | ||
| <ConfigrPane | ||
| label={"Collection Settings"} | ||
| showSearch={true} | ||
| // showJson={true} // useful for debugging | ||
| initialValues={settings || {}} | ||
| showAllGroups={true} | ||
| //themeOverrides={lightTheme} | ||
| themeOverrides={{ | ||
| // enhance: we'd like to just be passing `lightTheme` but at the moment that seems to clobber everything | ||
| palette: { | ||
| primary: { main: kBloomBlue }, | ||
| }, | ||
| }} | ||
| onChange={(s) => { | ||
| setSettingsToReturnLater(s); | ||
| }} | ||
| > | ||
| <ConfigrGroup label={"Languages"}></ConfigrGroup> | ||
| <ConfigrGroup label={"Appearance"}></ConfigrGroup> | ||
| </ConfigrPane> | ||
| {settings && ( | ||
| <ConfigrPane | ||
| label={"Collection Settings"} | ||
| showAppBar={false} | ||
| showSearch={true} | ||
| // showJson={true} // useful for debugging | ||
| initialValues={settings} | ||
| //themeOverrides={lightTheme} | ||
| themeOverrides={{ | ||
| // enhance: we'd like to just be passing `lightTheme` but at the moment that seems to clobber everything | ||
| palette: { | ||
| primary: { main: kBloomBlue }, | ||
| }, | ||
| }} | ||
| onChange={(s) => { | ||
| setSettingsToReturnLater(s); | ||
| }} | ||
| > | ||
| <ConfigrPage | ||
| label={"Languages"} | ||
| pageKey="languages" | ||
| topLevel={true} | ||
| > | ||
| <ConfigrGroup label={"Languages"}> | ||
| <ConfigrStatic> | ||
| <div | ||
| css={css` | ||
| font-size: 0.9em; | ||
| color: #555; | ||
| `} | ||
| > | ||
| Settings for this section are not | ||
| available yet. | ||
| </div> | ||
| </ConfigrStatic> | ||
| </ConfigrGroup> | ||
| </ConfigrPage> | ||
| <ConfigrPage | ||
| label={"Appearance"} | ||
| pageKey="appearance" | ||
| topLevel={true} | ||
| > | ||
| <ConfigrGroup label={"Appearance"}> | ||
| <ConfigrStatic> | ||
| <div | ||
| css={css` | ||
| font-size: 0.9em; | ||
| color: #555; | ||
| `} | ||
| > | ||
| Settings for this section are not | ||
| available yet. | ||
| </div> | ||
| </ConfigrStatic> | ||
| </ConfigrGroup> | ||
| </ConfigrPage> | ||
| </ConfigrPane> | ||
| )} | ||
| </div> | ||
| </DialogMiddle> | ||
| <DialogBottomButtons> | ||
| <DialogOkButton | ||
| default={true} | ||
| onClick={() => { | ||
| postJson("collection/settings", settingsToReturnLater); | ||
| const settingsToPost = normalizeConfigrSettings( | ||
| settingsToReturnLater, | ||
| ); | ||
| if (settingsToPost) { | ||
| postJson("collection/settings", settingsToPost); | ||
| } | ||
| closeDialog(); | ||
| }} | ||
| /> | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.