-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(sub v3): Update current plan header card #100800
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f3d66df
feat(sub v3): Update current plan header card
isabellaenriquez 8e0c3ff
Merge branch 'master' into isabella/bil-1232
isabellaenriquez 9d8b58d
add addons + tests
isabellaenriquez bc95fbd
account for managed + fix component usage in header
isabellaenriquez 861ebdd
pass priority to reg button
isabellaenriquez 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import {css} from '@emotion/react'; | ||
import styled from '@emotion/styled'; | ||
import moment from 'moment-timezone'; | ||
|
||
import {Flex, Grid} from 'sentry/components/core/layout'; | ||
import {Text} from 'sentry/components/core/text'; | ||
import ErrorBoundary from 'sentry/components/errorBoundary'; | ||
import Panel from 'sentry/components/panels/panel'; | ||
import {space} from 'sentry/styles/space'; | ||
import {IconGrid, IconUpgrade} from 'sentry/icons'; | ||
import {t, tct} from 'sentry/locale'; | ||
import type {Organization} from 'sentry/types/organization'; | ||
import {toTitleCase} from 'sentry/utils/string/toTitleCase'; | ||
|
||
import type {Subscription} from 'getsentry/types'; | ||
import {hasNewBillingUI} from 'getsentry/utils/billing'; | ||
import {getPlanIcon, getProductIcon, hasNewBillingUI} from 'getsentry/utils/billing'; | ||
import SubscriptionHeaderCard from 'getsentry/views/subscriptionPage/headerCards/subscriptionHeaderCard'; | ||
import SeerAutomationAlert from 'getsentry/views/subscriptionPage/seerAutomationAlert'; | ||
|
||
import {SubscriptionCard} from './subscriptionCard'; | ||
|
@@ -19,28 +22,90 @@ interface HeaderCardsProps { | |
} | ||
|
||
export function HeaderCards({organization, subscription}: HeaderCardsProps) { | ||
const isNewBillingUI = hasNewBillingUI(organization); | ||
|
||
const cards = [ | ||
<PlanCard key="plan" subscription={subscription} organization={organization} />, | ||
].filter(card => card !== null); | ||
|
||
return ( | ||
<ErrorBoundary mini> | ||
<SeerAutomationAlert organization={organization} /> | ||
<HeaderCardWrapper hasNewCheckout={hasNewBillingUI(organization)}> | ||
<SubscriptionCard organization={organization} subscription={subscription} /> | ||
<UsageCard organization={organization} subscription={subscription} /> | ||
</HeaderCardWrapper> | ||
{isNewBillingUI ? ( | ||
<Grid | ||
columns={{ | ||
xs: '1fr', | ||
sm: `repeat(${Math.min(cards.length, 2)}, 1fr)`, | ||
md: `repeat(${cards.length}, 1fr)`, | ||
}} | ||
> | ||
{cards} | ||
</Grid> | ||
) : ( | ||
<Grid | ||
background="primary" | ||
border="primary" | ||
radius="md" | ||
columns={{lg: 'auto minmax(0, 600px)'}} | ||
gap={{lg: 'xl'}} | ||
> | ||
<SubscriptionCard organization={organization} subscription={subscription} /> | ||
<UsageCard organization={organization} subscription={subscription} /> | ||
</Grid> | ||
)} | ||
</ErrorBoundary> | ||
); | ||
} | ||
|
||
// TODO(checkout v3): update this with the real layout | ||
const HeaderCardWrapper = styled(Panel)<{hasNewCheckout: boolean}>` | ||
display: grid; | ||
margin-bottom: ${space(2)}; | ||
|
||
${p => | ||
!p.hasNewCheckout && | ||
css` | ||
@media (min-width: ${p.theme.breakpoints.lg}) { | ||
grid-template-columns: auto minmax(0, 600px); | ||
gap: ${space(2)}; | ||
} | ||
`} | ||
`; | ||
function PlanCard({ | ||
subscription, | ||
organization, | ||
}: { | ||
organization: Organization; | ||
subscription: Subscription; | ||
}) { | ||
const button = subscription.canSelfServe | ||
? subscription.isFree | ||
? { | ||
ariaLabel: t('Upgrade plan'), | ||
label: t('Upgrade plan'), | ||
linkTo: `/settings/${organization.slug}/billing/checkout/?referrer=upgrade_plan`, | ||
icon: <IconUpgrade />, | ||
priority: 'primary' as const, | ||
} | ||
: { | ||
ariaLabel: t('Edit plan'), | ||
label: t('Edit plan'), | ||
linkTo: `/settings/${organization.slug}/billing/checkout/?referrer=edit_plan`, | ||
icon: <IconUpgrade />, | ||
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. 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. intentional change |
||
priority: 'default' as const, | ||
} | ||
: undefined; | ||
return ( | ||
<SubscriptionHeaderCard | ||
title={t('Current plan')} | ||
icon={<IconGrid />} | ||
subtitle={tct('[startDate] - [endDate]', { | ||
startDate: moment(subscription.contractPeriodStart).format('MMM D, YYYY'), | ||
endDate: moment(subscription.contractPeriodEnd).format('MMM D, YYYY'), | ||
})} | ||
sections={[ | ||
<Flex key="plan" gap="sm" align="center"> | ||
{getPlanIcon(subscription.planDetails)} | ||
<Text bold>{t('%s Plan', subscription.planDetails.name)}</Text> | ||
</Flex>, | ||
...Object.values(subscription.addOns ?? {}) | ||
.filter(addOn => addOn.enabled) | ||
.map(addOn => ( | ||
<Flex key={addOn.apiName} gap="sm" align="center"> | ||
{getProductIcon(addOn.apiName)} | ||
<Text bold> | ||
{toTitleCase(addOn.productName, {allowInnerUpperCase: true})} | ||
</Text> | ||
</Flex> | ||
)), | ||
]} | ||
button={button} | ||
/> | ||
); | ||
} |
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
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.
for this,
managedNote
,pendingChanges
, andtrialAlert
, I removed the bottom margins from here so the new parent component can handle the spacing