Skip to content

Commit

Permalink
Merge branch 'master' into electron/file-management-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MikesGlitch authored Oct 7, 2024
2 parents 11f9b09 + 279d545 commit 39e68c7
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 25 deletions.
1 change: 1 addition & 0 deletions .github/workflows/size-compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
workflow: build.yml
name: build-stats
path: head
allow_forks: true

- name: Strip content hashes from stats files
run: |
Expand Down
30 changes: 20 additions & 10 deletions packages/desktop-client/src/components/reports/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,26 @@ export function Overview() {
const isDashboardsFeatureEnabled = useFeatureFlag('dashboards');
const spendingReportFeatureFlag = useFeatureFlag('spendingReport');

const baseLayout = widgets.map(widget => ({
i: widget.id,
w: widget.width,
h: widget.height,
minW:
isCustomReportWidget(widget) || widget.type === 'markdown-card' ? 2 : 3,
minH:
isCustomReportWidget(widget) || widget.type === 'markdown-card' ? 1 : 2,
...widget,
}));
const baseLayout = widgets
.map(widget => ({
i: widget.id,
w: widget.width,
h: widget.height,
minW:
isCustomReportWidget(widget) || widget.type === 'markdown-card' ? 2 : 3,
minH:
isCustomReportWidget(widget) || widget.type === 'markdown-card' ? 1 : 2,
...widget,
}))
.filter(item => {
if (isDashboardsFeatureEnabled) {
return true;
}
if (item.type === 'custom-report' && !customReportMap.has(item.meta.id)) {
return false;
}
return true;
});

const layout =
spendingReportFeatureFlag &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,28 @@ import { numberFormatterTooltip } from '../numberFormatter';

type NetWorthGraphProps = {
style?: CSSProperties;
graphData;
compact: boolean;
graphData: {
data: Array<{
x: string;
y: number;
assets: string;
debt: string;
change: string;
networth: string;
date: string;
}>;
hasNegative: boolean;
start: string;
end: string;
};
compact?: boolean;
showTooltip?: boolean;
};

export function NetWorthGraph({
style,
graphData,
compact,
compact = false,
showTooltip = true,
}: NetWorthGraphProps) {
const { t } = useTranslation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useWidget } from 'loot-core/src/client/data-hooks/widget';
import { send } from 'loot-core/src/platform/client/fetch';
import * as monthUtils from 'loot-core/src/shared/months';
import { integerToCurrency } from 'loot-core/src/shared/util';
import { type TimeFrame, type NetWorthWidget } from 'loot-core/types/models';

import { useAccounts } from '../../../hooks/useAccounts';
import { useFilters } from '../../../hooks/useFilters';
Expand All @@ -33,7 +34,7 @@ import { fromDateRepr } from '../util';

export function NetWorth() {
const params = useParams();
const { data: widget, isLoading } = useWidget(
const { data: widget, isLoading } = useWidget<NetWorthWidget>(
params.id ?? '',
'net-worth-card',
);
Expand All @@ -45,22 +46,28 @@ export function NetWorth() {
return <NetWorthInner widget={widget} />;
}

function NetWorthInner({ widget }) {
type NetWorthInnerProps = {
widget?: NetWorthWidget;
};

function NetWorthInner({ widget }: NetWorthInnerProps) {
const dispatch = useDispatch();
const { t } = useTranslation();

const accounts = useAccounts();
const {
conditions,
saved,
conditionsOp,
onApply: onApplyFilter,
onDelete: onDeleteFilter,
onUpdate: onUpdateFilter,
onConditionsOpChange,
} = useFilters(widget?.meta?.conditions, widget?.meta?.conditionsOp);

const [allMonths, setAllMonths] = useState(null);
const [allMonths, setAllMonths] = useState<Array<{
name: string;
pretty: string;
}> | null>(null);

const [initialStart, initialEnd, initialMode] = calculateTimeRange(
widget?.meta?.timeFrame,
Expand Down Expand Up @@ -103,15 +110,19 @@ function NetWorthInner({ widget }) {
run();
}, []);

function onChangeDates(start, end, mode) {
function onChangeDates(start: string, end: string, mode: TimeFrame['mode']) {
setStart(start);
setEnd(end);
setMode(mode);
}

async function onSaveWidget() {
if (!widget) {
throw new Error('No widget that could be saved.');
}

await send('dashboard-update-widget', {
id: widget?.id,
id: widget.id,
meta: {
...(widget.meta ?? {}),
conditions,
Expand Down Expand Up @@ -163,7 +174,6 @@ function NetWorthInner({ widget }) {
mode={mode}
onChangeDates={onChangeDates}
filters={conditions}
saved={saved}
onApply={onApplyFilter}
onUpdateFilter={onUpdateFilter}
onDeleteFilter={onDeleteFilter}
Expand Down Expand Up @@ -203,12 +213,7 @@ function NetWorthInner({ widget }) {
</View>

<NetWorthGraph
start={start}
end={end}
graphData={data.graphData}
domain={{
y: [data.lowestNetWorth * 0.99, data.highestNetWorth * 1.01],
}}
showTooltip={!isNarrowWidth}
/>

Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3566.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---

Reports: fix old reports page having empty blocks.
6 changes: 6 additions & 0 deletions upcoming-release-notes/3576.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MatissJanis]
---

TypeScript: migrate `NetWorth` component to TS.
6 changes: 6 additions & 0 deletions upcoming-release-notes/3594.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [matt-fidd]
---

Fix regression in size comparison workflow

0 comments on commit 39e68c7

Please sign in to comment.