forked from actualbudget/actual
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Maintenance] Split up large payee management components file (actual…
- Loading branch information
Showing
6 changed files
with
277 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/desktop-client/src/components/payees/PayeeMenu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import Delete from '../../icons/v0/Delete'; | ||
import Merge from '../../icons/v0/Merge'; | ||
import { theme } from '../../style'; | ||
import Menu from '../common/Menu'; | ||
import View from '../common/View'; | ||
import { Tooltip } from '../tooltips'; | ||
|
||
export default function PayeeMenu({ | ||
payeesById, | ||
selectedPayees, | ||
onDelete, | ||
onMerge, | ||
onClose, | ||
}) { | ||
// Transfer accounts are never editable | ||
let isDisabled = [...selectedPayees].some( | ||
id => payeesById[id] == null || payeesById[id].transfer_acct, | ||
); | ||
|
||
return ( | ||
<Tooltip | ||
position="bottom" | ||
width={250} | ||
style={{ padding: 0 }} | ||
onClose={onClose} | ||
> | ||
<Menu | ||
onMenuSelect={type => { | ||
onClose(); | ||
switch (type) { | ||
case 'delete': | ||
onDelete(); | ||
break; | ||
case 'merge': | ||
onMerge(); | ||
break; | ||
default: | ||
} | ||
}} | ||
footer={ | ||
<View | ||
style={{ | ||
padding: 3, | ||
fontSize: 11, | ||
fontStyle: 'italic', | ||
color: theme.pageTextSubdued, | ||
}} | ||
> | ||
{[...selectedPayees] | ||
.slice(0, 4) | ||
.map(id => payeesById[id].name) | ||
.join(', ') + (selectedPayees.size > 4 ? ', and more' : '')} | ||
</View> | ||
} | ||
items={[ | ||
{ | ||
icon: Delete, | ||
name: 'delete', | ||
text: 'Delete', | ||
disabled: isDisabled, | ||
}, | ||
{ | ||
icon: Merge, | ||
iconSize: 9, | ||
name: 'merge', | ||
text: 'Merge', | ||
disabled: isDisabled || selectedPayees.size < 2, | ||
}, | ||
Menu.line, | ||
]} | ||
/> | ||
</Tooltip> | ||
); | ||
} |
Oops, something went wrong.