Skip to content

Commit

Permalink
Merge branch 'master' into twk3/api-tests-payees-trans
Browse files Browse the repository at this point in the history
  • Loading branch information
twk3 authored Jan 9, 2024
2 parents 485ee20 + f6dd0ec commit 46ab012
Show file tree
Hide file tree
Showing 37 changed files with 512 additions and 544 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ yarn.lock text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.jpg binary
35 changes: 0 additions & 35 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,3 @@ jobs:
name: desktop-client-test-results
path: packages/desktop-client/test-results/
retention-days: 30
- uses: actions-ecosystem/action-add-labels@v1
if: failure()
with:
labels: ':red_circle: VRT failing'
- uses: actions-ecosystem/action-remove-labels@v1
if: success()
with:
labels: ':red_circle: VRT failing'
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: VRT
- name: Create comment if failed
if: failure()
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
:wave: Looks like VRT (visual regression tests) are failing in this PR. This indicates a problem in the app. It could be either a bug in this PR or a visual change introduced by changing something.
To fix this: please follow [these instructions](https://github.com/actualbudget/actual/blob/master/packages/desktop-client/README.md#visual-regression) and review the output of the failing CI job to see the generated screenshots.
We look forward to reviewing this PR once all the CI jobs have passed successfully!
edit-mode: replace
- name: Update comment when CI job passes
if: success() && steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: The VRT tests have passed! Thank you!
edit-mode: replace
7 changes: 4 additions & 3 deletions packages/desktop-client/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "",
"short_name": "",
"name": "Actual",
"short_name": "Actual",
"icons": [
{
"src": "/android-chrome-192x192.png",
Expand All @@ -15,5 +15,6 @@
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
"display": "standalone",
"start_url": "."
}
1 change: 1 addition & 0 deletions packages/desktop-client/src/browser-preload.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ global.Actual = {
applyAppUpdate: () => {},
updateAppMenu: isBudgetOpen => {},

ipcConnect: () => {},
getServerSocket: async () => {
return worker;
},
Expand Down
39 changes: 28 additions & 11 deletions packages/desktop-client/src/components/ManageRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,6 @@ function ManageRulesContent({
setHoveredRule(id);
}, []);

if (allRules.length === 0) {
return null;
}

return (
<SelectedProvider instance={selectedInst}>
<View>
Expand Down Expand Up @@ -288,13 +284,17 @@ function ManageRulesContent({
// Hide the last border of the item in the table
style={{ marginBottom: -1 }}
>
<RulesList
rules={filteredRules}
selectedItems={selectedInst.items}
hoveredRule={hoveredRule}
onHover={onHover}
onEditRule={onEditRule}
/>
{filteredRules.length === 0 ? (
<EmptyMessage text="No rules" style={{ marginTop: 15 }} />
) : (
<RulesList
rules={filteredRules}
selectedItems={selectedInst.items}
hoveredRule={hoveredRule}
onHover={onHover}
onEditRule={onEditRule}
/>
)}
</SimpleTable>
</View>
<View
Expand All @@ -321,6 +321,23 @@ function ManageRulesContent({
);
}

function EmptyMessage({ text, style }) {
return (
<View
style={{
textAlign: 'center',
color: theme.pageTextSubdued,
fontStyle: 'italic',
fontSize: 13,
marginTop: 5,
style,
}}
>
{text}
</View>
);
}

type ManageRulesProps = {
isModal: boolean;
payeeId: string | null;
Expand Down
2 changes: 2 additions & 0 deletions packages/desktop-client/src/components/accounts/Account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ class AccountInternal extends PureComponent {
onImport = async () => {
const accountId = this.props.accountId;
const account = this.props.accounts.find(acct => acct.id === accountId);
const categories = await this.props.getCategories();

if (account) {
const res = await window.Actual.openFileDialog({
Expand All @@ -477,6 +478,7 @@ class AccountInternal extends PureComponent {
if (res) {
this.props.pushModal('import-transactions', {
accountId,
categories,
filename: res[0],
onImported: didChange => {
if (didChange) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ export const CategoryMonth = memo(function CategoryMonth({
<View
style={{
flexShrink: 0,
marginRight: 0,
marginLeft: 3,
paddingLeft: 3,
justifyContent: 'center',
borderTopWidth: 1,
borderBottomWidth: 1,
borderColor: theme.tableBorder,
}}
>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function ExpenseProgress({ current, target }: ExpenseProgressProps) {
<PieProgress
progress={frac}
color={over ? theme.errorText : theme.noticeTextLight}
backgroundColor={over ? theme.errorBackground : theme.pageBackground}
backgroundColor={over ? theme.errorBackground : theme.tableBackground}
style={{ width: 20, height: 20 }}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function IncomeProgress({ current, target }: IncomeProgressProps) {
<PieProgress
progress={frac}
color={over ? theme.errorText : theme.noticeTextLight}
backgroundColor={over ? theme.errorBackground : theme.pageBackground}
backgroundColor={over ? theme.errorBackground : theme.tableBackground}
style={{ width: 20, height: 20 }}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,24 @@ function getInitialMappings(transactions) {
fields.find(([name, value]) => value.match(/^-?[.,\d]+$/)),
);

const categoryField = key(
fields.find(([name, value]) => name.toLowerCase().includes('category')),
);

const payeeField = key(
fields.find(([name, value]) => name !== dateField && name !== amountField),
fields.find(
([name, value]) =>
name !== dateField && name !== amountField && name !== categoryField,
),
);

const notesField = key(
fields.find(
([name, value]) =>
name !== dateField && name !== amountField && name !== payeeField,
name !== dateField &&
name !== amountField &&
name !== categoryField &&
name !== payeeField,
),
);

Expand All @@ -221,6 +231,7 @@ function getInitialMappings(transactions) {
payee: payeeField,
notes: notesField,
inOut: inOutField,
category: categoryField,
};
}

Expand Down Expand Up @@ -290,6 +301,19 @@ function parseAmountFields(
};
}

function parseCategoryFields(trans, categories) {
let match = null;
categories.forEach(category => {
if (category.id === trans.category) {
return null;
}
if (category.name === trans.category) {
match = category.id;
}
});
return match;
}

function Transaction({
transaction: rawTransaction,
fieldMappings,
Expand All @@ -301,7 +325,9 @@ function Transaction({
outValue,
flipAmount,
multiplierAmount,
categories,
}) {
const categoryList = categories.map(category => category.name);
const transaction = useMemo(
() =>
fieldMappings
Expand Down Expand Up @@ -348,6 +374,14 @@ function Transaction({
<Field width="flex" title={transaction.notes}>
{transaction.notes}
</Field>
<Field
width="flex"
title={
categoryList.includes(transaction.category) && transaction.category
}
>
{categoryList.includes(transaction.category) && transaction.category}
</Field>
{splitMode ? (
<>
<Field
Expand Down Expand Up @@ -602,6 +636,17 @@ function FieldMappings({
firstTransaction={transactions[0]}
/>
</View>
<View style={{ flex: 1 }}>
<SubLabel title="Category" />
<SelectField
options={options}
value={mappings.category}
style={{ marginRight: 5 }}
onChange={name => onChange('category', name)}
hasHeaderRow={hasHeaderRow}
firstTransaction={transactions[0]}
/>
</View>
{splitMode ? (
<>
<View style={{ flex: 0.5 }}>
Expand Down Expand Up @@ -676,7 +721,7 @@ export function ImportTransactions({ modalProps, options }) {
const [outValue, setOutValue] = useState('');
const [flipAmount, setFlipAmount] = useState(false);
const [multiplierEnabled, setMultiplierEnabled] = useState(false);
const { accountId, onImported } = options;
const { accountId, categories, onImported } = options;

// This cannot be set after parsing the file, because changing it
// requires re-parsing the file. This is different from the other
Expand Down Expand Up @@ -866,6 +911,11 @@ export function ImportTransactions({ modalProps, options }) {
break;
}

const category_id = parseCategoryFields(trans, categories.list);
if (category_id != null) {
trans.category = category_id;
}

const { inflow, outflow, inOut, ...finalTransaction } = trans;
finalTransactions.push({
...finalTransaction,
Expand Down Expand Up @@ -919,6 +969,7 @@ export function ImportTransactions({ modalProps, options }) {
{ name: 'Date', width: 200 },
{ name: 'Payee', width: 'flex' },
{ name: 'Notes', width: 'flex' },
{ name: 'Category', width: 'flex' },
];

if (inOutMode) {
Expand Down Expand Up @@ -959,7 +1010,7 @@ export function ImportTransactions({ modalProps, options }) {

<TableWithNavigator
items={transactions}
fields={['payee', 'amount']}
fields={['payee', 'category', 'amount']}
style={{ backgroundColor: theme.tableHeaderBackground }}
getItemKey={index => index}
renderEmpty={() => {
Expand Down Expand Up @@ -989,6 +1040,7 @@ export function ImportTransactions({ modalProps, options }) {
outValue={outValue}
flipAmount={flipAmount}
multiplierAmount={multiplierAmount}
categories={categories.list}
/>
</View>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { BarLineGraph } from './graphs/BarLineGraph';
import { DonutGraph } from './graphs/DonutGraph';
import { LineGraph } from './graphs/LineGraph';
import { StackedBarGraph } from './graphs/StackedBarGraph';
import { ReportTable } from './graphs/tableGraph/ReportTable';
import { ReportTableHeader } from './graphs/tableGraph/ReportTableHeader';
import { ReportTableList } from './graphs/tableGraph/ReportTableList';
import { ReportTableTotals } from './graphs/tableGraph/ReportTableTotals';
import { ReportOptions } from './ReportOptions';
import { ReportTable } from './ReportTable';
import { ReportTableHeader } from './ReportTableHeader';
import { ReportTableList } from './ReportTableList';
import { ReportTableTotals } from './ReportTableTotals';

type ChooseGraphProps = {
data: DataEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import React, {
} from 'react';
import { type RefProp } from 'react-spring';

import { type CSSProperties } from '../../style';
import { View } from '../common/View';
import { type CSSProperties } from '../../../../style';
import { View } from '../../../common/View';

type ReportTableProps = {
saveScrollWidth?: (value: number) => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { type UIEventHandler } from 'react';
import { type RefProp } from 'react-spring';

import { styles, theme } from '../../style';
import { View } from '../common/View';
import { Row, Cell } from '../table';

import { type MonthData } from './entities';
import { styles, theme } from '../../../../style';
import { View } from '../../../common/View';
import { Row, Cell } from '../../../table';
import { type MonthData } from '../../entities';

type ReportTableHeaderProps = {
scrollWidth?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
integerToCurrency,
} from 'loot-core/src/shared/util';

import { type CSSProperties, styles, theme } from '../../style';
import { View } from '../common/View';
import { Row, Cell } from '../table';
import { type CSSProperties, styles, theme } from '../../../../style';
import { View } from '../../../common/View';
import { Row, Cell } from '../../../table';

type TableRowProps = {
item: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import {
integerToCurrency,
} from 'loot-core/src/shared/util';

import { styles, theme } from '../../style';
import { View } from '../common/View';
import { Row, Cell } from '../table';

import { type DataEntity } from './entities';
import { styles, theme } from '../../../../style';
import { View } from '../../../common/View';
import { Row, Cell } from '../../../table';
import { type DataEntity } from '../../entities';

type ReportTableTotalsProps = {
data: DataEntity;
Expand Down
Loading

0 comments on commit 46ab012

Please sign in to comment.