Skip to content
Snippets Groups Projects
Unverified Commit 9bfbf229 authored by Joel Jeremy Marquez's avatar Joel Jeremy Marquez Committed by GitHub
Browse files

Reports privacy filter (#1447)

<!-- Thank you for submitting a pull request! Make sure to follow the
instructions to write release notes for your PR — it should only take a
minute or two:
https://github.com/actualbudget/docs#writing-good-release-notes -->

Addresses
https://github.com/actualbudget/actual/issues/1360#issuecomment-1646600087
parent 2d11c0f6
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ import Block from '../common/Block'; ...@@ -13,6 +13,7 @@ import Block from '../common/Block';
import Paragraph from '../common/Paragraph'; import Paragraph from '../common/Paragraph';
import Text from '../common/Text'; import Text from '../common/Text';
import View from '../common/View'; import View from '../common/View';
import PrivacyFilter from '../PrivacyFilter';
import Change from './Change'; import Change from './Change';
import { cashFlowByDate } from './graphs/cash-flow-spreadsheet'; import { cashFlowByDate } from './graphs/cash-flow-spreadsheet';
...@@ -132,7 +133,7 @@ function CashFlow() { ...@@ -132,7 +133,7 @@ function CashFlow() {
left={<Block>Income:</Block>} left={<Block>Income:</Block>}
right={ right={
<Text style={{ fontWeight: 600 }}> <Text style={{ fontWeight: 600 }}>
{integerToCurrency(totalIncome)} <PrivacyFilter>{integerToCurrency(totalIncome)}</PrivacyFilter>
</Text> </Text>
} }
/> />
...@@ -142,7 +143,9 @@ function CashFlow() { ...@@ -142,7 +143,9 @@ function CashFlow() {
left={<Block>Expenses:</Block>} left={<Block>Expenses:</Block>}
right={ right={
<Text style={{ fontWeight: 600 }}> <Text style={{ fontWeight: 600 }}>
{integerToCurrency(totalExpenses)} <PrivacyFilter>
{integerToCurrency(totalExpenses)}
</PrivacyFilter>
</Text> </Text>
} }
/> />
...@@ -152,12 +155,16 @@ function CashFlow() { ...@@ -152,12 +155,16 @@ function CashFlow() {
left={<Block>Transfers:</Block>} left={<Block>Transfers:</Block>}
right={ right={
<Text style={{ fontWeight: 600 }}> <Text style={{ fontWeight: 600 }}>
{integerToCurrency(totalTransfers)} <PrivacyFilter>
{integerToCurrency(totalTransfers)}
</PrivacyFilter>
</Text> </Text>
} }
/> />
<Text style={{ fontWeight: 600 }}> <Text style={{ fontWeight: 600 }}>
<Change amount={totalIncome + totalExpenses + totalTransfers} /> <PrivacyFilter>
<Change amount={totalIncome + totalExpenses + totalTransfers} />
</PrivacyFilter>
</Text> </Text>
</View> </View>
......
...@@ -11,6 +11,7 @@ import useFilters from '../../hooks/useFilters'; ...@@ -11,6 +11,7 @@ import useFilters from '../../hooks/useFilters';
import { styles } from '../../style'; import { styles } from '../../style';
import Paragraph from '../common/Paragraph'; import Paragraph from '../common/Paragraph';
import View from '../common/View'; import View from '../common/View';
import PrivacyFilter from '../PrivacyFilter';
import Change from './Change'; import Change from './Change';
import netWorthSpreadsheet from './graphs/net-worth-spreadsheet'; import netWorthSpreadsheet from './graphs/net-worth-spreadsheet';
...@@ -117,9 +118,13 @@ export default function NetWorth() { ...@@ -117,9 +118,13 @@ export default function NetWorth() {
<View <View
style={[styles.largeText, { fontWeight: 400, marginBottom: 5 }]} style={[styles.largeText, { fontWeight: 400, marginBottom: 5 }]}
> >
{integerToCurrency(data.netWorth)} <PrivacyFilter blurIntensity={5}>
{integerToCurrency(data.netWorth)}
</PrivacyFilter>
</View> </View>
<Change amount={data.totalChange} /> <PrivacyFilter>
<Change amount={data.totalChange} />
</PrivacyFilter>
</View> </View>
<NetWorthGraph start={start} end={end} graphData={data.graphData} /> <NetWorthGraph start={start} end={end} graphData={data.graphData} />
......
import React, { useMemo } from 'react'; import React, { useCallback, useMemo, useState } from 'react';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { VictoryBar, VictoryGroup, VictoryVoronoiContainer } from 'victory'; import { VictoryBar, VictoryGroup, VictoryVoronoiContainer } from 'victory';
...@@ -10,6 +10,7 @@ import { colors, styles } from '../../style'; ...@@ -10,6 +10,7 @@ import { colors, styles } from '../../style';
import AnchorLink from '../common/AnchorLink'; import AnchorLink from '../common/AnchorLink';
import Block from '../common/Block'; import Block from '../common/Block';
import View from '../common/View'; import View from '../common/View';
import PrivacyFilter from '../PrivacyFilter';
import Change from './Change'; import Change from './Change';
import theme from './chart-theme'; import theme from './chart-theme';
...@@ -61,6 +62,9 @@ function Card({ flex, to, style, children }) { ...@@ -61,6 +62,9 @@ function Card({ flex, to, style, children }) {
function NetWorthCard({ accounts }) { function NetWorthCard({ accounts }) {
const end = monthUtils.currentMonth(); const end = monthUtils.currentMonth();
const start = monthUtils.subMonths(end, 5); const start = monthUtils.subMonths(end, 5);
const [isCardHovered, setIsCardHovered] = useState(false);
const onCardHover = useCallback(() => setIsCardHovered(true));
const onCardHoverEnd = useCallback(() => setIsCardHovered(false));
const params = useMemo( const params = useMemo(
() => netWorthSpreadsheet(start, end, accounts), () => netWorthSpreadsheet(start, end, accounts),
...@@ -74,7 +78,11 @@ function NetWorthCard({ accounts }) { ...@@ -74,7 +78,11 @@ function NetWorthCard({ accounts }) {
return ( return (
<Card flex={2} to="/reports/net-worth"> <Card flex={2} to="/reports/net-worth">
<View style={{ flex: 1 }}> <View
style={{ flex: 1 }}
onPointerEnter={onCardHover}
onPointerLeave={onCardHoverEnd}
>
<View style={{ flexDirection: 'row', padding: 20 }}> <View style={{ flexDirection: 'row', padding: 20 }}>
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<Block <Block
...@@ -89,12 +97,16 @@ function NetWorthCard({ accounts }) { ...@@ -89,12 +97,16 @@ function NetWorthCard({ accounts }) {
<Block <Block
style={[styles.mediumText, { fontWeight: 500, marginBottom: 5 }]} style={[styles.mediumText, { fontWeight: 500, marginBottom: 5 }]}
> >
{integerToCurrency(data.netWorth)} <PrivacyFilter activationFilters={[!isCardHovered]}>
{integerToCurrency(data.netWorth)}
</PrivacyFilter>
</Block> </Block>
<Change <PrivacyFilter activationFilters={[!isCardHovered]}>
amount={data.totalChange} <Change
style={{ color: colors.n6, fontWeight: 300 }} amount={data.totalChange}
/> style={{ color: colors.n6, fontWeight: 300 }}
/>
</PrivacyFilter>
</View> </View>
</View> </View>
...@@ -116,6 +128,10 @@ function CashFlowCard() { ...@@ -116,6 +128,10 @@ function CashFlowCard() {
const params = useMemo(() => simpleCashFlow(start, end), [start, end]); const params = useMemo(() => simpleCashFlow(start, end), [start, end]);
const data = useReport('cash_flow_simple', params); const data = useReport('cash_flow_simple', params);
const [isCardHovered, setIsCardHovered] = useState(false);
const onCardHover = useCallback(() => setIsCardHovered(true));
const onCardHoverEnd = useCallback(() => setIsCardHovered(false));
if (!data) { if (!data) {
return null; return null;
} }
...@@ -126,7 +142,11 @@ function CashFlowCard() { ...@@ -126,7 +142,11 @@ function CashFlowCard() {
return ( return (
<Card flex={1} to="/reports/cash-flow"> <Card flex={1} to="/reports/cash-flow">
<View style={{ flex: 1 }}> <View
style={{ flex: 1 }}
onPointerEnter={onCardHover}
onPointerLeave={onCardHoverEnd}
>
<View style={{ flexDirection: 'row', padding: 20 }}> <View style={{ flexDirection: 'row', padding: 20 }}>
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<Block <Block
...@@ -138,10 +158,12 @@ function CashFlowCard() { ...@@ -138,10 +158,12 @@ function CashFlowCard() {
<DateRange start={start} end={end} /> <DateRange start={start} end={end} />
</View> </View>
<View style={{ textAlign: 'right' }}> <View style={{ textAlign: 'right' }}>
<Change <PrivacyFilter activationFilters={[!isCardHovered]}>
amount={income - expense} <Change
style={{ color: colors.n6, fontWeight: 300 }} amount={income - expense}
/> style={{ color: colors.n6, fontWeight: 300 }}
/>
</PrivacyFilter>
</View> </View>
</View> </View>
...@@ -185,10 +207,14 @@ function CashFlowCard() { ...@@ -185,10 +207,14 @@ function CashFlowCard() {
x: 30, x: 30,
y: Math.max(income, 5), y: Math.max(income, 5),
premadeLabel: ( premadeLabel: (
<div style={{ textAlign: 'right' }}> <View style={{ textAlign: 'right' }}>
<div>Income</div> Income
<div>{integerToCurrency(income)}</div> <View>
</div> <PrivacyFilter activationFilters={[!isCardHovered]}>
{integerToCurrency(income)}
</PrivacyFilter>
</View>
</View>
), ),
labelPosition: 'left', labelPosition: 'left',
}, },
...@@ -202,10 +228,14 @@ function CashFlowCard() { ...@@ -202,10 +228,14 @@ function CashFlowCard() {
x: 60, x: 60,
y: Math.max(expense, 5), y: Math.max(expense, 5),
premadeLabel: ( premadeLabel: (
<div> <View>
<div>Expenses</div> Expenses
<div>{integerToCurrency(expense)}</div> <View>
</div> <PrivacyFilter activationFilters={[!isCardHovered]}>
{integerToCurrency(expense)}
</PrivacyFilter>
</View>
</View>
), ),
labelPosition: 'right', labelPosition: 'right',
fill: theme.colors.red, fill: theme.colors.red,
......
---
category: Enhancements
authors: [joel-jeremy]
---
Reports privacy filter
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment