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

Duplicate Budget #3847

Merged
merged 28 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ee12c8d
Initial Commit
tlesicka Nov 17, 2024
02cc76c
Create 3847.md
tlesicka Nov 17, 2024
89a9907
Removed un-needed comment
tlesicka Nov 17, 2024
882c14d
Changed error log text
tlesicka Nov 17, 2024
dbbc51a
Merge remote-tracking branch 'upstream/master' into duplicate-budget
tlesicka Nov 19, 2024
d5bba7a
Moved budget name validation from DuplicateFileModal to loot-core/server
tlesicka Nov 19, 2024
bca4252
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Nov 19, 2024
5238be9
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Nov 20, 2024
518c762
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Nov 21, 2024
5aed264
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Nov 22, 2024
a486c1e
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Nov 22, 2024
73066ce
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Nov 23, 2024
abe3bf4
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Nov 25, 2024
ba5d2d0
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Dec 2, 2024
1ecb9d2
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Dec 3, 2024
425286c
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Dec 6, 2024
02b65c1
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Dec 6, 2024
a875704
Added translation
tlesicka Dec 7, 2024
0fb0bf7
Fixed linting error
tlesicka Dec 7, 2024
49697a0
Changed delete file hack
tlesicka Dec 7, 2024
925b7f6
Merge remote-tracking branch 'upstream/master' into duplicate-budget
tlesicka Dec 7, 2024
968a437
Removed hard coded english from loot-core server
tlesicka Dec 8, 2024
0b34b2c
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Dec 8, 2024
b941908
Updated wording and style of Duplicate File Modal
tlesicka Dec 8, 2024
a39aa29
Simpler wording for Duplication text and buttons
tlesicka Dec 9, 2024
5117026
Merge remote-tracking branch 'upstream/master' into duplicate-budget
tlesicka Dec 9, 2024
890486a
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Dec 9, 2024
d9c0e48
Merge branch 'actualbudget:master' into duplicate-budget
tlesicka Dec 9, 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
11 changes: 11 additions & 0 deletions packages/desktop-client/src/components/Modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { KeyboardShortcutModal } from './modals/KeyboardShortcutModal';
import { LoadBackupModal } from './modals/LoadBackupModal';
import { ConfirmChangeDocumentDirModal } from './modals/manager/ConfirmChangeDocumentDir';
import { DeleteFileModal } from './modals/manager/DeleteFileModal';
import { DuplicateFileModal } from './modals/manager/DuplicateFileModal';
import { FilesSettingsModal } from './modals/manager/FilesSettingsModal';
import { ImportActualModal } from './modals/manager/ImportActualModal';
import { ImportModal } from './modals/manager/ImportModal';
Expand Down Expand Up @@ -586,6 +587,16 @@ export function Modals() {
return <BudgetListModal key={name} />;
case 'delete-budget':
return <DeleteFileModal key={name} file={options.file} />;
case 'duplicate-budget':
return (
<DuplicateFileModal
key={name}
file={options.file}
managePage={options?.managePage}
loadBudget={options?.loadBudget}
onComplete={options?.onComplete}
/>
);
case 'import':
return <ImportModal key={name} />;
case 'files-settings':
Expand Down
45 changes: 40 additions & 5 deletions packages/desktop-client/src/components/manager/BudgetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ function getFileDescription(file: File, t: (key: string) => string) {
function FileMenu({
onDelete,
onClose,
onDuplicate,
}: {
onDelete: () => void;
onClose: () => void;
onDuplicate?: () => void;
}) {
function onMenuSelect(type: string) {
onClose();
Expand All @@ -75,18 +77,30 @@ function FileMenu({
case 'delete':
onDelete();
break;
case 'duplicate':
if (onDuplicate) onDuplicate();
break;
default:
}
}

const { t } = useTranslation();

const items = [{ name: 'delete', text: t('Delete') }];
const items = [
...(onDuplicate ? [{ name: 'duplicate', text: t('Duplicate') }] : []),
{ name: 'delete', text: t('Delete') },
];

return <Menu onMenuSelect={onMenuSelect} items={items} />;
}

function FileMenuButton({ onDelete }: { onDelete: () => void }) {
function FileMenuButton({
onDelete,
onDuplicate,
}: {
onDelete: () => void;
onDuplicate?: () => void;
}) {
const triggerRef = useRef(null);
const [menuOpen, setMenuOpen] = useState(false);

Expand All @@ -108,7 +122,11 @@ function FileMenuButton({ onDelete }: { onDelete: () => void }) {
isOpen={menuOpen}
onOpenChange={() => setMenuOpen(false)}
>
<FileMenu onDelete={onDelete} onClose={() => setMenuOpen(false)} />
<FileMenu
onDelete={onDelete}
onClose={() => setMenuOpen(false)}
onDuplicate={onDuplicate}
/>
</Popover>
</View>
);
Expand Down Expand Up @@ -169,11 +187,13 @@ function FileItem({
quickSwitchMode,
onSelect,
onDelete,
onDuplicate,
}: {
file: File;
quickSwitchMode: boolean;
onSelect: (file: File) => void;
onDelete: (file: File) => void;
onDuplicate: (file: File) => void;
}) {
const { t } = useTranslation();

Expand Down Expand Up @@ -239,7 +259,10 @@ function FileItem({
)}

{!quickSwitchMode && (
<FileMenuButton onDelete={() => onDelete(file)} />
<FileMenuButton
onDelete={() => onDelete(file)}
onDuplicate={'id' in file ? () => onDuplicate(file) : undefined}
tlesicka marked this conversation as resolved.
Show resolved Hide resolved
/>
)}
</View>
</View>
Expand All @@ -252,11 +275,13 @@ function BudgetFiles({
quickSwitchMode,
onSelect,
onDelete,
onDuplicate,
}: {
files: File[];
quickSwitchMode: boolean;
onSelect: (file: File) => void;
onDelete: (file: File) => void;
onDuplicate: (file: File) => void;
}) {
function isLocalFile(file: File): file is LocalFile {
return file.state === 'local';
Expand Down Expand Up @@ -292,6 +317,7 @@ function BudgetFiles({
quickSwitchMode={quickSwitchMode}
onSelect={onSelect}
onDelete={onDelete}
onDuplicate={onDuplicate}
/>
))
)}
Expand Down Expand Up @@ -467,7 +493,16 @@ export function BudgetList({ showHeader = true, quickSwitchMode = false }) {
files={files}
quickSwitchMode={quickSwitchMode}
onSelect={onSelect}
onDelete={file => dispatch(pushModal('delete-budget', { file }))}
onDelete={(file: File) =>
dispatch(pushModal('delete-budget', { file }))
}
onDuplicate={(file: File) => {
if (file && 'id' in file) {
dispatch(pushModal('duplicate-budget', { file, managePage: true }));
} else {
console.error('Attempted to duplicate an invalid file:', file);
tlesicka marked this conversation as resolved.
Show resolved Hide resolved
tlesicka marked this conversation as resolved.
Show resolved Hide resolved
}
}}
tlesicka marked this conversation as resolved.
Show resolved Hide resolved
/>
{!quickSwitchMode && (
<View
Expand Down
Loading