Skip to content

Commit e787067

Browse files
SaraVieiraCompuIves
authored andcommitted
Show Template Banner and name for not owned sandboxes (codesandbox#2132)
* show sandbox name at the top * remove unused * remove inline css
1 parent 16b1bd5 commit e787067

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { HeaderProps } from './types';
3232

3333
export const Header = observer(({ zenMode }: HeaderProps) => {
3434
const store = useStore();
35-
const sandbox = store.editor.currentSandbox;
3635
const vscode = store.preferences.settings.experimentVSCode;
3736

3837
return (
@@ -49,11 +48,9 @@ export const Header = observer(({ zenMode }: HeaderProps) => {
4948
{vscode ? <MenuBar /> : <SaveAllButton />}
5049
</Left>
5150

52-
{sandbox.owned && (
53-
<Centered>
54-
<SandboxName />
55-
</Centered>
56-
)}
51+
<Centered>
52+
<SandboxName />
53+
</Centered>
5754

5855
<Right>
5956
{store.updateStatus === 'available' && <RefreshButton />}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ export const SandboxName = observer(() => {
8080
opacity: updatingName ? 0 : 1,
8181
pointerEvents: updatingName ? 'none' : 'initial',
8282
});
83+
const { customTemplate, owned } = currentSandbox;
8384

8485
return (
8586
<Main>
8687
<Container>
87-
{!currentSandbox.customTemplate && (
88+
{!customTemplate && owned && (
8889
<animated.div style={spring}>
8990
<Folder>
9091
{isLoggedIn ? (
@@ -117,7 +118,9 @@ export const SandboxName = observer(() => {
117118
/>
118119
</Form>
119120
) : (
120-
<Name onClick={handleNameClick}>{sandboxName}</Name>
121+
<Name owned={owned} onClick={owned ? handleNameClick : null}>
122+
{sandboxName}
123+
</Name>
121124
)}
122125
{template ? (
123126
<Tooltip
@@ -134,9 +137,7 @@ export const SandboxName = observer(() => {
134137
</>
135138
}
136139
>
137-
<TemplateBadge color={currentSandbox.customTemplate.color}>
138-
Template
139-
</TemplateBadge>
140+
<TemplateBadge color={customTemplate.color}>Template</TemplateBadge>
140141
</Tooltip>
141142
) : null}
142143
</Container>

packages/app/src/app/pages/Sandbox/Editor/Header/SandboxName/elements.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ export const NameInput = styled(AutosizeInput)`
5959
}
6060
`;
6161

62-
export const Name = styled.span`
63-
${({ theme }) => css`
62+
export const Name = styled.span<{ owned?: boolean }>`
63+
${({ theme, owned }) => css`
6464
color: ${theme.light ? 'black' : 'white'};
6565
margin-left: 0.25rem;
66-
cursor: pointer;
66+
cursor: ${owned ? 'pointer' : 'initial'};
6767
text-overflow: ellipsis;
6868
`}
6969
`;

packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/Project.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const Project = observer(({ editable }: IProjectProps) => {
114114
</PrivacyContainer>
115115
</PropertyValue>
116116
</Item>
117-
{!isPatron && (
117+
{!isPatron && editable && (
118118
<Explanation style={{ marginTop: '-1rem' }}>
119119
You can change privacy of a sandbox as a{' '}
120120
<a href={patronUrl()} target="_blank">

0 commit comments

Comments
 (0)