Skip to content

Commit

Permalink
Merge branch 'master' into jfdoming/fix-send-types-2
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdoming authored Jan 16, 2025
2 parents b4e38d5 + b1627d7 commit 135bd52
Show file tree
Hide file tree
Showing 52 changed files with 402 additions and 273 deletions.
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ contact_links:
- name: Support
url: https://discord.gg/pRYNYr4W5A
about: Need help with something? Having troubles setting up? Or perhaps issues using the API? Reach out to the community on Discord.
- name: Translations
url: https://hosted.weblate.org/projects/actualbudget/actual/
about: Found a string that needs a better translation? Add your suggestion or upvote an existing one in Weblate.
4 changes: 4 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ runs:
repository: actualbudget/translations
path: ${{ inputs.working-directory }}/packages/desktop-client/locale
if: ${{ inputs.download-translations == 'true' }}
- name: Remove untranslated languages
run: packages/desktop-client/bin/remove-untranslated-languages
shell: bash
if: ${{ inputs.download-translations == 'true' }}
9 changes: 8 additions & 1 deletion .github/workflows/i18n-string-extract-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
wlc \
--url https://hosted.weblate.org/api/ \
--key "${{ secrets.WEBLATE_API_KEY_CI_STRINGS }}" \
pull \
push \
actualbudget/actual
- name: Check out updated translations
uses: actions/checkout@v4
Expand Down Expand Up @@ -69,6 +69,13 @@ jobs:
else
echo "No changes to commit"
fi
- name: Update Weblate with latest translations
run: |
wlc \
--url https://hosted.weblate.org/api/ \
--key "${{ secrets.WEBLATE_API_KEY_CI_STRINGS }}" \
pull \
actualbudget/actual
- name: Unlock translations
if: always() # Clean up even on failure
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/update-vrt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ jobs:
with:
name: patch
- name: Apply patch and push
env:
BRANCH_NAME: ${{ steps.comment-branch.outputs.head_ref }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
Expand All @@ -89,7 +91,7 @@ jobs:
exit 0
fi
git commit -m "Update VRT"
git push origin HEAD:${{ steps.comment-branch.outputs.head_ref }}
git push origin HEAD:${BRANCH_NAME}
- name: Add finished reaction
uses: dkershner6/reaction-action@v2
with:
Expand Down
1 change: 1 addition & 0 deletions bin/package-browser
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fi
pushd packages/desktop-client/locale > /dev/null
git pull
popd > /dev/null
packages/desktop-client/bin/remove-untranslated-languages

yarn workspace loot-core build:browser
yarn workspace @actual-app/web build:browser
Expand Down
13 changes: 12 additions & 1 deletion packages/api/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,21 @@ export function addTransactions(
});
}

export function importTransactions(accountId, transactions) {
export interface ImportTransactionsOpts {
defaultCleared?: boolean;
}

export function importTransactions(
accountId,
transactions,
opts: ImportTransactionsOpts = {
defaultCleared: true,
},
) {
return send('api/transactions-import', {
accountId,
transactions,
opts,
});
}

Expand Down
48 changes: 48 additions & 0 deletions packages/desktop-client/bin/remove-untranslated-languages
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');

// Local path to the cloned translations repository
const localRepoPath = './packages/desktop-client/locale';

// Compare JSON files and delete incomplete ones
const processTranslations = () => {
try {
const files = fs.readdirSync(localRepoPath);
const enJsonPath = path.join(localRepoPath, 'en.json');

if (!fs.existsSync(enJsonPath)) {
throw new Error('en.json not found in the repository.');
}

const enJson = JSON.parse(fs.readFileSync(enJsonPath, 'utf8'));
const enKeysCount = Object.keys(enJson).length;

console.log(`en.json has ${enKeysCount} keys.`);

files.forEach((file) => {
if (file === 'en.json' || path.extname(file) !== '.json') return;

const filePath = path.join(localRepoPath, file);
const jsonData = JSON.parse(fs.readFileSync(filePath, 'utf8'));
const fileKeysCount = Object.keys(jsonData).length;

// Calculate the percentage of keys present compared to en.json
const percentage = (fileKeysCount / enKeysCount) * 100;
console.log(`${file} has ${fileKeysCount} keys (${percentage.toFixed(2)}%).`);

if (percentage < 50) {
fs.unlinkSync(filePath);
console.log(`Deleted ${file} due to insufficient keys.`);
} else {
console.log(`Keeping ${file}.`);
}
});

console.log('Processing completed.');
} catch (error) {
console.error(`Error: ${error.message}`);
}
};

processTranslations();
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/desktop-client/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ declare module 'react' {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-empty-object-type
interface CSSProperties extends CSSObject {}
}

declare global {
function __resetWorld(): void;
}
2 changes: 0 additions & 2 deletions packages/desktop-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
"i18next-parser": "^9.0.0",
"i18next-resources-to-backend": "^1.2.1",
"inter-ui": "^3.19.3",
"jest": "^27.5.1",
"jest-watch-typeahead": "^2.2.2",
"lodash": "^4.17.21",
"mdast-util-newline-to-break": "^2.0.0",
"memoize-one": "^6.0.0",
Expand Down
9 changes: 7 additions & 2 deletions packages/desktop-client/src/components/ServerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ export function ServerProvider({ children }: { children: ReactNode }) {

useEffect(() => {
async function run() {
setServerURL(await send('get-server-url'));
const serverURL = await send('get-server-url');
if (!serverURL) {
return;
}
setServerURL(serverURL);
setVersion(await getServerVersion());
}
run();
Expand Down Expand Up @@ -135,7 +139,8 @@ export function ServerProvider({ children }: { children: ReactNode }) {
async (url: string, opts: { validate?: boolean } = {}) => {
const { error } = await send('set-server-url', { ...opts, url });
if (!error) {
setServerURL(await send('get-server-url'));
const serverURL = await send('get-server-url');
setServerURL(serverURL!);
setVersion(await getServerVersion());
}
return { error };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ function UserAccessContent({
}, [cloudFileId, setLoading, t]);

const loadOwner = useCallback(async () => {
const file: Awaited<ReturnType<Handlers['get-user-file-info']>> =
(await send('get-user-file-info', cloudFileId as string)) ?? {};
const file = (await send('get-user-file-info', cloudFileId as string)) ?? {
usersWithAccess: [],
};
const owner = file?.usersWithAccess.filter(user => user.owner);

if (owner.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,24 @@ function UserDirectoryContent({
setLoading(true);

const loadedUsers = (await send('users-get')) ?? [];
if ('error' in loadedUsers) {
dispatch(
addNotification({
type: 'error',
id: 'error',
title: t('Error getting users'),
sticky: true,
message: getUserDirectoryErrors(loadedUsers.error),
}),
);
setLoading(false);
return;
}

setAllUsers(loadedUsers);
setLoading(false);
return loadedUsers;
}, [setLoading]);
}, [dispatch, getUserDirectoryErrors, setLoading, t]);

useEffect(() => {
async function loadData() {
Expand All @@ -141,9 +154,11 @@ function UserDirectoryContent({

const onDeleteSelected = useCallback(async () => {
setLoading(true);
const { error } = await send('user-delete-all', [...selectedInst.items]);
const res = await send('user-delete-all', [...selectedInst.items]);

if (error) {
const error = res['error'];
const someDeletionsFailed = res['someDeletionsFailed'];
if (error || someDeletionsFailed) {
if (error === 'token-expired') {
dispatch(
addNotification({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function SavedFilterMenuButton({
const [adding, setAdding] = useState(false);
const [menuOpen, setMenuOpen] = useState(false);
const triggerRef = useRef(null);
const [err, setErr] = useState(null);
const [err, setErr] = useState<string | null>(null);
const [menuItem, setMenuItem] = useState('');
const [name, setName] = useState(filterId?.name ?? '');
const id = filterId?.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function CreateAccountModal({ upgradingAccountId }: CreateAccountProps) {
balance: number;
};

for (const oldAccount of results.accounts) {
for (const oldAccount of results.accounts ?? []) {
const newAccount: NormalizedAccount = {
account_id: oldAccount.id,
name: oldAccount.name,
Expand Down
6 changes: 4 additions & 2 deletions packages/desktop-client/src/components/modals/EditUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ function useSaveUser() {
user: User,
setError: (error: string) => void,
): Promise<boolean> {
const { error, id: newId } = (await send(method, user)) || {};
if (!error) {
const res = (await send(method, user)) || {};
if (!res['error']) {
const newId = res['id'];
if (newId) {
user.id = newId;
}
} else {
const error = res['error'];
setError(getUserDirectoryErrors(error));
if (error === 'token-expired') {
dispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export function ManagePayeesWithData({
}, []);

const refetchRuleCounts = useCallback(async () => {
let counts = await send('payees-get-rule-counts');
counts = new Map(Object.entries(counts));
setRuleCounts({ value: counts });
const counts = await send('payees-get-rule-counts');
const countsMap = new Map(Object.entries(counts));
setRuleCounts({ value: countsMap });
}, []);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function calendarSpreadsheet(
}[];
}) => void,
) => {
let filters;
let filters: unknown[];

try {
const { filters: filtersLocal } = await send(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,18 @@ export function createCustomSpreadsheet({
filterEmptyRows({ showEmpty, data: i, balanceTypeOp }),
);

const sortedCalcDataFiltered = [...calcDataFiltered].sort(
sortData({ balanceTypeOp, sortByOp }),
);

const legend = calculateLegend(
intervalData,
calcDataFiltered,
sortedCalcDataFiltered,
groupBy,
graphType,
balanceTypeOp,
);

const sortedCalcDataFiltered = [...calcDataFiltered].sort(
sortData({ balanceTypeOp, sortByOp }),
);

setData({
data: sortedCalcDataFiltered,
intervalData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function createSpendingSpreadsheet({
$and: [{ month: { $eq: budgetMonth } }],
})
.filter({
[conditionsOpKey]: filters.filter(filter => filter.category),
[conditionsOpKey]: filters.filter(filter => filter['category']),
})
.groupBy([{ $id: '$category' }])
.select([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function summarySpreadsheet(
toRange: string;
}) => void,
) => {
let filters = [];
let filters: unknown[] = [];
try {
const response = await send('make-filters-from-conditions', {
conditions: conditions.filter(cond => !cond.customName),
Expand Down
Loading

0 comments on commit 135bd52

Please sign in to comment.