-
Notifications
You must be signed in to change notification settings - Fork 10
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
[RW-13480][risk=no] Workspace Banners for Initial Credits #8951
Open
evrii
wants to merge
47
commits into
main
Choose a base branch
from
eric/RW-13480
base: main
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 3 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
40bdb61
Added basic tests.
evrii cc7918c
Add expiration date.
evrii dee730b
Update styling
evrii e76615e
Add checks for extension button.
evrii a5ff2f3
Add extension and info buttons.
evrii 0adb7e4
Merge remote-tracking branch 'origin/main' into eric/RW-13481
evrii ad412f5
Merge remote-tracking branch 'origin/main' into eric/RW-13481
evrii c214129
Added extension field.
evrii cd7f7d3
First pass at banners
evrii bdd7f49
Simplified logic?
evrii a2dbc9d
Added config values.
evrii 42b159c
[RW-13735][risk=no] Added modal to trigger initial credit extension. …
evrii f50fb7b
Merge remote-tracking branch 'origin/eric/RW-13481' into eric/RW-13480
evrii bd12bb9
Fix title and eligibility usage
evrii 7b35bd6
Merge remote-tracking branch 'origin/main' into eric/RW-13480
evrii 6480a2f
[risk=low][no ticket] [dependabot] Bump cross-spawn from 7.0.3 to 7.0…
dependabot[bot] 7881475
laucn multi-zone (#8956)
yonghaoy 92a2784
remove getUploadResult in verifyAndLog (#8955)
Qi77Qi 0abe313
Merge remote-tracking branch 'origin/main' into eric/RW-13480
evrii 0f0326e
Update banner
evrii 8092dba
Cleaner banner?
evrii e507305
Merge remote-tracking branch 'origin/main' into eric/RW-13480
evrii d7ec332
Cleanup
evrii 34957ec
Add expiring soon banners.
evrii d1b1f87
Add expired but eligible tests
evrii f463eec
Add expired and ineligible tests
evrii 73378ea
Hide banner if not appropriate
evrii 3c286c7
Cleanup
evrii cbca190
Cleanup
evrii cd304ee
Updated language
evrii 300240f
Updated spacing
evrii 3c6ec5e
Updated test email.
evrii d6364e3
Merge main
evrii 8f15eb8
Made variables explicit
evrii 2e317b1
Cleanup
evrii b96ee0e
Changed directory
evrii 6d30024
Swap function
evrii 7b352b1
Fix link
evrii d66c840
Added missing extension logic
evrii 62b3414
Cleanup
evrii df7e585
Merge main
evrii fa78083
Fix name of mapper
evrii db9d522
Add missing condition
evrii 0954fd0
Cleanup
evrii ef63dde
Add comment
evrii db7a2ae
Removed unused enum
evrii 2cc9dfa
Cleanup
evrii 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 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 |
---|---|---|
|
@@ -4,8 +4,10 @@ import * as fp from 'lodash'; | |
import { Profile } from 'generated/fetch'; | ||
|
||
import { Button, LinkButton } from 'app/components/buttons'; | ||
import { AoU } from 'app/components/text-wrappers'; | ||
import { ToastBanner, ToastType } from 'app/components/toast-banner'; | ||
import { withCurrentWorkspace, withUserProfile } from 'app/utils'; | ||
import { plusDays } from 'app/utils/dates'; | ||
import { NavigationProps } from 'app/utils/navigation'; | ||
import { withNavigation } from 'app/utils/with-navigation-hoc'; | ||
import { WorkspaceData } from 'app/utils/workspace-data'; | ||
|
@@ -19,23 +21,119 @@ interface Props extends NavigationProps { | |
onClose: Function; | ||
} | ||
|
||
const InitialCreditsArticleLink = () => ( | ||
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. these 2 links have different text but the same URL. that does not seem right. 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. Thank you :-) |
||
<> | ||
" | ||
<LinkButton | ||
onClick={() => window.open(supportUrls.createBillingAccount, '_blank')} | ||
> | ||
Using <AoU /> Initial Credits | ||
</LinkButton> | ||
" | ||
</> | ||
); | ||
|
||
const BillingAccountArticleLink = () => ( | ||
<> | ||
" | ||
<LinkButton | ||
onClick={() => window.open(supportUrls.createBillingAccount, '_blank')} | ||
> | ||
Paying for Your Research | ||
</LinkButton> | ||
" | ||
</> | ||
); | ||
|
||
export const InvalidBillingBanner = fp.flow( | ||
withCurrentWorkspace(), | ||
withUserProfile(), | ||
withNavigation | ||
)(({ onClose, navigate, workspace }: Props) => { | ||
const message = ( | ||
<div> | ||
The initial credits for the creator of this workspace have run out. Please | ||
provide a valid billing account. | ||
<LinkButton | ||
onClick={() => window.open(supportUrls.createBillingAccount, '_blank')} | ||
> | ||
Learn how to link a billing account. | ||
</LinkButton> | ||
</div> | ||
); | ||
const footer = ( | ||
)(({ onClose, navigate, workspace, profileState }: Props) => { | ||
const { profile } = profileState; | ||
const isCreator = | ||
workspace && profile && profile.username === workspace.creator; | ||
const isEligibleForExtension = workspace && !workspace.extensionEpochMillis; | ||
const isExpired = | ||
workspace && workspace.initialCredits.expirationEpochMillis < Date.now(); | ||
const isExpiringSoon = | ||
workspace && | ||
!isExpired && | ||
plusDays(workspace.initialCredits.expirationEpochMillis, 5) < Date.now(); | ||
let message; | ||
let title; | ||
if (isExpiringSoon && isEligibleForExtension) { | ||
evrii marked this conversation as resolved.
Show resolved
Hide resolved
|
||
title = 'Workspace credits are expiring soon'; | ||
if (isCreator) { | ||
// Banner 1 in spec | ||
message = ( | ||
<div> | ||
Your initial credits are expiring soon. You can request an extension | ||
here. For more information, read the <InitialCreditsArticleLink />{' '} | ||
article on the User Support Hub. | ||
</div> | ||
); | ||
} else { | ||
// Banner 2 in spec | ||
message = ( | ||
<div> | ||
This workspace creator’s initial credits are expiring soon. This | ||
workspace was created by FIRST NAME LAST NAME. For more information, | ||
read the <InitialCreditsArticleLink /> article on the User Support | ||
Hub. | ||
</div> | ||
); | ||
} | ||
} else if (isExpired) { | ||
if (isEligibleForExtension) { | ||
title = 'Workspace credits have expired'; | ||
if (isCreator) { | ||
// Banner 3 in spec (changed to trigger modal from here instead of on Profile page) | ||
message = ( | ||
<div> | ||
Your initial credits have expired. You can request an extension | ||
here. For more information, read the <InitialCreditsArticleLink />{' '} | ||
article on the User Support Hub. | ||
</div> | ||
); | ||
} else { | ||
// Banner 4 in spec | ||
message = ( | ||
<div> | ||
This workspace creator’s initial credits have expired. This | ||
workspace was created by FIRST NAME LAST NAME. For more information, | ||
read the <InitialCreditsArticleLink /> article on the User Support | ||
Hub. | ||
</div> | ||
); | ||
} | ||
} else { | ||
title = 'This workspace is out of initial credits'; | ||
if (isCreator) { | ||
// Banner 5 in spec | ||
message = ( | ||
<div> | ||
Your initial credits have run out. To use the workspace, a valid | ||
billing account needs to be provided. To learn more about | ||
establishing a billing account, read the{' '} | ||
<BillingAccountArticleLink /> article on the User Support Hub. | ||
</div> | ||
); | ||
} else { | ||
// Banner 6 in spec | ||
message = ( | ||
<div> | ||
This workspace creator’s initial credits have run out. This | ||
workspace was created by FIRST NAME LAST NAME. To use the workspace, | ||
a valid billing account needs to be provided. To learn more about | ||
establishing a billing account, read the{' '} | ||
<BillingAccountArticleLink /> article on the User Support Hub. | ||
</div> | ||
); | ||
} | ||
} | ||
} | ||
const footer = isCreator && ( | ||
<Button | ||
style={{ height: '38px', width: '70%', fontWeight: 400 }} | ||
onClick={() => { | ||
|
@@ -53,6 +151,7 @@ export const InvalidBillingBanner = fp.flow( | |
Edit Workspace | ||
</Button> | ||
); | ||
|
||
return ( | ||
<ToastBanner | ||
{...{ message, footer, onClose }} | ||
|
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 sets extension to the same value as expiration. Is this intentional?
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.
Whoops, nope. I corrected it. Thank you for pointing it out.