-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Foundations for the budget automations UI #4308
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
jfdoming marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ interface AverageTemplate extends BaseTemplate { | |
} | ||
|
||
interface GoalTemplate extends BaseTemplate { | ||
type: 'simple'; | ||
type: 'goal'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed since I'm pretty sure it's a typo, will matter later once we implement goal-type templates |
||
amount: number; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export type FeatureFlag = | ||
| 'goalTemplatesEnabled' | ||
| 'goalTemplatesUIEnabled' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling this |
||
| 'actionTemplating' | ||
| 'contextMenus' | ||
| 'openidAuth'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Features | ||
authors: [jfdoming] | ||
--- | ||
|
||
Foundations for the budget automations UI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused in the current PR, but the next PR will use the same styles in a different component so I extracted it here