Skip to content

Commit 5178c39

Browse files
fix(create-new): Add login option to cloud beta template list and fix styles (#7015)
* Add login option to cloud beta template list and fix styles * Add sign in button to error message
1 parent 6d13c65 commit 5178c39

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

packages/app/src/app/components/CreateSandbox/CreateSandbox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ export const CreateSandbox: React.FC<CreateSandboxProps> = ({
459459
selectTemplate(template);
460460
}}
461461
onOpenTemplate={openTemplate}
462+
isCloudTemplateList
462463
/>
463464
</Panel>
464465

packages/app/src/app/components/CreateSandbox/Import/Import.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ const UnauthenticatedImport: React.FC = () => {
1414
const actions = useActions();
1515

1616
return (
17-
<Stack direction="vertical" gap={8}>
18-
<Text as="h2" css={{ margin: 0 }} size={4} weight="medium">
17+
<Stack direction="vertical" gap={4}>
18+
<Text
19+
as="h2"
20+
css={{ margin: 0, lineHeight: '24px' }}
21+
size={4}
22+
weight="medium"
23+
>
1924
Import from GitHub
2025
</Text>
2126
<Stack direction="vertical" gap={4}>

packages/app/src/app/components/CreateSandbox/TemplateCategoryList.tsx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
import React, { useEffect } from 'react';
22
import track from '@codesandbox/common/lib/utils/analytics';
3-
import { Text, Stack } from '@codesandbox/components';
3+
import { Button, Text, Stack } from '@codesandbox/components';
44
import { css } from '@styled-system/css';
55
import { CloudBetaBadge } from 'app/components/CloudBetaBadge';
6+
import { useAppState, useActions } from 'app/overmind';
67
import { TemplateFragment } from 'app/graphql/types';
78
import { TemplateCard } from './TemplateCard';
89
import { TemplateGrid } from './elements';
910

1011
interface TemplateCategoryListProps {
1112
title: string;
12-
showBetaTag?: boolean;
13+
isCloudTemplateList?: boolean;
1314
templates: TemplateFragment[];
1415
onSelectTemplate: (template: TemplateFragment) => void;
1516
onOpenTemplate: (template: TemplateFragment) => void;
1617
}
1718

1819
export const TemplateCategoryList = ({
1920
title,
20-
showBetaTag,
21+
isCloudTemplateList,
2122
templates,
2223
onSelectTemplate,
2324
onOpenTemplate,
2425
}: TemplateCategoryListProps) => {
26+
const { hasLogIn } = useAppState();
27+
const actions = useActions();
28+
2529
useEffect(() => {
2630
track('Create Sandbox Tab Open', { tab: title });
2731
}, [title]);
2832

2933
return (
30-
<Stack direction="vertical" css={{ height: '100%' }} gap={6}>
34+
<Stack direction="vertical" css={{ height: '100%' }} gap={4}>
3135
<Stack
3236
css={css({
3337
alignItems: 'center',
@@ -42,14 +46,31 @@ export const TemplateCategoryList = ({
4246
size={4}
4347
css={{
4448
fontWeight: 500,
45-
lineHeight: 1.5,
49+
lineHeight: '24px',
4650
margin: 0,
4751
}}
4852
>
4953
{title}
5054
</Text>
51-
{showBetaTag && <CloudBetaBadge hideIcon />}
55+
{isCloudTemplateList && <CloudBetaBadge hideIcon />}
5256
</Stack>
57+
{!hasLogIn && isCloudTemplateList ? (
58+
<Stack direction="vertical" gap={4}>
59+
<Text id="unauthenticated-label" css={{ color: '#999999' }} size={3}>
60+
You need to be signed in to fork a cloud template.
61+
</Text>
62+
<Button
63+
aria-describedby="unauthenticated-label"
64+
css={{
65+
width: '132px',
66+
}}
67+
onClick={() => actions.signInClicked()}
68+
variant="primary"
69+
>
70+
Sign in
71+
</Button>
72+
</Stack>
73+
) : null}
5374
<TemplateGrid>
5475
{templates.length > 0 ? (
5576
templates.map(template => (

packages/app/src/app/overmind/internalActions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,17 @@ export const handleError = (
526526
effects.analytics.track('Patron Server Sandbox Limit Reached', {
527527
errorMessage: error.message,
528528
});
529+
} else if (
530+
error.message.startsWith(
531+
'You need to be signed in to fork a server template.'
532+
)
533+
) {
534+
notificationActions.primary = {
535+
label: 'Sign in',
536+
run: () => {
537+
state.signInModalOpen = true;
538+
},
539+
};
529540
}
530541

531542
effects.notificationToast.add({

0 commit comments

Comments
 (0)