-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Foundations for the budget automations UI (#4308)
* Foundations for the budget automations UI * Coderabbit
- Loading branch information
Showing
11 changed files
with
102 additions
and
17 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
54 changes: 54 additions & 0 deletions
54
packages/desktop-client/src/components/budget/goals/CategoryAutomationButton.tsx
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,54 @@ | ||
import React, { type CSSProperties } from 'react'; | ||
|
||
import { Button } from '@actual-app/components/button'; | ||
import { theme } from '@actual-app/components/theme'; | ||
|
||
import { pushModal } from 'loot-core/client/actions'; | ||
import { type Template } from 'loot-core/server/budget/types/templates'; | ||
|
||
import { useFeatureFlag } from '../../../hooks/useFeatureFlag'; | ||
import { SvgChartPie } from '../../../icons/v1'; | ||
import { useDispatch } from '../../../redux'; | ||
|
||
type CategoryAutomationButtonProps = { | ||
width?: number; | ||
height?: number; | ||
defaultColor?: string; | ||
style?: CSSProperties; | ||
}; | ||
export function CategoryAutomationButton({ | ||
width = 12, | ||
height = 12, | ||
defaultColor = theme.buttonNormalText, | ||
style, | ||
}: CategoryAutomationButtonProps) { | ||
const automations: Template[] = []; | ||
const hasAutomations = !!automations.length; | ||
|
||
const dispatch = useDispatch(); | ||
|
||
const goalTemplatesEnabled = useFeatureFlag('goalTemplatesEnabled'); | ||
const goalTemplatesUIEnabled = useFeatureFlag('goalTemplatesUIEnabled'); | ||
|
||
if (!goalTemplatesEnabled || !goalTemplatesUIEnabled) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Button | ||
variant="bare" | ||
aria-label="Change category automations" | ||
className={!hasAutomations ? 'hover-visible' : ''} | ||
style={{ | ||
color: defaultColor, | ||
...style, | ||
...(hasAutomations && { display: 'flex !important' }), | ||
}} | ||
onPress={() => { | ||
dispatch(pushModal('category-automations-edit')); | ||
}} | ||
> | ||
<SvgChartPie style={{ width, height, flexShrink: 0 }} /> | ||
</Button> | ||
); | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Features | ||
authors: [jfdoming] | ||
--- | ||
|
||
Foundations for the budget automations UI |