From 62ebf59dbe9014bf1e3ba7f76207dd2201e6c288 Mon Sep 17 00:00:00 2001 From: Ramon Candel Date: Tue, 30 Jul 2024 15:05:35 +0200 Subject: [PATCH] Fixed navigation from upgrade now button to new preferences modal --- src/app/drive/components/PlanUsage/PlanUsage.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/drive/components/PlanUsage/PlanUsage.tsx b/src/app/drive/components/PlanUsage/PlanUsage.tsx index 1d9b72a0e..a6cfe4517 100644 --- a/src/app/drive/components/PlanUsage/PlanUsage.tsx +++ b/src/app/drive/components/PlanUsage/PlanUsage.tsx @@ -1,9 +1,12 @@ +import navigationService from 'app/core/services/navigation.service'; import limitService from 'app/drive/services/limit.service'; import { bytesToString } from 'app/drive/services/size.service'; import usageService from 'app/drive/services/usage.service'; -import navigationService from 'app/core/services/navigation.service'; -import { AppView } from 'app/core/types'; import { useTranslationContext } from 'app/i18n/provider/TranslationProvider'; +import { useDispatch } from 'react-redux'; +import { useAppSelector } from '../../../store/hooks'; +import { uiActions } from '../../../store/slices/ui'; +import workspacesSelectors from '../../../store/slices/workspaces/workspaces.selectors'; export default function PlanUsage({ limit, @@ -19,13 +22,20 @@ export default function PlanUsage({ className?: string; }): JSX.Element { const { translate } = useTranslationContext(); + const dispatch = useDispatch(); const usagePercent = usageService.getUsagePercent(usage, limit); + const selectedWorkspace = useAppSelector(workspacesSelectors.getSelectedWorkspace); const isLimitReached = usage >= limit; const componentColor = isLimitReached ? 'bg-red' : 'bg-primary'; const onUpgradeButtonClicked = () => { - navigationService.push(AppView.Preferences, { tab: 'plans' }); + navigationService.openPreferencesDialog({ + section: 'account', + subsection: 'plans', + workspaceUuid: selectedWorkspace?.workspaceUser.workspaceId, + }); + dispatch(uiActions.setIsPreferencesDialogOpen(true)); }; return (