Skip to content

Commit ccf96b1

Browse files
lbogdanCompuIves
authored andcommitted
Show message if user doesn't have any (liked) sandboxes. (codesandbox#809)
1 parent c3fe136 commit ccf96b1

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

packages/app/src/app/pages/Profile/Sandboxes/elements.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import * as React from 'react';
12
import styled from 'styled-components';
23

4+
import Centered from 'common/components/flex/Centered';
5+
import Margin from 'common/components/spacing/Margin';
6+
37
export const Navigation = styled.div`
48
width: 100%;
59
display: flex;
@@ -15,3 +19,21 @@ export const Notice = styled.div`
1519
padding: 2rem 0;
1620
padding-bottom: 0;
1721
`;
22+
23+
const ErrorTitle = styled.div`
24+
font-size: 1.25rem;
25+
color: rgba(255, 255, 255, 0.7);
26+
`;
27+
const prefix = {
28+
currentSandboxes: ["You don't have", "This user doesn't have"],
29+
currentLikedSandboxes: ["You didn't like", "This user didn't like"],
30+
};
31+
export const NoSandboxes = ({ source, isCurrentUser }) => (
32+
<Centered vertical horizontal>
33+
<Margin top={4}>
34+
<ErrorTitle>
35+
{prefix[source][isCurrentUser ? 0 : 1]} any sandboxes yet
36+
</ErrorTitle>
37+
</Margin>
38+
</Centered>
39+
);

packages/app/src/app/pages/Profile/Sandboxes/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { inject, observer } from 'mobx-react';
44
import Button from 'app/components/Button';
55
import SandboxList from 'app/components/SandboxList';
66

7-
import { Navigation, Notice } from './elements';
7+
import { Navigation, Notice, NoSandboxes } from './elements';
88

99
const PER_PAGE_COUNT = 15;
1010

@@ -71,6 +71,13 @@ class Sandboxes extends React.Component {
7171
if (isLoadingSandboxes || !sandboxes || !sandboxes.get(page))
7272
return <div />;
7373

74+
const sandboxesPage = sandboxes.get(page);
75+
76+
if (sandboxesPage.length === 0)
77+
return (
78+
<NoSandboxes source={source} isCurrentUser={isProfileCurrentUser} />
79+
);
80+
7481
return (
7582
<div>
7683
{isProfileCurrentUser && (
@@ -81,7 +88,7 @@ class Sandboxes extends React.Component {
8188
)}
8289
<SandboxList
8390
isCurrentUser={isProfileCurrentUser}
84-
sandboxes={sandboxes.get(page)}
91+
sandboxes={sandboxesPage}
8592
onDelete={source === 'currentSandboxes' && this.deleteSandbox}
8693
/>
8794
<Navigation>

packages/app/src/app/pages/Profile/Showcase/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class Showcase extends React.Component {
3535
return (
3636
<Centered vertical horizontal>
3737
<Margin top={4}>
38-
<ErrorTitle>This user doesn{"'"}t have a sandbox yet</ErrorTitle>
38+
<ErrorTitle>
39+
{isCurrentUser ? "You don't" : "This user doesn't"} have any
40+
sandboxes yet
41+
</ErrorTitle>
3942
</Margin>
4043
</Centered>
4144
);

0 commit comments

Comments
 (0)