Skip to content

Commit 7c29117

Browse files
authored
feat: ubb beta welcome (#8269)
* feat: ubb beta welcome * feat: Refactor import statements and add 'Learn more' button with link and dismiss functionality * feat: Format code, add useDismissible hook and fix conditional rendering in RecentHeader component * feat: Format code, fix import path and create UBBBetaWelcomeBanner component * feat: Fix issue with RecentHeader component not rendering the TopBanner., add TopBanner component to RecentHeader. and format code in RecentHeader component. * Update UBBBetaWelcomeBanner.tsx * Update useWorkspaceFeatureFlags.ts
1 parent e21042c commit 7c29117

File tree

3 files changed

+124
-4
lines changed

3 files changed

+124
-4
lines changed

packages/app/src/app/components/StripeMessages/SandboxLimitation.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ import { MessageStripe } from '@codesandbox/components';
44
import { useAppState } from 'app/overmind';
55
import { useWorkspaceLimits } from 'app/hooks/useWorkspaceLimits';
66
import { useScopedPersistedState } from 'app/hooks/usePersistedState';
7+
import { useWorkspaceFeatureFlags } from 'app/hooks/useWorkspaceFeatureFlags';
78

89
const SANDBOX_INCREASE_LIMIT_REQUEST_FORM =
910
'https://webforms.pipedrive.com/f/cB3DfL4Vg41gVPKuA6MLRpr8YI6L8KCzxiulfpjgnBdFBxa4xkJpqMSE6g8yHTjjtF';
10-
const SANDBOX_LIMIT_ANNOUNCEMENT = 'https://www.codesandbox.community/c/api-billing-updates/upcoming-pricing-billing-changes';
11+
const SANDBOX_LIMIT_ANNOUNCEMENT =
12+
'https://www.codesandbox.community/c/api-billing-updates/upcoming-pricing-billing-changes';
1113

1214
export const SandboxLimitation: React.FC = () => {
15+
const { ubbBeta } = useWorkspaceFeatureFlags();
1316
const { activeTeam } = useAppState();
1417
const { hasOver20Sandboxes, hasOver200Sandboxes } = useWorkspaceLimits();
1518
const [
@@ -21,6 +24,10 @@ export const SandboxLimitation: React.FC = () => {
2124
setSandboxBannerDismissed(true);
2225
};
2326

27+
if (ubbBeta) {
28+
return null;
29+
}
30+
2431
const buildCopy = () => {
2532
if (hasOver200Sandboxes) {
2633
return 'Starting on Jan 30th, your Free plan will be limited to 20 sandboxes. Request an increase to avoid disruption to your service.';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import * as React from 'react';
2+
3+
import { dashboard as dashboardURLs } from '@codesandbox/common/lib/utils/url-generator';
4+
import { Banner, Button, Stack, Text, Icon } from '@codesandbox/components';
5+
6+
import { useDismissible } from 'app/hooks';
7+
import { Link } from 'react-router-dom';
8+
import { SUBSCRIPTION_DOCS_URLS } from 'app/constants';
9+
import { useURLSearchParams } from 'app/hooks/useURLSearchParams';
10+
11+
export const UBBBetaWelcomeBanner: React.FC = () => {
12+
const [isBannerDismissed, dismissBanner] = useDismissible(
13+
'DASHBOARD_UBB_BETA_WELCOME'
14+
);
15+
16+
if (isBannerDismissed) {
17+
return null;
18+
}
19+
20+
return (
21+
<Banner onDismiss={dismissBanner}>
22+
<Stack gap={2} direction="vertical">
23+
<Text color="#EDFFA5" size={6} weight="500">
24+
Welcome to the usage-based billing beta
25+
</Text>
26+
<Text>
27+
This workspace has been added to an early beta experience. You can
28+
now:
29+
</Text>
30+
</Stack>
31+
32+
<StyledFeatures />
33+
34+
<Stack
35+
align="center"
36+
gap={2}
37+
css={{
38+
marginTop: '24px',
39+
}}
40+
>
41+
<Button
42+
target="_blank"
43+
autoWidth
44+
onClick={() => {
45+
window.open(SUBSCRIPTION_DOCS_URLS.teams.non_trial);
46+
dismissBanner();
47+
}}
48+
>
49+
Learn more
50+
</Button>
51+
<Button autoWidth variant="ghost" onClick={dismissBanner}>
52+
Dismiss
53+
</Button>
54+
</Stack>
55+
</Banner>
56+
);
57+
};
58+
59+
const StyledFeatures: React.FC = () => {
60+
const { getQueryParam } = useURLSearchParams();
61+
const workspaceId = getQueryParam('workspace');
62+
63+
return (
64+
<Stack
65+
gap={6}
66+
as="ul"
67+
css={{
68+
listStyle: 'none',
69+
padding: '12px 0 24px 0',
70+
maxWidth: 724,
71+
}}
72+
>
73+
<Stack gap={3} as="li">
74+
<Icon css={{ flexShrink: 0, color: '#C2C2C2' }} name="lock" />
75+
<Text css={{ color: '#999' }} size={3}>
76+
Create private sandboxes and devboxes for free.
77+
</Text>
78+
</Stack>
79+
80+
<Stack gap={3} as="li">
81+
<Icon css={{ flexShrink: 0, color: '#C2C2C2' }} name="server" />
82+
<Text css={{ color: '#999' }} size={3}>
83+
Customize Virtual Machine specs through the new{' '}
84+
<Link to={dashboardURLs.portalRelativePath(workspaceId)}>
85+
customer portal.
86+
</Link>
87+
</Text>
88+
</Stack>
89+
90+
<Stack gap={3} as="li">
91+
<Icon css={{ flexShrink: 0, color: '#C2C2C2' }} name="sandbox" />
92+
<Text css={{ color: '#999' }} size={3}>
93+
Run devboxes and repositories on credits.
94+
</Text>
95+
</Stack>
96+
</Stack>
97+
);
98+
};

packages/app/src/app/pages/Dashboard/Content/routes/Recent/RecentHeader.tsx

+18-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import {
55
IMPORT_BUTTON_DESCRIPTION,
66
SANDBOX_BUTTON_DESCRIPTION,
77
} from 'app/components/Create/utils/constants';
8+
import { UBBBetaWelcomeBanner } from 'app/components/UBBBetaWelcomeBanner';
89
import { LargeCTAButton } from 'app/components/dashboard/LargeCTAButton';
10+
import { useDismissible } from 'app/hooks';
911
import { useWorkspaceFeatureFlags } from 'app/hooks/useWorkspaceFeatureFlags';
1012
import { useActions } from 'app/overmind';
1113
import { EmptyPage } from 'app/pages/Dashboard/Components/EmptyPage';
@@ -17,12 +19,10 @@ import React from 'react';
1719

1820
export const RecentHeader: React.FC<{ title: string }> = ({ title }) => {
1921
const actions = useActions();
20-
const { ubbBeta } = useWorkspaceFeatureFlags();
2122

2223
return (
2324
<Stack direction="vertical" gap={8}>
24-
{ubbBeta ? <UbbUpgradeBanner /> : <UpgradeBanner />}
25-
25+
<TopBanner />
2626
<Text
2727
as="h1"
2828
css={{
@@ -95,3 +95,18 @@ export const RecentHeader: React.FC<{ title: string }> = ({ title }) => {
9595
</Stack>
9696
);
9797
};
98+
99+
const TopBanner = () => {
100+
const { ubbBeta } = useWorkspaceFeatureFlags();
101+
const [welcomeBannerDismissed] = useDismissible('DASHBOARD_UBB_BETA_WELCOME');
102+
103+
if (ubbBeta) {
104+
if (welcomeBannerDismissed) {
105+
return <UbbUpgradeBanner />;
106+
}
107+
108+
return <UBBBetaWelcomeBanner />;
109+
}
110+
111+
return <UpgradeBanner />;
112+
};

0 commit comments

Comments
 (0)