From b5cbaa52b236c358c4492528a8e4b3752b79bb8c Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Tue, 18 Mar 2025 06:43:01 -0700 Subject: [PATCH] Simplify Modals component by destructuring modal.options instead of passing options one by one (#4647) * Simplify Modals component * Release notes --- .../desktop-client/src/components/Modals.tsx | 385 +++--------------- upcoming-release-notes/4647.md | 6 + 2 files changed, 58 insertions(+), 333 deletions(-) create mode 100644 upcoming-release-notes/4647.md diff --git a/packages/desktop-client/src/components/Modals.tsx b/packages/desktop-client/src/components/Modals.tsx index cb32f3e7c2..da7236595b 100644 --- a/packages/desktop-client/src/components/Modals.tsx +++ b/packages/desktop-client/src/components/Modals.tsx @@ -106,72 +106,29 @@ export function Modals() { return ; case 'add-account': - return ( - - ); + return ; case 'add-local-account': return ; case 'close-account': - return ( - - ); + return ; case 'select-linked-accounts': - return ( - - ); + return ; case 'confirm-category-delete': - return ( - - ); + return ; case 'confirm-unlink-account': - return ( - - ); + return ; case 'confirm-transaction-edit': - return ( - - ); + return ; case 'confirm-transaction-delete': return ( - + ); case 'load-backup': @@ -179,150 +136,67 @@ export function Modals() { ); case 'manage-rules': - return ( - - ); + return ; case 'edit-rule': - return ( - - ); + return ; case 'merge-unused-payees': - return ( - - ); + return ; case 'gocardless-init': - return ( - - ); + return ; case 'simplefin-init': - return ( - - ); + return ; case 'pluggyai-init': - return ( - - ); + return ; case 'gocardless-external-msg': return ( { modal.options.onClose?.(); send('gocardless-poll-web-token-stop'); }} - onSuccess={modal.options.onSuccess} /> ); case 'create-encryption-key': - return ( - - ); + return ; case 'fix-encryption-key': - return ( - - ); + return ; case 'edit-field': - return ( - - ); + return ; case 'category-autocomplete': - return ( - - ); + return ; case 'account-autocomplete': - return ( - - ); + return ; case 'payee-autocomplete': - return ( - - ); + return ; case 'payee-category-learning': return ; case 'new-category': - return ( - - ); + return ; case 'new-category-group': - return ( - - ); + return ; case 'envelope-budget-summary': return ( @@ -330,41 +204,18 @@ export function Modals() { key={name} value={monthUtils.sheetForMonth(modal.options.month)} > - + ); case 'tracking-budget-summary': - return ( - - ); + return ; case 'schedule-edit': - return ( - - ); + return ; case 'schedule-link': - return ( - - ); + return ; case 'schedules-discover': return ; @@ -376,33 +227,13 @@ export function Modals() { return ; case 'synced-account-edit': - return ; + return ; case 'account-menu': - return ( - - ); + return ; case 'category-menu': - return ( - - ); + return ; case 'envelope-budget-menu': return ( @@ -410,13 +241,7 @@ export function Modals() { key={name} value={monthUtils.sheetForMonth(modal.options.month)} > - + ); @@ -426,39 +251,15 @@ export function Modals() { key={name} value={monthUtils.sheetForMonth(modal.options.month)} > - + ); case 'category-group-menu': - return ( - - ); + return ; case 'notes': - return ( - - ); + return ; case 'envelope-balance-menu': return ( @@ -466,12 +267,7 @@ export function Modals() { key={name} value={monthUtils.sheetForMonth(modal.options.month)} > - + ); @@ -481,12 +277,7 @@ export function Modals() { key={name} value={monthUtils.sheetForMonth(modal.options.month)} > - + ); @@ -496,10 +287,7 @@ export function Modals() { key={name} value={monthUtils.sheetForMonth(modal.options.month)} > - + ); @@ -509,58 +297,23 @@ export function Modals() { key={name} value={monthUtils.sheetForMonth(modal.options.month)} > - + ); case 'transfer': - return ( - - ); + return ; case 'cover': - return ( - - ); + return ; case 'scheduled-transaction-menu': return ( - + ); case 'budget-page-menu': - return ( - - ); + return ; case 'envelope-budget-month-menu': return ( @@ -568,11 +321,7 @@ export function Modals() { key={name} value={monthUtils.sheetForMonth(modal.options.month)} > - + ); @@ -582,39 +331,23 @@ export function Modals() { key={name} value={monthUtils.sheetForMonth(modal.options.month)} > - + ); case 'budget-list': return ; case 'delete-budget': - return ; + return ; case 'duplicate-budget': - return ( - - ); + return ; case 'import': return ; case 'files-settings': return ; case 'confirm-change-document-dir': return ( - + ); case 'import-ynab4': return ; @@ -627,33 +360,19 @@ export function Modals() { return ; case 'edit-access': - return ( - - ); + return ; case 'edit-user': - return ( - - ); + return ; case 'transfer-ownership': - return ; + return ; case 'enable-openid': - return ; + return ; case 'enable-password-auth': - return ( - - ); + return ; default: throw new Error('Unknown modal'); diff --git a/upcoming-release-notes/4647.md b/upcoming-release-notes/4647.md new file mode 100644 index 0000000000..709f224a46 --- /dev/null +++ b/upcoming-release-notes/4647.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [joel-jeremy] +--- + +Simplify Modals component by destructuring modal.options instead of one by one. This would remove the need to modify Modals component to pass in new option whenever a new one is added.