Skip to content

A local-first personal finance app

[AI] Expose tag splitting and scope selection in custom reports (#8948)

Julian Dominguez-Schatzfab0ab1b9a24
diff --git a/packages/desktop-client/e2e/reports.test.ts b/packages/desktop-client/e2e/reports.test.ts
index 15f3d2a192..b29e609b6a 100644
--- a/packages/desktop-client/e2e/reports.test.ts
+++ b/packages/desktop-client/e2e/reports.test.ts
@@ -1,6 +1,7 @@
import type { Page } from '@playwright/test';
import { expect, test } from './fixtures';
+import { AccountPage } from './page-models/account-page';
import { ConfigurationPage } from './page-models/configuration-page';
import type { CustomReportPage } from './page-models/custom-report-page';
import { Navigation } from './page-models/navigation';
@@ -149,6 +150,139 @@ test.describe('Reports', () => {
});
});
+ test('splits transactions into exact tag buckets and scopes them', async () => {
+ test.setTimeout(90_000);
+ const settingsPage = await navigation.goToSettingsPage();
+ await settingsPage.goToSection('Tags');
+ await page.getByRole('button', { name: 'Add New', exact: true }).click();
+ for (const tag of ['red', 'circle']) {
+ await page.getByPlaceholder('New tag', { exact: true }).fill(tag);
+ await page.getByTestId('new-tag').getByTestId('add-button').click();
+ await expect(page.getByText(`#${tag}`, { exact: true })).toBeVisible();
+ }
+
+ const accountPage = await navigation.goToAccountPage(
+ 'Capital One Checking',
+ );
+ await accountPage.createSingleTransaction({
+ debit: '10.00',
+ payee: 'Kroger',
+ notes: '#red',
+ category: 'Food',
+ });
+ await accountPage.createSingleTransaction({
+ debit: '20.00',
+ payee: 'Kroger',
+ notes: '#circle',
+ category: 'Food',
+ });
+ await accountPage.createSingleTransaction({
+ debit: '30.00',
+ payee: 'Kroger',
+ notes: '#red #circle',
+ category: 'Food',
+ });
+
+ reportsPage = await navigation.goToReportsPage();
+ await reportsPage.waitToLoad();
+ customReportPage = await reportsPage.goToCustomReportPage();
+
+ const splitRow = page.getByText('Split:', { exact: true }).locator('..');
+ await splitRow.getByRole('button').click();
+ await page.getByRole('button', { name: 'Tag', exact: true }).click();
+ await customReportPage.selectViz('Data Table');
+
+ await expect(page.getByText('#red', { exact: true })).toBeVisible();
+ await expect(page.getByText('#circle', { exact: true })).toBeVisible();
+ await expect(
+ page.getByText('#circle + #red', { exact: true }),
+ ).toBeVisible();
+ await expect(page.getByTestId('report-row-#circle + #red')).toContainText(
+ '-30.00',
+ );
+
+ await page.getByRole('button', { name: 'Tag scope: All tags' }).click();
+ const tagScopePopover = page.locator('[data-popover]');
+ await expect(tagScopePopover).toMatchThemeScreenshots();
+ await page.keyboard.press('Escape');
+ const typeRow = page.getByText('Type:', { exact: true }).locator('..');
+ await expect(splitRow).toMatchThemeScreenshots();
+
+ await page
+ .getByTestId('report-row-#circle + #red')
+ .getByText('-30.00', { exact: true })
+ .click();
+ await page.waitForURL('**/accounts');
+
+ const drilldownAccountPage = new AccountPage(page);
+ await expect(
+ drilldownAccountPage.transactionTable
+ .getByTestId('notes')
+ .filter({ hasText: '#red #circle' }),
+ ).toHaveCount(1);
+ const visibleTagNotes = (
+ await drilldownAccountPage.transactionTable
+ .getByTestId('notes')
+ .allTextContents()
+ ).filter(note => note.includes('#'));
+ expect(visibleTagNotes).toEqual(['#red #circle']);
+
+ await page.goBack();
+ await page.getByTestId('reports-page').waitFor();
+ await splitRow.getByRole('button').click();
+ await page.getByRole('button', { name: 'Tag', exact: true }).click();
+ await customReportPage.selectViz('Data Table');
+ await page.getByRole('button', { name: 'Tag scope: All tags' }).click();
+ const scopedTagPopover = page.getByTestId('tag-scope-popover');
+ await scopedTagPopover
+ .getByRole('textbox', { name: 'Search tags' })
+ .fill('red');
+ await scopedTagPopover
+ .getByRole('button', { name: '#red', exact: true })
+ .click();
+ await expect(
+ scopedTagPopover.locator('button').filter({ hasText: '#red' }),
+ ).toBeVisible();
+ await scopedTagPopover.getByRole('button', { name: 'Apply' }).click();
+
+ await expect(
+ page.getByRole('button', { name: 'Tag scope: #red' }),
+ ).toBeVisible();
+ await expect(page.getByTestId('report-row-#red')).toContainText('-40.00');
+ await expect(
+ page.getByText('#circle + #red', { exact: true }),
+ ).not.toBeVisible();
+
+ await typeRow
+ .getByRole('button', { name: 'Payment', exact: true })
+ .click();
+ await page.getByRole('button', { name: 'Budgeted', exact: true }).click();
+ await expect(splitRow.getByRole('button')).toHaveText('Category');
+ });
+
+ test('warns about missing scoped tags without transaction filters', async () => {
+ await page.evaluate(() => {
+ sessionStorage.setItem('url', window.location.pathname);
+ sessionStorage.setItem(
+ 'report',
+ JSON.stringify({
+ groupBy: 'Tag',
+ tagScope: { mode: 'selected', tagIds: ['deleted-tag-id'] },
+ conditions: [],
+ }),
+ );
+ });
+ await page.reload();
+
+ const warning = page.getByText(/non-existing filter or tag/);
+ await expect(warning).toBeVisible();
+
+ const splitRow = page.getByText('Split:', { exact: true }).locator('..');
+ await splitRow.getByRole('button', { name: 'Tag', exact: true }).click();
+ await page.getByRole('button', { name: 'Category', exact: true }).click();
+ await expect(warning).not.toBeVisible();
+ });
+
test('Switches to Data Table and checks the visuals', async () => {
await customReportPage.selectMode('time');
await customReportPage.selectViz('Data Table');
diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-1-chromium-linux.png
new file mode 100644
index 0000000000..21ef23b003
Binary files /dev/null and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-2-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-2-chromium-linux.png
new file mode 100644
index 0000000000..7dedc2f643
Binary files /dev/null and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-2-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-3-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-3-chromium-linux.png
new file mode 100644
index 0000000000..8c1b4ecbc3
Binary files /dev/null and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-3-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-4-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-4-chromium-linux.png
new file mode 100644
index 0000000000..a60dec7fe7
Binary files /dev/null and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-4-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-5-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-5-chromium-linux.png
new file mode 100644
index 0000000000..535705a8de
Binary files /dev/null and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-5-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-6-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-6-chromium-linux.png
new file mode 100644
index 0000000000..29ffdbc79f
Binary files /dev/null and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-splits-transactions-into-exact-tag-buckets-and-scopes-them-6-chromium-linux.png differ
diff --git a/packages/desktop-client/src/components/autocomplete/TagMultiAutocomplete.test.tsx b/packages/desktop-client/src/components/autocomplete/TagMultiAutocomplete.test.tsx
new file mode 100644
index 0000000000..57f17de61c
--- /dev/null
+++ b/packages/desktop-client/src/components/autocomplete/TagMultiAutocomplete.test.tsx
@@ -0,0 +1,50 @@
+import { useState } from 'react';
+
+import type { TagEntity } from '@actual-app/core/types/models';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+
+import { TestProviders } from '#mocks';
+
+import { TagMultiAutocomplete } from './TagMultiAutocomplete';
+
+const tags: TagEntity[] = [
+ { id: 'red-id', tag: 'red' },
+ { id: 'circle-id', tag: 'circle' },
+];
+
+function FilterTagPicker() {
+ const [value, setValue] = useState('#missing #red');
+
+ return (
+ <TestProviders>
+ <TagMultiAutocomplete
+ tags={tags}
+ value={value}
+ setValue={setValue}
+ embedded
+ inputProps={{ 'aria-label': 'Choose tags' }}
+ />
+ <output>{value}</output>
+ </TestProviders>
+ );
+}
+
+describe('TagMultiAutocomplete', () => {
+ it('preserves filter tag IDs and order while adding and removing tags', async () => {
+ const user = userEvent.setup();
+ render(<FilterTagPicker />);
+
+ await user.type(
+ screen.getByRole('textbox', { name: 'Choose tags' }),
+ 'cir',
+ );
+ await user.click(screen.getByRole('button', { name: '#circle' }));
+ expect(screen.getByRole('status')).toHaveTextContent(
+ '#missing #red #circle',
+ );
+
+ await user.click(screen.getByRole('button', { name: '#red' }));
+ expect(screen.getByRole('status')).toHaveTextContent('#missing #circle');
+ });
+});
diff --git a/packages/desktop-client/src/components/autocomplete/TagMultiAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/TagMultiAutocomplete.tsx
index 0d5b210b96..e3e278b47e 100644
--- a/packages/desktop-client/src/components/autocomplete/TagMultiAutocomplete.tsx
+++ b/packages/desktop-client/src/components/autocomplete/TagMultiAutocomplete.tsx
@@ -1,4 +1,3 @@
-import { useMemo } from 'react';
import type { ComponentProps } from 'react';
import { Button } from '@actual-app/components/button';
@@ -7,6 +6,7 @@ import { SpaceBetween } from '@actual-app/components/space-between';
import { theme } from '@actual-app/components/theme';
import type { View } from '@actual-app/components/view';
import { extractTagsForFilter } from '@actual-app/core/shared/tags';
+import type { TagEntity } from '@actual-app/core/types/models';
import { css } from '@emotion/css';
import { useTagCSS } from '#hooks/useTagCSS';
@@ -15,38 +15,45 @@ import { filterTags, useTags } from '#hooks/useTags';
import { Autocomplete } from './Autocomplete';
import type { AutocompleteItem } from './Autocomplete';
-export function TagMultiAutocomplete({
- value,
- setValue,
-}: {
- value: string;
- setValue: (value: string) => void;
-}) {
- const tags = useMemo(() => {
- return extractTagsForFilter(value);
- }, [value]);
- const { data: allTags } = useTags();
- const allTagItems = useMemo(
- () =>
- allTags?.map(tag => ({
- ...tag,
- id: '#' + tag.tag,
- name: '#' + tag.tag,
- })) ?? [],
- [allTags],
- );
+type TagMultiAutocompleteProps = {
+ tags?: TagEntity[];
+ inputProps?: ComponentProps<typeof Autocomplete>['inputProps'];
+ containerProps?: ComponentProps<typeof Autocomplete>['containerProps'];
+ embedded?: boolean;
+ closeOnBlur?: boolean;
+} & (
+ | { mode?: 'names'; value: string; setValue: (value: string) => void }
+ | { mode: 'ids'; value: string[]; setValue: (value: string[]) => void }
+);
- function handleSelect(ids: string[]) {
- setValue(ids.join(' '));
- }
+export function TagMultiAutocomplete(props: TagMultiAutocompleteProps) {
+ const { tags, inputProps, containerProps, embedded, closeOnBlur } = props;
+ const { data: loadedTags = [] } = useTags();
+ const availableTags = tags ?? loadedTags;
+ const tagItems = availableTags.map(tag => ({
+ ...tag,
+ id: props.mode === 'ids' ? tag.id : '#' + tag.tag,
+ name: '#' + tag.tag,
+ }));
return (
- <Autocomplete<(typeof allTagItems)[number]>
- value={tags}
+ <Autocomplete<(typeof tagItems)[number]>
+ value={
+ props.mode === 'ids' ? props.value : extractTagsForFilter(props.value)
+ }
+ embedded={embedded}
+ closeOnBlur={closeOnBlur}
+ containerProps={containerProps}
strict
type="multi"
- onSelect={handleSelect}
- suggestions={allTagItems}
+ onSelect={ids => {
+ if (props.mode === 'ids') {
+ props.setValue(ids);
+ } else {
+ props.setValue(ids.join(' '));
+ }
+ }}
+ suggestions={tagItems}
filterSuggestions={filterTags}
renderItems={(items, getItemProps, highlightedIndex) => (
<TagList
@@ -56,7 +63,7 @@ export function TagMultiAutocomplete({
/>
)}
renderMultiItem={TagMultiItem}
- inputProps={{ placeholder: 'Choose tags' }}
+ inputProps={{ placeholder: 'Choose tags', ...inputProps }}
/>
);
}
diff --git a/packages/desktop-client/src/components/reports/ReportOptions.ts b/packages/desktop-client/src/components/reports/ReportOptions.ts
index e9bfd63525..b7c98700f9 100644
--- a/packages/desktop-client/src/components/reports/ReportOptions.ts
+++ b/packages/desktop-client/src/components/reports/ReportOptions.ts
@@ -62,6 +62,7 @@ const groupByOptions = [
{ description: t('Category+Group'), key: 'CategoryGroup' }, // new: two-ring donut support
{ description: t('Payee'), key: 'Payee' },
{ description: t('Account'), key: 'Account' },
+ { description: t('Tag'), key: 'Tag' },
{ description: t('Interval'), key: 'Interval' },
];
diff --git a/packages/desktop-client/src/components/reports/ReportSidebar.tsx b/packages/desktop-client/src/components/reports/ReportSidebar.tsx
index dcea77a684..013643059c 100644
--- a/packages/desktop-client/src/components/reports/ReportSidebar.tsx
+++ b/packages/desktop-client/src/components/reports/ReportSidebar.tsx
@@ -18,7 +18,9 @@ import type {
CategoryEntity,
CategoryGroupEntity,
CustomReportEntity,
+ CustomReportTagScope,
sortByOpType,
+ TagEntity,
TimeFrame,
TransactionEntity,
} from '@actual-app/core/types/models';
@@ -35,16 +37,19 @@ import { getIntervalFormat, ReportOptions } from './ReportOptions';
import type { dateRangeProps } from './ReportOptions';
import { validateEnd, validateStart } from './reportRanges';
import { setSessionReport } from './setSessionReport';
+import { TagScopeSelector } from './TagScopeSelector';
type ReportSidebarProps = {
customReportItems: CustomReportEntity;
selectedCategories: CategoryEntity[];
categories: { list: CategoryEntity[]; grouped: CategoryGroupEntity[] };
+ tags: TagEntity[];
dateRangeLine: number;
allIntervals: { name: string; pretty: string }[];
setDateRange: (value: CustomReportEntity['dateRange']) => void;
setGraphType: (value: CustomReportEntity['graphType']) => void;
setGroupBy: (value: CustomReportEntity['groupBy']) => void;
+ setTagScope: (value: CustomReportTagScope) => void;
setInterval: (value: CustomReportEntity['interval']) => void;
setBalanceType: (value: CustomReportEntity['balanceType']) => void;
setSortBy: (value: CustomReportEntity['sortBy']) => void;
@@ -83,11 +88,13 @@ export function ReportSidebar({
customReportItems,
selectedCategories,
categories,
+ tags,
dateRangeLine,
allIntervals,
setDateRange,
setGraphType,
setGroupBy,
+ setTagScope,
setInterval,
setBalanceType,
setSortBy,
@@ -181,16 +188,23 @@ export function ReportSidebar({
defaultItems(cond);
};
+ const onChangeTagScope = (scope: CustomReportTagScope) => {
+ setSessionReport('tagScope', scope);
+ onReportChange({ type: 'modify' });
+ setTagScope(scope);
+ };
+
const onChangeBalanceType = (cond: string) => {
setSessionReport('balanceType', cond);
onReportChange({ type: 'modify' });
setBalanceType(cond);
if (cond === 'Budgeted') {
- // Budgeted does not support Payee and Account splits
+ // Budgeted does not support Payee, Account, or Tag splits
if (
customReportItems.groupBy === 'Payee' ||
- customReportItems.groupBy === 'Account'
+ customReportItems.groupBy === 'Account' ||
+ customReportItems.groupBy === 'Tag'
) {
setSessionReport('groupBy', 'Category');
setGroupBy('Category');
@@ -310,10 +324,27 @@ export function ReportSidebar({
])}
disabledKeys={
customReportItems.balanceType === 'Budgeted'
- ? [...new Set([...disabledItems('split'), 'Payee', 'Account'])]
+ ? [
+ ...new Set([
+ ...disabledItems('split'),
+ 'Payee',
+ 'Account',
+ 'Tag',
+ ]),
+ ]
: disabledItems('split')
}
+ style={{ minWidth: 0 }}
/>
+ {customReportItems.groupBy === 'Tag' && (
+ <View style={{ marginLeft: 5, minWidth: 0 }}>
+ <TagScopeSelector
+ tags={tags}
+ tagScope={customReportItems.tagScope}
+ onChange={onChangeTagScope}
+ />
+ </View>
+ )}
</View>
<View
diff --git a/packages/desktop-client/src/components/reports/TagScopeSelector.test.tsx b/packages/desktop-client/src/components/reports/TagScopeSelector.test.tsx
new file mode 100644
index 0000000000..c7cb08d513
--- /dev/null
+++ b/packages/desktop-client/src/components/reports/TagScopeSelector.test.tsx
@@ -0,0 +1,142 @@
+import { useState } from 'react';
+import type { ReactNode } from 'react';
+
+import type {
+ CustomReportTagScope,
+ TagEntity,
+} from '@actual-app/core/types/models';
+import { render as rtlRender, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+
+import { TestProviders } from '#mocks';
+
+import { TagScopeSelector } from './TagScopeSelector';
+
+function render(ui: ReactNode) {
+ return rtlRender(ui, { wrapper: TestProviders });
+}
+
+const tags: TagEntity[] = [
+ { id: 'red-id', tag: 'red' },
+ { id: 'circle-id', tag: 'circle' },
+ { id: 'blue-id', tag: 'blue' },
+ { id: 'hidden-id', tag: 'hidden', hidden: true },
+];
+
+function Harness({ initialScope }: { initialScope: CustomReportTagScope }) {
+ const [scope, setScope] = useState(initialScope);
+ return <TagScopeSelector tags={tags} tagScope={scope} onChange={setScope} />;
+}
+
+describe('TagScopeSelector', () => {
+ it.each([
+ { tagIds: ['red-id', 'circle-id', 'blue-id'] },
+ { tagIds: ['missing-id'] },
+ { tagIds: ['red-id', 'missing-id'] },
+ ])('does not change an untouched saved scope $tagIds', async ({ tagIds }) => {
+ const user = userEvent.setup();
+ const onChange = vi.fn();
+ render(
+ <TagScopeSelector
+ tags={tags}
+ tagScope={{ mode: 'selected', tagIds }}
+ onChange={onChange}
+ />,
+ );
+
+ await user.click(screen.getByRole('button', { name: /Tag scope:/ }));
+ await user.click(screen.getByRole('button', { name: 'Apply' }));
+
+ expect(onChange).not.toHaveBeenCalled();
+ });
+
+ it('can remove and reselect a tag without changing its ID', async () => {
+ const user = userEvent.setup();
+ const onChange = vi.fn();
+ render(
+ <TagScopeSelector
+ tags={tags}
+ tagScope={{ mode: 'selected', tagIds: ['red-id', 'circle-id'] }}
+ onChange={onChange}
+ />,
+ );
+
+ await user.click(screen.getByRole('button', { name: 'Tag scope: 2 tags' }));
+ await user.click(screen.getByRole('button', { name: '#red' }));
+ await user.type(
+ screen.getByRole('textbox', { name: 'Search tags' }),
+ 'red',
+ );
+ await user.click(screen.getByRole('button', { name: '#red' }));
+ await user.click(screen.getByRole('button', { name: 'Apply' }));
+
+ expect(onChange).not.toHaveBeenCalled();
+ });
+
+ it('searches tags and summarizes a selected singleton', async () => {
+ const user = userEvent.setup();
+ render(<Harness initialScope={{ mode: 'all' }} />);
+
+ await user.click(
+ screen.getByRole('button', { name: 'Tag scope: All tags' }),
+ );
+ expect(
+ screen.queryByRole('button', { name: '#hidden' }),
+ ).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: '#circle' })).toBeInTheDocument();
+ await user.type(
+ screen.getByRole('textbox', { name: 'Search tags' }),
+ 'red',
+ );
+
+ expect(
+ screen.queryByRole('button', { name: '#circle' }),
+ ).not.toBeInTheDocument();
+
+ await user.click(screen.getByRole('button', { name: '#red' }));
+ await user.click(screen.getByRole('button', { name: 'Apply' }));
+
+ expect(
+ screen.getByRole('button', { name: 'Tag scope: #red' }),
+ ).toBeInTheDocument();
+
+ await user.click(screen.getByRole('button', { name: 'Tag scope: #red' }));
+ await user.click(screen.getByRole('button', { name: '#red' }));
+ await user.click(screen.getByRole('textbox', { name: 'Search tags' }));
+ await user.click(screen.getByRole('button', { name: 'Apply' }));
+ expect(
+ screen.getByRole('button', { name: 'Tag scope: All tags' }),
+ ).toBeInTheDocument();
+ });
+
+ it.each(['Escape', 'outside click'])(
+ 'discards edits on %s',
+ async dismissal => {
+ const user = userEvent.setup();
+ const onChange = vi.fn();
+ render(
+ <TagScopeSelector
+ tags={tags}
+ tagScope={{ mode: 'selected', tagIds: ['red-id'] }}
+ onChange={onChange}
+ />,
+ );
+
+ await user.click(screen.getByRole('button', { name: /Tag scope:/ }));
+ await user.click(screen.getByRole('button', { name: '#red' }));
+ expect(onChange).not.toHaveBeenCalled();
+ if (dismissal === 'Escape') {
+ await user.click(screen.getByRole('textbox', { name: 'Search tags' }));
+ await user.keyboard('{Escape}');
+ } else {
+ await user.click(document.body);
+ }
+ expect(screen.queryByTestId('tag-scope-popover')).not.toBeInTheDocument();
+ expect(onChange).not.toHaveBeenCalled();
+
+ await user.click(screen.getByRole('button', { name: /Tag scope:/ }));
+ await user.click(screen.getByRole('button', { name: 'Apply' }));
+ expect(onChange).not.toHaveBeenCalled();
+ },
+ );
+});
diff --git a/packages/desktop-client/src/components/reports/TagScopeSelector.tsx b/packages/desktop-client/src/components/reports/TagScopeSelector.tsx
new file mode 100644
index 0000000000..100d720dcf
--- /dev/null
+++ b/packages/desktop-client/src/components/reports/TagScopeSelector.tsx
@@ -0,0 +1,137 @@
+import { useRef, useState } from 'react';
+import { Form } from 'react-aria-components';
+import { Trans, useTranslation } from 'react-i18next';
+
+import { Button } from '@actual-app/components/button';
+import { Popover } from '@actual-app/components/popover';
+import { Text } from '@actual-app/components/text';
+import { View } from '@actual-app/components/view';
+import type {
+ CustomReportTagScope,
+ TagEntity,
+} from '@actual-app/core/types/models';
+
+import { TagMultiAutocomplete } from '#components/autocomplete/TagMultiAutocomplete';
+
+import { normalizeTagScope, resolveTagScope } from './tagScope';
+
+type TagScopeSelectorProps = {
+ tags: TagEntity[];
+ tagScope: CustomReportTagScope | undefined;
+ onChange: (tagScope: CustomReportTagScope) => void;
+};
+
+export function TagScopeSelector({
+ tags,
+ tagScope,
+ onChange,
+}: TagScopeSelectorProps) {
+ const { t } = useTranslation();
+ const triggerRef = useRef<HTMLButtonElement>(null);
+ const [isOpen, setIsOpen] = useState(false);
+ const [draftTagIds, setDraftTagIds] = useState<string[]>([]);
+ const normalizedScope = normalizeTagScope(tagScope);
+ const visibleTags = tags.filter(tag => !tag.hidden);
+ const selectedTags = resolveTagScope(visibleTags, normalizedScope);
+ const originalIds =
+ normalizedScope.mode === 'all' ? [] : normalizedScope.tagIds;
+
+ const summary =
+ normalizedScope.mode === 'all'
+ ? t('All tags')
+ : selectedTags.length === 1
+ ? `#${selectedTags[0].tag}`
+ : t('{{count}} tags', { count: selectedTags.length });
+
+ function openSelector() {
+ setDraftTagIds(originalIds);
+ setIsOpen(true);
+ }
+
+ function applyScope() {
+ setIsOpen(false);
+ if (
+ originalIds.length === draftTagIds.length &&
+ originalIds.every(id => draftTagIds.includes(id))
+ ) {
+ return;
+ }
+
+ const selectedIds = visibleTags
+ .filter(tag => draftTagIds.includes(tag.id))
+ .map(tag => tag.id);
+ const isAll =
+ selectedIds.length === 0 || selectedIds.length === visibleTags.length;
+ if (isAll && normalizedScope.mode === 'all') return;
+
+ onChange(
+ isAll ? { mode: 'all' } : { mode: 'selected', tagIds: selectedIds },
+ );
+ }
+
+ return (
+ <>
+ <Button
+ ref={triggerRef}
+ onPress={openSelector}
+ aria-label={t('Tag scope: {{scope}}', { scope: summary })}
+ style={{ minWidth: 0, maxWidth: 160 }}
+ >
+ <Text
+ style={{
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ }}
+ >
+ {summary}
+ </Text>
+ </Button>
+ <Popover
+ triggerRef={triggerRef}
+ placement="bottom start"
+ isOpen={isOpen}
+ onOpenChange={setIsOpen}
+ style={{ width: 280, padding: 10 }}
+ >
+ <Form
+ data-testid="tag-scope-popover"
+ style={{ display: 'flex', flexDirection: 'column', gap: 8 }}
+ onSubmit={event => {
+ event.preventDefault();
+ applyScope();
+ }}
+ >
+ <Text>
+ <Trans>Leave empty to include all tags.</Trans>
+ </Text>
+ <TagMultiAutocomplete
+ mode="ids"
+ tags={visibleTags}
+ value={draftTagIds}
+ setValue={setDraftTagIds}
+ embedded
+ closeOnBlur={false}
+ containerProps={{
+ style: {
+ flexDirection: 'column',
+ maxHeight: 240,
+ overflowY: 'auto',
+ },
+ }}
+ inputProps={{
+ autoFocus: true,
+ placeholder: t('Search tags'),
+ 'aria-label': t('Search tags'),
+ }}
+ />
+ <View style={{ marginTop: 7, alignItems: 'flex-end' }}>
+ <Button variant="primary" type="submit">
+ <Trans>Apply</Trans>
+ </Button>
+ </View>
+ </Form>
+ </Popover>
+ </>
+ );
+}
diff --git a/packages/desktop-client/src/components/reports/disabledList.ts b/packages/desktop-client/src/components/reports/disabledList.ts
index d450e591e7..2c5789838e 100644
--- a/packages/desktop-client/src/components/reports/disabledList.ts
+++ b/packages/desktop-client/src/components/reports/disabledList.ts
@@ -103,7 +103,14 @@ const totalGraphOptions: graphOptions[] = [
{
description: 'AreaGraph',
// CategoryGroup is only valid for DonutGraph
- disabledSplit: ['Category', 'Group', 'CategoryGroup', 'Payee', 'Account'],
+ disabledSplit: [
+ 'Category',
+ 'Group',
+ 'CategoryGroup',
+ 'Payee',
+ 'Account',
+ 'Tag',
+ ],
defaultSplit: 'Interval',
disabledType: [],
defaultType: 'Payment',
@@ -212,11 +219,9 @@ export function disabledLegendLabel(
return disableLegendLabel[type];
}
-export function defaultsGraphList(
- item: string,
- newGraph: string,
- type: 'defaultSplit' | 'defaultType' | 'defaultSort',
-) {
+export function defaultsGraphList<
+ K extends 'defaultSplit' | 'defaultType' | 'defaultSort',
+>(item: string, newGraph: string, type: K) {
const graphList = modeOptions.find(d => d.description === item);
if (!graphList) {
return '';
diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
index a8e03a178c..27c134a9cc 100644
--- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
@@ -370,6 +370,8 @@ export function BarGraph({
showOffBudget,
type: 'totals',
...drilldown,
+ bucketTagNames: item.payload.bucketTagNames,
+ scopeTagNames: data.scopeTagNames,
});
}}
shape={(props: BarShapeProps) => (
diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
index ca9e22bbb4..ee91a149d8 100644
--- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
@@ -31,7 +31,7 @@ import { showActivity } from './showActivity';
const RADIAN = Math.PI / 180;
type ClickablePieItem = PieSectorDataItem &
- Partial<Pick<GroupedEntity, 'id' | 'uncategorizedId'>> &
+ Partial<Pick<GroupedEntity, 'id' | 'uncategorizedId' | 'bucketTagNames'>> &
Partial<Pick<IntervalEntity, 'intervalStartDate' | 'intervalEndDate'>>;
// ---------------------------------------------------------------------------
@@ -703,6 +703,8 @@ export function DonutGraph({
showOffBudget,
type: 'totals',
...drilldown,
+ bucketTagNames: item.bucketTagNames,
+ scopeTagNames: data.scopeTagNames,
});
}
}}
diff --git a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
index a998728269..db47af8715 100644
--- a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
@@ -189,7 +189,7 @@ export function LineGraph({
? computeTrendLines(data.intervalData, data.legend)
: [];
- const onShowActivity = (id, payload, uncategorizedId) => {
+ const onShowActivity = (id, payload, uncategorizedId, bucketTagNames) => {
showActivity({
navigate,
categories,
@@ -204,6 +204,8 @@ export function LineGraph({
field: groupBy.toLowerCase(),
id,
uncategorizedId,
+ bucketTagNames,
+ scopeTagNames: data.scopeTagNames,
interval,
});
};
@@ -300,6 +302,7 @@ export function LineGraph({
entry.id,
payload,
entry.uncategorizedId,
+ entry.bucketTagNames,
),
}}
/>
diff --git a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
index 175190179f..861a8e2738 100644
--- a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
@@ -320,6 +320,8 @@ export function StackedBarGraph({
field: groupBy.toLowerCase(),
id: entry.id,
uncategorizedId: entry.uncategorizedId,
+ bucketTagNames: entry.bucketTagNames,
+ scopeTagNames: data.scopeTagNames,
interval,
})
}
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx
index 9004732298..01e92cf94b 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx
@@ -94,6 +94,7 @@ export function ReportTable({
showHiddenCategories={showHiddenCategories}
showOffBudget={showOffBudget}
interval={interval}
+ scopeTagNames={data.scopeTagNames}
/>
);
};
@@ -125,6 +126,7 @@ export function ReportTable({
handleScroll={handleScroll}
height={32 + scrollWidthTotals}
interval={interval}
+ scopeTagNames={data.scopeTagNames}
colorized
/>
);
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
index c8ee75f477..971616e8c3 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
@@ -38,6 +38,7 @@ type ReportTableRowProps = {
handleScroll?: UIEventHandler<HTMLDivElement>;
height?: number;
colorized?: boolean;
+ scopeTagNames?: string[];
};
const getAmountColor = (amount: number) => {
@@ -66,6 +67,7 @@ export const ReportTableRow = memo(
height,
interval,
colorized,
+ scopeTagNames,
}: ReportTableRowProps) => {
const average = Math.round(item[balanceTypeOp] / intervalsCount);
const groupByItem = groupBy === 'Interval' ? 'date' : 'name';
@@ -111,6 +113,7 @@ export const ReportTableRow = memo(
return (
<Row
key={item.id}
+ data-testid={`report-row-${item.name}`}
height={height}
collapsed
style={{
@@ -189,6 +192,8 @@ export const ReportTableRow = memo(
id: item.id,
uncategorizedId: item.uncategorizedId,
interval,
+ bucketTagNames: item.bucketTagNames,
+ scopeTagNames,
})
}
width="flex"
@@ -240,6 +245,8 @@ export const ReportTableRow = memo(
type: 'assets',
...drilldown,
uncategorizedId: item.uncategorizedId,
+ bucketTagNames: item.bucketTagNames,
+ scopeTagNames,
})
}
/>
@@ -285,6 +292,8 @@ export const ReportTableRow = memo(
type: 'debts',
...drilldown,
uncategorizedId: item.uncategorizedId,
+ bucketTagNames: item.bucketTagNames,
+ scopeTagNames,
})
}
/>
@@ -329,6 +338,8 @@ export const ReportTableRow = memo(
type: 'totals',
...drilldown,
uncategorizedId: item.uncategorizedId,
+ bucketTagNames: item.bucketTagNames,
+ scopeTagNames,
})
}
width="flex"
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
index 1b46836e3c..a7e2409121 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
@@ -53,6 +53,7 @@ import type { SavedStatus } from '#components/reports/SaveReportMenu';
import { setSessionReport } from '#components/reports/setSessionReport';
import { createCustomSpreadsheet } from '#components/reports/spreadsheets/custom-spreadsheet';
import { createGroupedSpreadsheet } from '#components/reports/spreadsheets/grouped-spreadsheet';
+import { normalizeTagScope } from '#components/reports/tagScope';
import { useReport } from '#components/reports/useReport';
import { calculateHasWarning, fromDateRepr } from '#components/reports/util';
import { useAccounts } from '#hooks/useAccounts';
@@ -66,6 +67,7 @@ import { usePayees } from '#hooks/usePayees';
import { useReport as useCustomReport } from '#hooks/useReport';
import { useRuleConditionFilters } from '#hooks/useRuleConditionFilters';
import { useSyncedPref } from '#hooks/useSyncedPref';
+import { useTags } from '#hooks/useTags';
/**
* Transform `selectedCategories` into `conditions`.
@@ -150,6 +152,7 @@ function CustomReportInner({
const dateFormat = useDateFormat() || 'MM/dd/yyyy';
const { data: categories = { grouped: [], list: [] } } = useCategories();
+ const { data: tags = [] } = useTags();
const { isNarrowWidth } = useResponsive();
const [_firstDayOfWeekIdx] = useSyncedPref('firstDayOfWeekIdx');
const firstDayOfWeekIdx = _firstDayOfWeekIdx || '0';
@@ -270,6 +273,10 @@ function CustomReportInner({
const [mode, setMode] = useState(loadReport.mode);
const [isDateStatic, setIsDateStatic] = useState(loadReport.isDateStatic);
const [groupBy, setGroupBy] = useState(loadReport.groupBy);
+ const [tagScope, setTagScope] = useState(
+ normalizeTagScope(loadReport.tagScope),
+ );
+ const [metadata, setMetadata] = useState(loadReport.metadata);
const [interval, setInterval] = useState(loadReport.interval);
const [balanceType, setBalanceType] = useState(loadReport.balanceType);
const [sortBy, setSortBy] = useState(loadReport.sortBy);
@@ -489,6 +496,8 @@ function CustomReportInner({
categories: categories.list,
payees,
accounts,
+ tags,
+ tagScope: groupBy === 'Tag' ? tagScope : undefined,
});
useEffect(() => {
@@ -566,6 +575,8 @@ function CustomReportInner({
sortByOp,
payees,
accounts,
+ tags,
+ tagScope,
graphType,
firstDayOfWeekIdx,
dateFormat,
@@ -580,6 +591,8 @@ function CustomReportInner({
categories,
payees,
accounts,
+ tags,
+ tagScope,
conditions,
conditionsOp,
showEmpty,
@@ -608,6 +621,8 @@ function CustomReportInner({
dateRange,
mode,
groupBy,
+ tagScope,
+ metadata,
interval,
balanceType,
sortBy,
@@ -696,7 +711,7 @@ function CustomReportInner({
const defaultSort = defaultsGraphList(mode, chooseGraph, 'defaultSort');
if (defaultSort) {
setSessionReport('sortBy', defaultSort);
- setSortBy(defaultSort as CustomReportEntity['sortBy']);
+ setSortBy(defaultSort);
}
};
@@ -755,6 +770,8 @@ function CustomReportInner({
setDateRange(input.dateRange);
setMode(input.mode);
setGroupBy(input.groupBy);
+ setTagScope(normalizeTagScope(input.tagScope));
+ setMetadata(input.metadata);
setInterval(input.interval);
setBalanceType(input.balanceType);
setSortBy(input.sortBy);
@@ -893,11 +910,13 @@ function CustomReportInner({
customReportItems={customReportItems}
selectedCategories={selectedCategories}
categories={categories}
+ tags={tags}
dateRangeLine={dateRangeLine}
allIntervals={allIntervals}
setDateRange={setDateRange}
setGraphType={setGraphType}
setGroupBy={setGroupBy}
+ setTagScope={setTagScope}
setInterval={setInterval}
setBalanceType={setBalanceType}
setSortBy={setSortBy}
@@ -943,7 +962,7 @@ function CustomReportInner({
defaultItems={defaultItems}
/>
)}
- {conditions && conditions.length > 0 && (
+ {(conditions.length > 0 || hasWarning) && (
<View
style={{
marginBottom: 10,
@@ -953,44 +972,46 @@ function CustomReportInner({
flexShrink: 0,
}}
>
- <View
- style={{
- flexShrink: 0,
- flexDirection: 'row',
- alignItems: 'flex-start',
- justifyContent: 'flex-start',
- }}
- >
- <AppliedFilters
- conditions={conditions}
- onUpdate={(oldFilter, newFilter) => {
- setSessionReport(
- 'conditions',
- conditions.map(f => (f === oldFilter ? newFilter : f)),
- );
- onReportChange({ type: 'modify' });
- onUpdateFilter(oldFilter, newFilter);
- }}
- onDelete={deletedFilter => {
- setSessionReport(
- 'conditions',
- conditions.filter(f => f !== deletedFilter),
- );
- onDeleteFilter(deletedFilter);
- onReportChange({ type: 'modify' });
- }}
- conditionsOp={conditionsOp}
- onConditionsOpChange={co => {
- onConditionsOpChange(co);
- onReportChange({ type: 'modify' });
+ {conditions.length > 0 && (
+ <View
+ style={{
+ flexShrink: 0,
+ flexDirection: 'row',
+ alignItems: 'flex-start',
+ justifyContent: 'flex-start',
}}
- />
- </View>
+ >
+ <AppliedFilters
+ conditions={conditions}
+ onUpdate={(oldFilter, newFilter) => {
+ setSessionReport(
+ 'conditions',
+ conditions.map(f => (f === oldFilter ? newFilter : f)),
+ );
+ onReportChange({ type: 'modify' });
+ onUpdateFilter(oldFilter, newFilter);
+ }}
+ onDelete={deletedFilter => {
+ setSessionReport(
+ 'conditions',
+ conditions.filter(f => f !== deletedFilter),
+ );
+ onDeleteFilter(deletedFilter);
+ onReportChange({ type: 'modify' });
+ }}
+ conditionsOp={conditionsOp}
+ onConditionsOpChange={co => {
+ onConditionsOpChange(co);
+ onReportChange({ type: 'modify' });
+ }}
+ />
+ </View>
+ )}
{hasWarning && (
<Warning style={{ paddingTop: 5, paddingBottom: 5 }}>
{t(
- 'This report is configured to use a non-existing filter value (i.e. category/account/payee).',
+ 'This report is configured to use a non-existing filter or tag value.',
)}
</Warning>
)}
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx b/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx
index d3c72a329c..8109a45e39 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx
@@ -19,6 +19,7 @@ import { useAccounts } from '#hooks/useAccounts';
import { useCategories } from '#hooks/useCategories';
import { usePayees } from '#hooks/usePayees';
import { useSyncedPref } from '#hooks/useSyncedPref';
+import { useTags } from '#hooks/useTags';
import { addNotification } from '#notifications/notificationsSlice';
import { useDispatch } from '#redux';
import { useUpdateReportMutation } from '#reports/mutations';
@@ -74,11 +75,14 @@ function CustomReportListCardsInner({
const { data: payees = [] } = usePayees();
const { data: accounts = [] } = useAccounts();
const { data: categories = { list: [], grouped: [] } } = useCategories();
+ const { data: tags = [] } = useTags();
const hasWarning = calculateHasWarning(report.conditions ?? [], {
categories: categories.list,
payees,
accounts,
+ tags,
+ tagScope: report.groupBy === 'Tag' ? report.tagScope : undefined,
});
const [_firstDayOfWeekIdx] = useSyncedPref('firstDayOfWeekIdx');
@@ -165,6 +169,7 @@ function CustomReportListCardsInner({
payees={payees}
accounts={accounts}
categories={categories}
+ tags={tags}
earliestTransaction={earliestTransaction}
latestTransaction={latestTransaction}
firstDayOfWeekIdx={firstDayOfWeekIdx}
@@ -175,7 +180,7 @@ function CustomReportListCardsInner({
<View style={{ padding: 5, position: 'absolute', bottom: 0 }}>
<Tooltip
content={t(
- 'The widget is configured to use a non-existing filter value (i.e. category/account/payee). Edit the filters used in this report widget to remove the warning.',
+ 'The widget is configured to use a non-existing filter or tag value. Edit this report to remove the warning.',
)}
placement="bottom start"
style={{ ...styles.tooltip, maxWidth: 300 }}
diff --git a/packages/desktop-client/src/components/reports/reports/GetCardData.tsx b/packages/desktop-client/src/components/reports/reports/GetCardData.tsx
index 9cf2cc3388..a14341d1fc 100644
--- a/packages/desktop-client/src/components/reports/reports/GetCardData.tsx
+++ b/packages/desktop-client/src/components/reports/reports/GetCardData.tsx
@@ -13,6 +13,7 @@ import type {
CategoryGroupEntity,
CustomReportEntity,
PayeeEntity,
+ TagEntity,
} from '@actual-app/core/types/models';
import type { SyncedPrefs } from '@actual-app/core/types/prefs';
@@ -70,6 +71,7 @@ export function GetCardData({
payees,
accounts,
categories,
+ tags,
earliestTransaction,
latestTransaction,
firstDayOfWeekIdx,
@@ -79,6 +81,7 @@ export function GetCardData({
payees: PayeeEntity[];
accounts: AccountEntity[];
categories: { list: CategoryEntity[]; grouped: CategoryGroupEntity[] };
+ tags: TagEntity[];
earliestTransaction: string;
latestTransaction: string;
firstDayOfWeekIdx?: SyncedPrefs['firstDayOfWeekIdx'];
@@ -160,6 +163,8 @@ export function GetCardData({
balanceTypeOp: ReportOptions.balanceTypeMap.get(report.balanceType),
payees,
accounts,
+ tags,
+ tagScope: report.tagScope,
graphType: report.graphType,
firstDayOfWeekIdx,
sortByOp: report.sortBy,
@@ -170,6 +175,7 @@ export function GetCardData({
categories,
payees,
accounts,
+ tags,
startDate,
endDate,
firstDayOfWeekIdx,
diff --git a/packages/desktop-client/src/components/reports/setSessionReport.ts b/packages/desktop-client/src/components/reports/setSessionReport.ts
index c3ae82c82d..500f78cb0b 100644
--- a/packages/desktop-client/src/components/reports/setSessionReport.ts
+++ b/packages/desktop-client/src/components/reports/setSessionReport.ts
@@ -1,18 +1,20 @@
-import type { RuleConditionEntity } from '@actual-app/core/types/models';
+import type { CustomReportEntity } from '@actual-app/core/types/models';
-export const setSessionReport = (
- propName: string,
- propValue: string | boolean | RuleConditionEntity[],
+type SessionReport = Partial<CustomReportEntity> & {
+ savedStatus?: 'saved' | 'modified';
+};
+
+export const setSessionReport = <K extends keyof SessionReport>(
+ propName: K,
+ propValue: SessionReport[K],
) => {
const storedReport =
sessionStorage.report && JSON.parse(sessionStorage.getItem('report') || '');
- const result: Record<string, string | boolean | RuleConditionEntity[]> = {};
- result[propName] = propValue;
sessionStorage.setItem(
'report',
JSON.stringify({
...storedReport,
- ...result,
+ [propName]: propValue,
}),
);
};
diff --git a/upcoming-release-notes/split-custom-reports-by-tags.md b/upcoming-release-notes/split-custom-reports-by-tags.md
new file mode 100644
index 0000000000..eea84ddfc2
--- /dev/null
+++ b/upcoming-release-notes/split-custom-reports-by-tags.md
@@ -0,0 +1,6 @@
+---
+category: Features
+authors: [jfdoming]
+---
+
+Group custom reports by tags, with the option to choose which tags to include.