Skip to content

Commit 9bbc89b

Browse files
rabingaireSaraVieira
authored andcommitted
codesandbox#1719 Pick Sandbox is now shown at header when user is a curator (codesandbox#1723)
* codesandbox#1719 Pick Sandbox is now shown at header when user is a curator * Added null check and refactored code
1 parent 75f1676 commit 9bbc89b

File tree

1 file changed

+35
-0
lines changed
  • packages/app/src/app/pages/Sandbox/Editor/Header

1 file changed

+35
-0
lines changed

packages/app/src/app/pages/Sandbox/Editor/Header/index.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,29 @@ const ForkButton = ({
9191
</Button>
9292
);
9393

94+
const PickButton = ({ store, signals, secondary, style }: ButtonProps) => {
95+
const { id, title, description } = store.editor.currentSandbox;
96+
97+
return (
98+
<Button
99+
onClick={() => {
100+
signals.explore.pickSandboxModal({
101+
details: {
102+
id,
103+
title,
104+
description,
105+
},
106+
});
107+
}}
108+
style={style}
109+
secondary={secondary}
110+
small
111+
>
112+
Pick
113+
</Button>
114+
);
115+
};
116+
94117
const ShareButton = ({ signals, secondary, style }: ButtonProps) => (
95118
<Button
96119
onClick={() => {
@@ -217,12 +240,24 @@ const Header = ({ store, signals, zenMode }: Props) => {
217240
likeCount={store.editor.currentSandbox.likeCount}
218241
/>
219242
)}
243+
244+
{store.user &&
245+
store.user.curatorAt && (
246+
<PickButton
247+
style={{ fontSize: '.75rem' }}
248+
secondary={sandbox.owned}
249+
signals={signals}
250+
store={store}
251+
/>
252+
)}
253+
220254
<ShareButton
221255
style={{ fontSize: '.75rem', margin: '0 1rem' }}
222256
signals={signals}
223257
secondary={!sandbox.owned}
224258
store={store}
225259
/>
260+
226261
<ForkButton
227262
secondary={sandbox.owned}
228263
isForking={store.editor.isForkingSandbox}

0 commit comments

Comments
 (0)