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

✨ release tracking budget feature #3833

Merged
merged 10 commits into from
Nov 18, 2024
17 changes: 0 additions & 17 deletions packages/desktop-client/e2e/page-models/settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,10 @@ export class SettingsPage {
}

async useBudgetType(budgetType) {
await this.enableExperimentalFeature('Budget mode toggle');

const switchBudgetTypeButton = this.page.getByRole('button', {
name: `Switch to ${budgetType} budgeting`,
});

await switchBudgetTypeButton.click();
}

async enableExperimentalFeature(featureName) {
const advancedSettingsButton = this.page.getByTestId('advanced-settings');
await advancedSettingsButton.click();

const experimentalSettingsButton = this.page.getByTestId(
'experimental-settings',
);
await experimentalSettingsButton.click();

const featureCheckbox = this.page.getByRole('checkbox', {
name: featureName,
});
await featureCheckbox.click();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 44 additions & 40 deletions packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-strict-ignore
import React, {
useCallback,
type ComponentProps,
type ComponentType,
type CSSProperties,
} from 'react';
Expand Down Expand Up @@ -43,6 +43,43 @@ export function MobileNavTabs() {
padding: 10,
};

const [{ y }, api] = useSpring(() => ({ y: OPEN_DEFAULT_Y }));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically there are no changes here. I just re-arranged the constant definitions so that openDefault could be accessed by the NavLink definitions. It will now close the bottom nav bar whenever a item in the nav is clicked (thus navigating to a different page).

This should make the VRT tests more stable. 🤞


const openFull = useCallback(
({ canceled }: { canceled?: boolean }) => {
// when cancel is true, it means that the user passed the upwards threshold
// so we change the spring config to create a nice wobbly effect
api.start({
y: OPEN_FULL_Y,
immediate: false,
config: canceled ? config.wobbly : config.stiff,
});
},
[api, OPEN_FULL_Y],
);

const openDefault = useCallback(
(velocity = 0) => {
api.start({
y: OPEN_DEFAULT_Y,
immediate: false,
config: { ...config.stiff, velocity },
});
},
[api, OPEN_DEFAULT_Y],
);

const hide = useCallback(
(velocity = 0) => {
api.start({
y: HIDDEN_Y,
immediate: false,
config: { ...config.stiff, velocity },
});
},
[api, HIDDEN_Y],
);

const navTabs = [
{
name: 'Budget',
Expand Down Expand Up @@ -92,50 +129,15 @@ export function MobileNavTabs() {
style: navTabStyle,
Icon: SvgCog,
},
].map(tab => <NavTab key={tab.path} {...tab} />);
].map(tab => (
<NavTab key={tab.path} onClick={() => openDefault()} {...tab} />
));

const bufferTabsCount = COLUMN_COUNT - (navTabs.length % COLUMN_COUNT);
const bufferTabs = Array.from({ length: bufferTabsCount }).map((_, idx) => (
<div key={idx} style={navTabStyle} />
));

const [{ y }, api] = useSpring(() => ({ y: OPEN_DEFAULT_Y }));

const openFull = useCallback(
({ canceled }) => {
// when cancel is true, it means that the user passed the upwards threshold
// so we change the spring config to create a nice wobbly effect
api.start({
y: OPEN_FULL_Y,
immediate: false,
config: canceled ? config.wobbly : config.stiff,
});
},
[api, OPEN_FULL_Y],
);

const openDefault = useCallback(
(velocity = 0) => {
api.start({
y: OPEN_DEFAULT_Y,
immediate: false,
config: { ...config.stiff, velocity },
});
},
[api, OPEN_DEFAULT_Y],
);

const hide = useCallback(
(velocity = 0) => {
api.start({
y: HIDDEN_Y,
immediate: false,
config: { ...config.stiff, velocity },
});
},
[api, HIDDEN_Y],
);

useScrollListener(({ isScrolling }) => {
if (isScrolling('down')) {
hide();
Expand Down Expand Up @@ -237,9 +239,10 @@ type NavTabProps = {
path: string;
Icon: ComponentType<NavTabIconProps>;
style?: CSSProperties;
onClick: ComponentProps<typeof NavLink>['onClick'];
};

function NavTab({ Icon: TabIcon, name, path, style }: NavTabProps) {
function NavTab({ Icon: TabIcon, name, path, style, onClick }: NavTabProps) {
return (
<NavLink
to={path}
Expand All @@ -253,6 +256,7 @@ function NavTab({ Icon: TabIcon, name, path, style }: NavTabProps) {
textAlign: 'center',
...style,
})}
onClick={onClick}
>
<TabIcon width={22} height={22} />
{name}
Expand Down
21 changes: 1 addition & 20 deletions packages/desktop-client/src/components/settings/Experimental.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type ReactNode, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { Trans } from 'react-i18next';

import type { FeatureFlag } from 'loot-core/src/types/prefs';

Expand Down Expand Up @@ -67,23 +67,6 @@ function FeatureToggle({
);
}

function TrackingBudgetFeature() {
const { t } = useTranslation();
const [budgetType = 'rollover'] = useSyncedPref('budgetType');
const enabled = useFeatureFlag('reportBudget');
const blockToggleOff = budgetType === 'report' && enabled;
return (
<FeatureToggle
flag="reportBudget"
disableToggle={blockToggleOff}
error={t('Switch to a envelope budget before turning off this feature')}
feedbackLink="https://github.com/actualbudget/actual/issues/2999"
>
<Trans>Budget mode toggle</Trans>
</FeatureToggle>
);
}

export function ExperimentalFeatures() {
const [expanded, setExpanded] = useState(false);

Expand All @@ -92,8 +75,6 @@ export function ExperimentalFeatures() {
primaryAction={
expanded ? (
<View style={{ gap: '1em' }}>
<TrackingBudgetFeature />

<FeatureToggle flag="goalTemplatesEnabled">
<Trans>Goal templates</Trans>
</FeatureToggle>
Expand Down
3 changes: 1 addition & 2 deletions packages/desktop-client/src/components/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { isElectron } from 'loot-core/shared/environment';
import { listen } from 'loot-core/src/platform/client/fetch';

import { useActions } from '../../hooks/useActions';
import { useFeatureFlag } from '../../hooks/useFeatureFlag';
import { useGlobalPref } from '../../hooks/useGlobalPref';
import { useIsOutdated, useLatestVersion } from '../../hooks/useLatestVersion';
import { useMetadataPref } from '../../hooks/useMetadataPref';
Expand Down Expand Up @@ -177,7 +176,7 @@ export function Settings() {
<ThemeSettings />
<FormatSettings />
<EncryptionSettings />
{useFeatureFlag('reportBudget') && <BudgetTypeSettings />}
<BudgetTypeSettings />
{isElectron() && <Backups />}
<ExportBudget />
<AdvancedToggle>
Expand Down
1 change: 0 additions & 1 deletion packages/desktop-client/src/hooks/useFeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { FeatureFlag } from 'loot-core/src/types/prefs';
import { useSyncedPref } from './useSyncedPref';

const DEFAULT_FEATURE_FLAG_STATE: Record<FeatureFlag, boolean> = {
reportBudget: false,
goalTemplatesEnabled: false,
dashboards: false,
actionTemplating: false,
Expand Down
1 change: 0 additions & 1 deletion packages/loot-core/src/types/prefs.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export type FeatureFlag =
| 'dashboards'
| 'reportBudget'
| 'goalTemplatesEnabled'
| 'actionTemplating'
| 'upcomingLengthAdjustment'
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3833.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Features
authors: [MatissJanis]
---

Release tracking budget feature.