Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicating Budget and Budget Snapshots #3689

Closed
Closed
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
7127d46
Initial Commit
tlesicka Oct 19, 2024
74004f5
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 19, 2024
62f5175
Fixed database copy error
tlesicka Oct 19, 2024
597b0fa
Removing unused code
tlesicka Oct 19, 2024
f90fc5d
Create 3689.md
tlesicka Oct 19, 2024
b4f2aae
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 20, 2024
e96e646
Fixed issue with database duplication
tlesicka Oct 20, 2024
133a7ed
fixed lint and typecheck errors
tlesicka Oct 20, 2024
d0dcb28
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 21, 2024
eb8f270
Fixed small errors
tlesicka Oct 21, 2024
e423ff9
Ported backups from electron to web-app
tlesicka Oct 22, 2024
3b7ceb8
Fixed lint issues
tlesicka Oct 22, 2024
d56f647
Fixed backups not being deleted
tlesicka Oct 22, 2024
f74a910
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 22, 2024
88293b0
Fixed a few errors reported by coderabbitai
tlesicka Oct 22, 2024
6f1e542
fixed typo
tlesicka Oct 22, 2024
63d2ea6
Fixed issues from coderabbitai
tlesicka Oct 22, 2024
e287c41
Applying coderabbitai recommendations
tlesicka Oct 22, 2024
9816e25
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 22, 2024
bc0881e
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 23, 2024
0932913
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 23, 2024
007c8f0
Fixed issues that required new budget to open
tlesicka Oct 23, 2024
62fb59b
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 23, 2024
83bd491
Added loading spinners to Backup modal
tlesicka Oct 23, 2024
f275142
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Oct 23, 2024
6ce0032
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 23, 2024
3a70c01
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Oct 24, 2024
7e8a4ca
Merge branch 'snapshot-and-duplicate-budget' of https://github.com/tl…
tlesicka Oct 24, 2024
8e81f44
Updated as recommended by coderabbitai
tlesicka Oct 24, 2024
dbf13b6
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Oct 24, 2024
459ed61
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Oct 24, 2024
6d9a2f7
Added onComplete to DuplicateFileModal
tlesicka Oct 25, 2024
c967053
Merge branch 'snapshot-and-duplicate-budget' of https://github.com/tl…
tlesicka Oct 25, 2024
b99d314
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 25, 2024
0b226b8
Fixed issues recommended by coderabbitai
tlesicka Oct 25, 2024
86faf0b
Added user notification to LoadBackupModal and DuplicateFileModal
tlesicka Oct 25, 2024
ef9eb70
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 25, 2024
c717805
Added definition file for backups.{platform}.ts, Added better typing
tlesicka Oct 26, 2024
66760ad
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 26, 2024
49306d3
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Oct 27, 2024
f70a44a
Removed unused/commented code; applied coderabbitai recommendations
tlesicka Oct 27, 2024
4168aac
Fixed typechecking and removed ts-strict-ignore from server/backup.*.ts
tlesicka Oct 27, 2024
d568640
Updated as recommended by coderabbitai
tlesicka Oct 27, 2024
b5ab478
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Oct 27, 2024
9b4d6ab
Fixed issue with backups not showing up in web-app
tlesicka Oct 27, 2024
62274b1
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Oct 28, 2024
d52e8cf
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Oct 29, 2024
22e26a0
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Oct 31, 2024
63b468f
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Nov 4, 2024
65ed930
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Nov 5, 2024
aea26fa
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Nov 6, 2024
ae16f6a
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Nov 6, 2024
e375dbc
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Nov 7, 2024
ff57ec3
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Nov 7, 2024
437ca4e
Updating menu from merge
tlesicka Nov 7, 2024
c5db05b
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Nov 7, 2024
30bc01c
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Nov 12, 2024
5ef098b
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Nov 15, 2024
b023dab
Fixed errors from merging upstream/master
tlesicka Nov 15, 2024
b042059
Merge remote-tracking branch 'upstream/master' into snapshot-and-dupl…
tlesicka Nov 16, 2024
5b1c80a
Removed <Trans> tags
tlesicka Nov 16, 2024
61f4e22
Merge branch 'actualbudget:master' into snapshot-and-duplicate-budget
tlesicka Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed issues from coderabbitai
tlesicka committed Oct 22, 2024
commit 63d2ea68dc6e1bc613140efa61a5fa781ab686d0
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ export function DuplicateFileModal({ file, managePage }: DuplicateFileProps) {
);

const validateNewName = (name: string): string | null => {
if (name === '') return 'Name can not be blank';
if (name === '') return t('Name cannot be blank');
return null;
};

@@ -72,7 +72,11 @@ export function DuplicateFileModal({ file, managePage }: DuplicateFileProps) {
lineHeight: '1.5em',
}}
>
<InlineField label="New Budget Name" width="100%" labelWidth={150}>
<InlineField
label={t('New Budget Name')}
width="100%"
labelWidth={150}
>
<InitialFocus>
<Input
name="name"
@@ -129,6 +133,8 @@ export function DuplicateFileModal({ file, managePage }: DuplicateFileProps) {
);
setLoadingState(null);
setLoading(false);
} else {
setNameError(nameError);
}
}}
>
@@ -150,14 +156,16 @@ export function DuplicateFileModal({ file, managePage }: DuplicateFileProps) {
) : (
<Text>
<Trans>
This is a <strong>local budget</strong> which is not stored
on a server. Only a local copy will be duplicated.
This is a <strong>local budget</strong> which is not
stored on a server. Only a local copy will be duplicated.
</Trans>
</Text>
)}

<ModalButtons>
<Button onPress={close}>Cancel</Button>
<Button onPress={close}>
<Trans>Cancel</Trans>
</Button>
<ButtonWithLoading
variant={
loading ? 'bare' : isCloudFile ? 'normal' : 'primary'
4 changes: 3 additions & 1 deletion packages/desktop-client/src/components/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -200,7 +200,9 @@ function EditableBudgetName() {
setEditing(true);
break;
case 'backups':
dispatch(replaceModal('load-backup', { budgetId }));
if (budgetId) {
dispatch(replaceModal('load-backup', { budgetId }));
}
break;
case 'duplicate':
if (budgetFile) {
4 changes: 2 additions & 2 deletions packages/loot-core/src/client/state-types/modals.d.ts
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ type FinanceModals = {
* The ID of the budget to load a backup for.
* If undefined, it may indicate loading a backup for the current budget or a user-selected budget.
*/
budgetId: string | undefined,
budgetId: string | undefined;
};

'manage-rules': { payeeId?: string };
@@ -87,7 +87,7 @@ type FinanceModals = {
'duplicate-budget': {
/** The budget file to be duplicated */
file: File;
/**
/**
* Indicates whether the duplication is initiated from the budget
* management page. This may affect the behavior or UI of the
* duplication process.
14 changes: 10 additions & 4 deletions packages/loot-core/src/platform/server/fs/index.web.ts
Original file line number Diff line number Diff line change
@@ -315,12 +315,18 @@ export const copyFile = async function (
try {
const contents = await _readFile(frompath);
result = await _writeFile(topath, contents);
} catch (e) {
try {
if (frompath.endsWith('.sqlite') || topath.endsWith('.sqlite')) {
} catch (error) {
if (frompath.endsWith('.sqlite') || topath.endsWith('.sqlite')) {
try {
result = await _copySqlFile(frompath, topath);
} catch (secondError) {
throw new Error(
`Failed to copy SQL file from ${frompath} to ${topath}: ${secondError.message}`,
);
}
} catch (ee) {}
} else {
throw error;
}
}
return result;
};
2 changes: 1 addition & 1 deletion packages/loot-core/src/server/backups.ts
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ export async function makeBackup(id: string) {
export async function removeAllBackups(id: string): Promise<boolean> {
const budgetDir = fs.getBudgetDir(id);
const backupsDir = fs.join(budgetDir, 'backups');

if (!(await fs.exists(backupsDir))) {
return true; // No backups to remove
}
8 changes: 6 additions & 2 deletions packages/loot-core/src/server/backups.web.ts
Original file line number Diff line number Diff line change
@@ -200,7 +200,9 @@ export async function loadBackup(id: string, backupId: string) {
// Re-upload the new file
try {
await cloudStorage.upload();
} catch (e) {}
} catch (error) {
console.error('Error uploading to cloud storage:', error);
}
prefs.unloadPrefs();
} else {
console.log('Loading backup', backupId);
@@ -219,7 +221,9 @@ export async function loadBackup(id: string, backupId: string) {
// Re-upload the new file
try {
await cloudStorage.upload();
} catch (e) {}
} catch (error) {
console.error('Error uploading to cloud storage:', error);
}

prefs.unloadPrefs();

3 changes: 1 addition & 2 deletions packages/loot-core/src/server/util/budget-name.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// @ts-strict-ignore
import { v4 as uuidv4 } from 'uuid';

import { type Budget } from 'loot-core/types/budget';

import * as fs from '../../platform/server/fs';
import { type Budget } from '../../types/budget';

export async function uniqueFileName(
existingFiles: Budget[],