Skip to content

Commit ca3d2d2

Browse files
authored
Render blank screen if project is a scratch project (#1210)
Stop Scratch projects being displayed
1 parent 507187b commit ca3d2d2

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010

1111
- Fake translation for stress testing (#1206)
1212

13+
### Changed
14+
15+
- Prevent the Scratch projects from being displayed (#1210)
16+
1317
### Fixed
18+
1419
- Styling issue on sidebar on mobile (#1194)
1520

1621
## [0.30.0] - 2025-04-15

src/components/WebComponentProject/WebComponentProject.jsx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const WebComponentProject = ({
4141
const projectIdentifier = useSelector(
4242
(state) => state.editor.project.identifier,
4343
);
44+
const isScratchProject = project.project_type === "scratch";
4445
const codeRunTriggered = useSelector(
4546
(state) => state.editor.codeRunTriggered,
4647
);
@@ -137,24 +138,28 @@ const WebComponentProject = ({
137138

138139
return (
139140
<>
140-
{!outputOnly &&
141-
(isMobile ? (
142-
<MobileProject
143-
withSidebar={withSidebar}
144-
sidebarOptions={sidebarOptions}
145-
/>
146-
) : (
147-
<Project
148-
nameEditable={nameEditable}
149-
withProjectbar={withProjectbar}
150-
withSidebar={withSidebar}
151-
sidebarOptions={sidebarOptions}
152-
/>
153-
))}
154-
{outputOnly && (
155-
<div className="embedded-viewer" data-testid="output-only">
156-
{loading === "success" && <Output outputPanels={outputPanels} />}
157-
</div>
141+
{!isScratchProject && (
142+
<>
143+
{!outputOnly &&
144+
(isMobile ? (
145+
<MobileProject
146+
withSidebar={withSidebar}
147+
sidebarOptions={sidebarOptions}
148+
/>
149+
) : (
150+
<Project
151+
nameEditable={nameEditable}
152+
withProjectbar={withProjectbar}
153+
withSidebar={withSidebar}
154+
sidebarOptions={sidebarOptions}
155+
/>
156+
))}
157+
{outputOnly && (
158+
<div className="embedded-viewer" data-testid="output-only">
159+
{loading === "success" && <Output outputPanels={outputPanels} />}
160+
</div>
161+
)}
162+
</>
158163
)}
159164
</>
160165
);

src/components/WebComponentProject/WebComponentProject.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jest.useFakeTimers();
2121
let store;
2222

2323
const renderWebComponentProject = ({
24+
projectType,
2425
instructions,
2526
permitOverride = true,
2627
loading,
@@ -33,6 +34,7 @@ const renderWebComponentProject = ({
3334
const initialState = {
3435
editor: {
3536
project: {
37+
project_type: projectType,
3638
components: [
3739
{ name: "main", extension: "py", content: "print('hello')" },
3840
],
@@ -68,6 +70,10 @@ describe("When state set", () => {
6870
});
6971
});
7072

73+
test("Renders", () => {
74+
expect(screen.queryAllByText("output.textOutput")[0]).toBeInTheDocument();
75+
});
76+
7177
test("Triggers codeChanged event", () => {
7278
act(() => {
7379
jest.runAllTimers();
@@ -114,6 +120,18 @@ describe("When state set", () => {
114120
});
115121
});
116122

123+
describe("When project type is scratch", () => {
124+
beforeEach(() => {
125+
renderWebComponentProject({
126+
projectType: "scratch",
127+
});
128+
});
129+
130+
test("Renders a blank screen", () => {
131+
expect(screen.queryByText("output.textOutput")).not.toBeInTheDocument();
132+
});
133+
});
134+
117135
describe("When there are instructions", () => {
118136
beforeEach(() => {
119137
renderWebComponentProject({

src/web-component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class WebComponent extends HTMLElement {
113113

114114
get editorCode() {
115115
const state = store.getState();
116-
return state.editor.project.components[0].content;
116+
return state.editor.project.components[0]?.content;
117117
}
118118

119119
get menuItems() {

0 commit comments

Comments
 (0)