Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 50 additions & 53 deletions packages/app/src/app/pages/Profile/Showcase/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { inject, observer } from 'app/componentConnectors';

import Column from '@codesandbox/common/lib/components/flex/Column';
Expand All @@ -11,64 +11,61 @@ import ShowcasePreview from '../../common/ShowcasePreview';

import { ErrorTitle } from './elements';

class Showcase extends React.Component {
openModal = () => {
this.props.signals.profile.selectSandboxClicked();
};

render() {
const { store } = this.props;
const sandbox = store.profile.showcasedSandbox;
const isCurrentUser = store.profile.isProfileCurrentUser;

if (store.profile.isLoadingProfile) {
return (
<Centered vertical horizontal>
<Margin top={4}>
<ErrorTitle>Loading showcased sandbox...</ErrorTitle>
</Margin>
</Centered>
);
}
const Showcase = ({ store, signals }) => {
const sandbox = store.profile.showcasedSandbox;
const isCurrentUser = store.profile.isProfileCurrentUser;

if (!sandbox) {
return (
<Centered vertical horizontal>
<Margin top={4}>
<ErrorTitle>
{isCurrentUser ? "You don't" : "This user doesn't"} have any
sandboxes yet
</ErrorTitle>
</Margin>
</Centered>
);
}
const openModal = () => {
signals.profile.selectSandboxClicked();
};

if (store.profile.isLoadingProfile) {
return (
<Column alignItems="center">
<Margin top={1}>
{isCurrentUser && (
<Button small onClick={this.openModal}>
Change Sandbox
</Button>
)}
<Centered vertical horizontal>
<Margin top={4}>
<ErrorTitle>Loading showcased sandbox...</ErrorTitle>
</Margin>
<Margin top={2} style={{ width: '100%' }}>
<Column alignItems="initial">
<div style={{ flex: 2 }}>
<ShowcasePreview
sandbox={sandbox}
settings={this.props.store.preferences.settings}
/>
</div>
<div style={{ flex: 1 }}>
<SandboxInfo sandbox={sandbox} />
</div>
</Column>
</Centered>
);
}

if (!sandbox) {
return (
<Centered vertical horizontal>
<Margin top={4}>
<ErrorTitle>
{isCurrentUser ? "You don't" : "This user doesn't"} have any
sandboxes yet
</ErrorTitle>
</Margin>
</Column>
</Centered>
);
}
}

return (
<Column alignItems="center">
<Margin top={1}>
{isCurrentUser && (
<Button small onClick={openModal}>
Change Sandbox
</Button>
)}
</Margin>
<Margin top={2} style={{ width: '100%' }}>
<Column alignItems="initial">
<div style={{ flex: 2 }}>
<ShowcasePreview
sandbox={sandbox}
settings={store.preferences.settings}
/>
</div>
<div style={{ flex: 1 }}>
<SandboxInfo sandbox={sandbox} />
</div>
</Column>
</Margin>
</Column>
);
};

export default inject('signals', 'store')(observer(Showcase));
Loading