-
Notifications
You must be signed in to change notification settings - Fork 34
[PB-6492]:feat/new banners for storage advertisement #2002
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
Open
jaaaaavier
wants to merge
7
commits into
master
Choose a base branch
from
feat/progressive-free-usage-storage-advertisements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0836757
feat: new banners for storage advertisement
jaaaaavier f8e4794
Merge branch 'master' into feat/progressive-free-usage-storage-advert…
jaaaaavier 58538a8
remove unused import
jaaaaavier 31245c1
remove tailwind config
jaaaaavier 33986d9
feat: update css library version
jaaaaavier 16e6760
Merge branch 'master' into feat/progressive-free-usage-storage-advert…
jaaaaavier 25a34ee
Merge branch 'master' into feat/progressive-free-usage-storage-advert…
jaaaaavier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ import { RootState } from 'app/store'; | |
| import { useAppDispatch, useAppSelector } from 'app/store/hooks'; | ||
| import { planSelectors } from 'app/store/slices/plan'; | ||
| import { sharedThunks } from 'app/store/slices/sharedLinks'; | ||
| import { uiActions } from 'app/store/slices/ui'; | ||
| import logo from 'assets/icons/small-logo.svg'; | ||
| import { useSidenavCollapsed } from 'hooks/useSidenavCollapsed'; | ||
| import { useSidenavNavigation } from 'hooks/useSidenavNavigation'; | ||
|
|
@@ -24,6 +23,35 @@ import { useReferralParamsChange } from 'views/Drive/hooks/useReferralParamsChan | |
| import WorkspaceSelectorContainer from 'views/Home/components/WorkspaceSelectorContainer'; | ||
| import WorkspaceSelectorSkeleton from 'views/Home/components/WorkspaceSelectorSkeleton'; | ||
| import ReferralBanner from './ReferralBanner'; | ||
| import { CloudWarning } from '@phosphor-icons/react'; | ||
|
|
||
| type StorageWarning = 'lowWarning' | 'midWarning' | 'highWarning'; | ||
|
|
||
| interface StorageStageConfig { | ||
| key: StorageWarning; | ||
| threshold: number; | ||
| barClassName: string; | ||
| containerClassName?: string; | ||
| advertisementKey?: string; | ||
| } | ||
|
|
||
| const STORAGE_STAGES: StorageStageConfig[] = [ | ||
| { key: 'lowWarning', threshold: 60, barClassName: 'bg-yellow-60', containerClassName: 'pb-5' }, | ||
| { | ||
| key: 'midWarning', | ||
| threshold: 80, | ||
| barClassName: 'bg-orange-60', | ||
| containerClassName: 'pb-5', | ||
| advertisementKey: 'modals.reachingUsageBanner.midWarning.sidenavStorageText', | ||
| }, | ||
| { | ||
| key: 'highWarning', | ||
| threshold: 95, | ||
| barClassName: 'bg-danger', | ||
| containerClassName: 'pb rounded-lg bg-alert border border-alert-dark', | ||
| advertisementKey: 'modals.reachingUsageBanner.highWarning.sidenavStorageText', | ||
| }, | ||
| ]; | ||
|
Contributor
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. Maybe it could be better to centralize this Stages with this one. Something like STORAGE_STAGES_CONFIG and export them whenever you need them and use it as you wish. |
||
|
|
||
| const SidenavPrimaryAction = ({ | ||
| user, | ||
|
|
@@ -69,6 +97,12 @@ const SidenavWrapper = () => { | |
| const userUsage = planUsage > 0 ? bytesToString(planUsage) : '0GB'; | ||
| const isReferralEligible = useAppSelector((state: RootState) => state.referrals.isEligible); | ||
|
|
||
| const isFreeUser = subscription?.type === 'free'; | ||
| const usedPercentage = planLimit > 0 ? (planUsage / planLimit) * 100 : 0; | ||
| const reachedStorageStage = isFreeUser | ||
| ? [...STORAGE_STAGES].reverse().find((stage) => usedPercentage >= stage.threshold) | ||
| : undefined; | ||
|
|
||
| useReferralParamsChange(); | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -91,14 +125,19 @@ const SidenavWrapper = () => { | |
| }; | ||
|
|
||
| const handleUpgradeClick = () => { | ||
| navigationService.openPreferencesDialog({ | ||
| section: 'account', | ||
| subsection: 'plans', | ||
| workspaceUuid: selectedWorkspace?.workspaceUser.workspaceId, | ||
| }); | ||
| dispatch(uiActions.setIsPreferencesDialogOpen(true)); | ||
| window.open('https://internxt.com/specialoffer', '_blank', 'noopener,noreferrer'); | ||
| }; | ||
|
|
||
| const storageAdvertisement = reachedStorageStage?.advertisementKey ? ( | ||
| <span className="flex flex-row gap-0.5 items-center"> | ||
| <CloudWarning | ||
| className="size-5 text-yellow-60" | ||
| weight={reachedStorageStage.key === 'highWarning' ? 'fill' : 'regular'} | ||
| /> | ||
| <p className="text-sm font-semibold text-gray-80">{translate(reachedStorageStage.advertisementKey)} </p> | ||
| </span> | ||
| ) : undefined; | ||
|
|
||
| const handleReferralClick = () => { | ||
| if (user) { | ||
| referralService.openPanel( | ||
|
|
@@ -141,6 +180,9 @@ const SidenavWrapper = () => { | |
| onUpgradeClick: handleUpgradeClick, | ||
| upgradeLabel: isUpgradeAvailable() ? translate('preferences.account.plans.upgrade') : undefined, | ||
| isLoading: isLoadingPlanUsage && isLoadingPlanLimit && isLoadingBusinessLimitAndUsage, | ||
| barClassName: reachedStorageStage?.barClassName, | ||
| containerClassName: reachedStorageStage?.containerClassName, | ||
| advertisement: storageAdvertisement, | ||
| }} | ||
| /> | ||
| {isReferralEligible && ( | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 duplicated.