Skip to content

Commit d6c5970

Browse files
committed
user ability to toggle showing account balance in top bar
1 parent 4fb9e7d commit d6c5970

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/packages/frontend/account/other-settings.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function OtherSettings(props: Readonly<Props>): React.JSX.Element {
107107
>
108108
<FormattedMessage
109109
id="account.other-settings.global_banner"
110-
defaultMessage={`<strong>Show announcement banner</strong>: only shows up if there is a
110+
defaultMessage={`<strong>Show Announcement Banner</strong>: only shows up if there is a
111111
message`}
112112
/>
113113
</Checkbox>
@@ -122,7 +122,7 @@ export function OtherSettings(props: Readonly<Props>): React.JSX.Element {
122122
>
123123
<FormattedMessage
124124
id="account.other-settings.time_ago_absolute"
125-
defaultMessage={`Display <strong>timestamps as absolute points in time</strong>
125+
defaultMessage={`<strong>Display Timestamps as absolute points in time</strong>
126126
instead of relative to the current time`}
127127
/>
128128
</Checkbox>
@@ -195,7 +195,7 @@ export function OtherSettings(props: Readonly<Props>): React.JSX.Element {
195195
>
196196
<FormattedMessage
197197
id="account.other-settings.mask_files"
198-
defaultMessage={`<strong>Mask files:</strong> grey out files in the files viewer
198+
defaultMessage={`<strong>Mask Files:</strong> grey out files in the files viewer
199199
that you probably do not want to open`}
200200
/>
201201
</Checkbox>
@@ -666,6 +666,15 @@ export function OtherSettings(props: Readonly<Props>): React.JSX.Element {
666666
{render_hide_project_popovers()}
667667
{render_hide_file_popovers()}
668668
{render_hide_button_tooltips()}
669+
<Checkbox
670+
checked={!!props.other_settings.get("hide_navbar_balance")}
671+
onChange={(e) => on_change("hide_navbar_balance", e.target.checked)}
672+
>
673+
<FormattedMessage
674+
id="account.other-settings.hide_navbar_balance"
675+
defaultMessage={`<strong>Hide Account Balance</strong> in navigation bar`}
676+
/>
677+
</Checkbox>
669678
{render_no_free_warnings()}
670679
<Checkbox
671680
checked={!!props.other_settings.get("disable_markdown_codebar")}

src/packages/frontend/purchases/balance-button.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export default function BalanceButton({
2727
const dbBalance = useTypedRedux("account", "balance");
2828
const balanceAlert = useTypedRedux("account", "balance_alert");
2929
const [balance, setBalance] = useState<number | null>(dbBalance ?? null);
30+
const otherSettings = useTypedRedux("account", "other_settings");
31+
const hideNavbarBalance = otherSettings?.get("hide_navbar_balance");
3032

3133
useEffect(() => {
3234
if (dbBalance != null) {
@@ -123,7 +125,7 @@ export default function BalanceButton({
123125

124126
// This ensures it only shows up in commercial setups.
125127
// Wherever it is used, the component shouldn't be instantiated in those cases, though.
126-
if (!is_commercial) {
128+
if (!is_commercial || (topBar && hideNavbarBalance && !balanceAlert)) {
127129
return;
128130
} else {
129131
return (

src/packages/util/db-schema/accounts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ Table({
508508
no_email_new_messages: false,
509509
[USE_BALANCE_TOWARD_SUBSCRIPTIONS]:
510510
USE_BALANCE_TOWARD_SUBSCRIPTIONS_DEFAULT,
511+
hide_navbar_balance: false,
511512
},
512513
name: null,
513514
first_name: "",

0 commit comments

Comments
 (0)