Skip to content

Commit ce329b3

Browse files
committed
Add in a button to save scratch projects
This is a quick way to add it so we can that the save urls are configured correctly in different environment, we've written a separate issue to implement a save button
1 parent 2ab2177 commit ce329b3

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/components/ProjectBar/ProjectBar.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ const ProjectBar = ({ nameEditable = true }) => {
2121
const projectOwner = isOwner(user, project);
2222
const readOnly = useSelector((state) => state.editor.readOnly);
2323

24+
const saveScratchProject = () => {
25+
const webComponent = document.querySelector("editor-wc");
26+
webComponent.shadowRoot
27+
.querySelector("iframe[title='Scratch']")
28+
.contentWindow.postMessage(
29+
{ type: "scratch-gui-save" },
30+
process.env.ASSETS_URL,
31+
);
32+
};
33+
2434
return (
2535
loading === "success" && (
2636
<div className="project-bar">
@@ -43,6 +53,14 @@ const ProjectBar = ({ nameEditable = true }) => {
4353
<SaveButton className="project-bar__btn btn--save" />
4454
</div>
4555
)}
56+
{project.project_type === "code_editor_scratch" && (
57+
<button
58+
className="project-bar__btn btn--save"
59+
onClick={saveScratchProject}
60+
>
61+
Save
62+
</button>
63+
)}
4664
{lastSavedTime && user && !readOnly && (
4765
<SaveStatus saving={saving} lastSavedTime={lastSavedTime} />
4866
)}

0 commit comments

Comments
 (0)