Skip to content
Merged
Show file tree
Hide file tree
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
40 changes: 27 additions & 13 deletions DistFiles/localization/en/Bloom.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -511,22 +511,36 @@
<source xml:lang="en">Upper-Armenian</source>
<note>ID: CollectionSettingsDialog.BookMakingTab.PageNumberingStyle.Upper-Armenian</note>
</trans-unit>
<trans-unit id="CollectionSettingsDialog.BookMakingTab.QrCodeBadgeLabelCaption" translate="no">
<source xml:lang="en">Label for QR code badge</source>
<note>ID: CollectionSettingsDialog.BookMakingTab.QrCodeBadgeLabelCaption</note>
<trans-unit id="CollectionSettingsDialog.AdvancedTab.Program" translate="no">
<source xml:lang="en">Program</source>
<note>ID: CollectionSettingsDialog.AdvancedTab.Program</note>
</trans-unit>
<trans-unit id="CollectionSettingsDialog.BookMakingTab.QrCodeBadgeText" translate="no">
<source xml:lang="en">Get more books in the {0} language on BloomLibrary.org.</source>
<note>ID: CollectionSettingsDialog.BookMakingTab.QrCodeBadgeText</note>
<note>{0} will be replaced by a language name</note>
<trans-unit id="CollectionSettingsDialog.AdvancedTab.QrCodes" translate="no">
<source xml:lang="en">QR Codes</source>
<note>ID: CollectionSettingsDialog.AdvancedTab.QrCodes</note>
</trans-unit>
<trans-unit id="CollectionSettingsDialog.AdvancedTab.ShowQrCodes" translate="no">
<source xml:lang="en">Show QR Codes</source>
<note>ID: CollectionSettingsDialog.AdvancedTab.ShowQrCodes</note>
</trans-unit>
<trans-unit id="CollectionSettingsDialog.AdvancedTab.ShowQrCodes.Description" translate="no">
<source xml:lang="en">Scanning the code or clicking the badge will take the user to the collection of books in this collection's primary language. Note, if you want to use this but your branding does not show it, contact us.</source>
<note>ID: CollectionSettingsDialog.AdvancedTab.ShowQrCodes.Description</note>
</trans-unit>
<trans-unit id="CollectionSettingsDialog.BookMakingTab.QrCodeLabel" translate="no">
<source xml:lang="en">QR code in Bloom badge</source>
<note>ID: CollectionSettingsDialog.BookMakingTab.QrCodeLabel</note>
<trans-unit id="CollectionSettingsDialog.AdvancedTab.Caption" translate="no">
<source xml:lang="en">Caption</source>
<note>ID: CollectionSettingsDialog.AdvancedTab.Caption</note>
<note>The string labeled as Caption here is used in the QR Code badge to let the user know what the badge is used for.</note>
</trans-unit>
<trans-unit id="CollectionSettingsDialog.AdvancedTab.Caption.Description" translate="no">
<source xml:lang="en">If your caption contains "{0}", Bloom will fill this in with the name of the language.</source>
<note>ID: CollectionSettingsDialog.AdvancedTab.Caption.Description</note>
<note>{0} must not be translated but appear verbatim.</note>
</trans-unit>
<trans-unit id="CollectionSettingsDialog.BookMakingTab.QrCodeShowLanguage" translate="no">
<source xml:lang="en">Show QR code for current language books</source>
<note>ID: CollectionSettingsDialog.BookMakingTab.QrCodeShowLanguage</note>
<trans-unit id="CollectionSettingsDialog.AdvancedTab.QrCodeBadgeText" translate="no">
<source xml:lang="en">Get more books in the {0} language on BloomLibrary.org.</source>
<note>ID: CollectionSettingsDialog.AdvancedTab.QrCodeBadgeText</note>
<note>{0} will be replaced by a language name</note>
</trans-unit>
<trans-unit id="CollectionSettingsDialog.BookMakingTab.SpecialScriptSettingsLink">
<source xml:lang="en">Special Script Settings</source>
Expand Down
4 changes: 4 additions & 0 deletions src/BloomBrowserUI/collection/AdvancedSettingsPanel.entry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { bootstrapReactComponent } from "../utils/entryPointBootstrap";
import { AdvancedSettingsPanel } from "./AdvancedSettingsPanel";

bootstrapReactComponent(AdvancedSettingsPanel);
222 changes: 222 additions & 0 deletions src/BloomBrowserUI/collection/AdvancedSettingsPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
import { css } from "@emotion/react";
import * as React from "react";
import {
ConfigrBoolean,
ConfigrGroup,
ConfigrInput,
ConfigrPage,
ConfigrPane,
} from "@sillsdev/config-r";
import { get, postJson } from "../utils/bloomApi";
import { kBloomBlue } from "../bloomMaterialUITheme";
import { tabMargins } from "./commonTabSettings";
import { WireUpForWinforms } from "../utils/WireUpWinform";
import { BloomSubscriptionIndicatorIconAndText } from "../react_components/requiresSubscription";
import { useGetFeatureStatus } from "../react_components/featureStatus";
import { useL10n } from "../react_components/l10nHooks";

export const AdvancedSettingsPanel: React.FunctionComponent = () => {
const [settings, setSettings] = React.useState<object | undefined>(
undefined,
);
const [showAutoUpdate, setShowAutoUpdate] = React.useState<boolean>(false);
const [allowTeamCollectionEnabled, setAllowTeamCollectionEnabled] =
React.useState<boolean>(false);
const [
showExperimentalBookSourcesOption,
setShowExperimentalBookSourcesOption,
] = React.useState<boolean>(false);

const advancedProgramSettingsLabel = useL10n(
"Advanced Program Settings",
"CollectionSettingsDialog.AdvancedTab.AdvancedProgramSettingsTabLabel",
);
const programLabel = useL10n(
"Program",
"CollectionSettingsDialog.AdvancedTab.Program",
);
const automaticallyUpdateBloomLabel = useL10n(
"Automatically Update Bloom",
"CollectionSettingsDialog.AdvancedTab.AutoUpdate",
);
const showExperimentalBookSourcesLabel = useL10n(
"Show Experimental Book Sources",
"CollectionSettingsDialog.AdvancedTab.Experimental.ShowExperimentalBookSources",
);
const teamCollectionsLabel = useL10n(
"Team Collections",
"TeamCollection.TeamCollections",
);
const availableWithSubscriptionLabel = useL10n(
"Available with your Bloom Subscription",
"AvailableWithSubscription",
);
const qrCodesLabel = useL10n(
"QR Codes",
"CollectionSettingsDialog.AdvancedTab.QrCodes",
);
const showQrCodesLabel = useL10n(
"Show QR Codes",
"CollectionSettingsDialog.AdvancedTab.ShowQrCodes",
);
const showQrCodesDescription = useL10n(
"Scanning the code or clicking the badge will take the user to the collection of books in this collection's primary language. Note, if you want to use this but your branding does not show it, contact us.",
"CollectionSettingsDialog.AdvancedTab.ShowQrCodes.Description",
);
const captionLabel = useL10n(
"Caption",
"CollectionSettingsDialog.AdvancedTab.Caption",
);
const captionDescription = useL10n(
'If your caption contains "{0}", Bloom will fill this in with the name of the language.',
"CollectionSettingsDialog.AdvancedTab.Caption.Description",
);

const featureStatus = useGetFeatureStatus("TeamCollection");
const teamCollectionOptionEnabled =
featureStatus === undefined ? true : featureStatus.enabled;
const canChangeTeamCollectionOption = allowTeamCollectionEnabled !== false;
Comment thread
hatton marked this conversation as resolved.

const normalizeConfigrSettings = React.useCallback(
(settingsValue: string | object | undefined): object | undefined => {
if (!settingsValue) {
return undefined;
}
if (typeof settingsValue === "string") {
return JSON.parse(settingsValue) as object;
}
return settingsValue;
},
[],
);

// Load current advanced settings from the host dialog so Config-r starts with matching values.
React.useEffect(() => {
get("settings/advancedProgramSettings", (result) => {
if (!result || !result.data || result.data === "{}") {
return;
}
let data = result.data;
if (typeof result.data === "string") {
data = JSON.parse(result.data);
}
setSettings(data["values"]);
setShowAutoUpdate(data["showAutoUpdate"] ?? false);
setAllowTeamCollectionEnabled(
data["allowTeamCollectionEnabled"] ?? false,
);
setShowExperimentalBookSourcesOption(
data["showExperimentalBookSourcesOption"] ?? false,
);
});
}, []);

return (
<div
css={css`
display: flex;
flex-direction: column;
height: 100%;
padding-top: ${tabMargins.top};
padding-left: ${tabMargins.side};
padding-right: ${tabMargins.side};
padding-bottom: ${tabMargins.bottom};
`}
>
{settings && (
<ConfigrPane
label={advancedProgramSettingsLabel}
showAppBar={false}
showSearch={false}
initialValues={
settings as React.ComponentProps<
typeof ConfigrPane
>["initialValues"]
}
themeOverrides={{
palette: {
primary: { main: kBloomBlue },
},
}}
onChange={(newSettings) => {
const normalized =
normalizeConfigrSettings(newSettings);
if (normalized) {
setSettings(normalized);
postJson(
"settings/advancedProgramSettings",
normalized,
);
}
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
}}
>
<ConfigrPage label={""} pageKey="settings" topLevel={true}>
<ConfigrGroup label={programLabel}>
{showAutoUpdate && (
<ConfigrBoolean
label={automaticallyUpdateBloomLabel}
path="autoUpdate"
/>
)}
{showExperimentalBookSourcesOption && (
<ConfigrBoolean
label={showExperimentalBookSourcesLabel}
path="showExperimentalBookSources"
/>
)}
<div
css={css`
.Mui-disabled {
// The color already sets opacity to 0.26. We don't
// want to get any lighter, but MUI defaults to an
// additional "opacity: 0.38" for disabled elements.
opacity: 1;
}
`}
>
<ConfigrBoolean
label={teamCollectionsLabel}
path="allowTeamCollection"
disabled={
!teamCollectionOptionEnabled ||
!canChangeTeamCollectionOption
}
></ConfigrBoolean>
</div>
<div
css={css`
display: flex;
justify-content: flex-end;
.bloom-subscriptionIndicator {
font-size: 10pt;
font-weight: 700;
}
`}
>
<BloomSubscriptionIndicatorIconAndText
feature="TeamCollection"
className="bloom-subscriptionIndicator"
/>
</div>
</ConfigrGroup>
<ConfigrGroup label={qrCodesLabel}>
<ConfigrBoolean
label={showQrCodesLabel}
path="showQrCode"
description={showQrCodesDescription}
></ConfigrBoolean>
<ConfigrInput
path="qrcodeCaption"
label={captionLabel}
description={captionDescription}
disabled={!settings["showQrCode"]}
/>
</ConfigrGroup>
</ConfigrPage>
</ConfigrPane>
)}
</div>
);
};

WireUpForWinforms(AdvancedSettingsPanel);
66 changes: 0 additions & 66 deletions src/BloomBrowserUI/collection/BlorgLanguageQrCodeControl.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/BloomBrowserUI/collection/bookMakingSettingsControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import FontScriptSettingsControl from "./fontScriptSettingsControl";
import { tabMargins } from "./commonTabSettings";

import { WireUpForWinforms } from "../utils/WireUpWinform";
import BlorgLanguageQrCodeControl from "./BlorgLanguageQrCodeControl";

const BookMakingSettingsControl: React.FunctionComponent = () => {
return (
Expand All @@ -34,7 +33,6 @@ const BookMakingSettingsControl: React.FunctionComponent = () => {
>
<FontScriptSettingsControl />
<PageNumberStyleControl />
<BlorgLanguageQrCodeControl />
</div>
<div
css={css`
Expand Down
2 changes: 1 addition & 1 deletion src/BloomBrowserUI/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"@nivo/core": "^0.80.0",
"@nivo/scatterplot": "^0.80.0",
"@nivo/tooltip": "^0.80.0",
"@sillsdev/config-r": "1.0.0-alpha.18",
"@sillsdev/config-r": "1.0.0-alpha.23",
"@types/filesize": "^5.0.0",
"@types/react-transition-group": "^4.4.1",
"@use-it/event-listener": "^0.1.7",
Expand Down
1 change: 1 addition & 0 deletions src/BloomBrowserUI/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ export default defineConfig(async ({ command }) => {
accessibilityCheckBundle:
"./publish/accessibilityCheck/accessibilityCheckScreen.entry.tsx",
subscriptionSettingsBundle: "./collection/subscriptionSettingsTab.tsx",
advancedSettingsBundle: "./collection/AdvancedSettingsPanel.entry.tsx",
performanceLogBundle: "./performance/PerformanceLogPage.tsx",
appBundle: "./app/App.tsx",
problemReportBundle: "./problemDialog/ProblemDialog.tsx",
Expand Down
8 changes: 4 additions & 4 deletions src/BloomBrowserUI/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2940,10 +2940,10 @@
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.52.5.tgz#1657f56326bbe0ac80eedc9f9c18fc1ddd24e107"
integrity sha512-TAcgQh2sSkykPRWLrdyy2AiceMckNf5loITqXxFI5VuQjS5tSuw3WlwdN8qv8vzjLAUTvYaH/mVjSFpbkFbpTg==

"@sillsdev/config-r@1.0.0-alpha.18":
version "1.0.0-alpha.18"
resolved "https://registry.npmjs.org/@sillsdev/config-r/-/config-r-1.0.0-alpha.18.tgz#177178ec2bba9e2843a3edab949c6b6489f0286d"
integrity sha512-EFiyAwUTMJ4jlvXRMBsO4+Zm8Gkaur+idUB3czXADqE0zG8ZnrMug951dWv67uFLH6hZT9jhGasEsHU1G/2/qA==
"@sillsdev/config-r@1.0.0-alpha.23":
version "1.0.0-alpha.23"
resolved "https://registry.yarnpkg.com/@sillsdev/config-r/-/config-r-1.0.0-alpha.23.tgz#70805e49e6dd8bb197eb2b110999a3501f80e98b"
integrity sha512-8s6+frggiRi7YUzF8J1wBAVEHXE1BucxEyKoqymyYSokqwzc107GokTIDr7YJO39rIOcrhI3ojWNGTUeeHfQjQ==
dependencies:
"@textea/json-viewer" "^2.13.1"
formik "^2.2.9"
Expand Down
Loading