Skip to content

Commit 64bdb22

Browse files
committed
Merge branch 'feat/privatesketch' of https://github.com/vivekbopaliya/p5.js-web-editor into feat/privatesketch
2 parents dfb7797 + 0ba7467 commit 64bdb22

File tree

16 files changed

+117
-63
lines changed

16 files changed

+117
-63
lines changed

client/modules/IDE/components/Editor/MobileEditor.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const EditorContainer = styled.div`
99
transform: ${(props) =>
1010
props.expanded ? 'translateX(50%)' : 'translateX(0)'};
1111
12-
> header {
12+
> div {
1313
display: flex;
1414
${prop('MobilePanel.secondary')}
1515
> span {

client/modules/IDE/components/Editor/index.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ class Editor extends React.Component {
208208
if (/^[a-z]$/i.test(e.key) && (mode === 'css' || mode === 'javascript')) {
209209
this.showHint(_cm);
210210
}
211+
if (e.key === 'Escape') {
212+
e.preventDefault();
213+
this._cm.getInputField().blur();
214+
}
211215
});
212216

213217
this._cm.getWrapperElement().style[
@@ -513,7 +517,7 @@ class Editor extends React.Component {
513517
{(matches) =>
514518
matches ? (
515519
<section className={editorSectionClass}>
516-
<header className="editor__header">
520+
<div className="editor__header">
517521
<button
518522
aria-label={this.props.t('Editor.OpenSketchARIA')}
519523
className="sidebar__contract"
@@ -538,7 +542,7 @@ class Editor extends React.Component {
538542
</span>
539543
<Timer />
540544
</div>
541-
</header>
545+
</div>
542546
<article
543547
ref={(element) => {
544548
this.codemirrorContainer = element;
@@ -555,7 +559,7 @@ class Editor extends React.Component {
555559
</section>
556560
) : (
557561
<EditorContainer expanded={this.props.isExpanded}>
558-
<header>
562+
<>
559563
<IconButton
560564
onClick={this.props.expandSidebar}
561565
icon={FolderIcon}
@@ -564,7 +568,7 @@ class Editor extends React.Component {
564568
{this.props.file.name}
565569
<UnsavedChangesIndicator />
566570
</span>
567-
</header>
571+
</>
568572
<section>
569573
<EditorHolder
570574
ref={(element) => {

client/modules/IDE/components/Header/Nav.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ const UnauthenticatedUserMenu = () => {
270270
</span>
271271
</Link>
272272
</li>
273-
<span className="nav__item-or">{t('Nav.LoginOr')}</span>
273+
<li className="nav__item-or">{t('Nav.LoginOr')}</li>
274274
<li className="nav__item">
275275
<Link to="/signup" className="nav__auth-button">
276276
<span className="nav__item-header" title="SignUp">

client/modules/IDE/components/Header/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const Header = (props) => {
1212
const isMobile = useIsMobile();
1313

1414
return (
15-
<header>
15+
<>
1616
<Nav />
1717
{!isMobile && (
1818
<Toolbar syncFileContent={props.syncFileContent} key={project.id} />
1919
)}
20-
</header>
20+
</>
2121
);
2222
};
2323

client/modules/IDE/hooks/useSketchActions.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const useSketchActions = () => {
1616
const unsavedChanges = useSelector((state) => state.ide.unsavedChanges);
1717
const authenticated = useSelector((state) => state.user.authenticated);
1818
const project = useSelector((state) => state.project);
19+
const user = useSelector((state) => state.user);
1920
const canEditProjectName = useSelector(selectCanEditSketch);
2021
const dispatch = useDispatch();
2122
const { t } = useTranslation();
@@ -40,8 +41,10 @@ const useSketchActions = () => {
4041
}
4142

4243
function downloadSketch() {
43-
dispatch(autosaveProject());
44-
exportProjectAsZip(project.id);
44+
if (authenticated && user.id === project.owner.id) {
45+
dispatch(autosaveProject());
46+
exportProjectAsZip(project.id);
47+
}
4548
}
4649

4750
function shareSketch() {

kubernetes_app.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ spec:
6565
selector:
6666
matchLabels:
6767
app: web-editor
68-
replicas: 3
68+
replicas: 4
6969
template:
7070
metadata:
7171
labels:
@@ -99,8 +99,8 @@ metadata:
9999
name: web-editor-node
100100
namespace: production
101101
spec:
102-
maxReplicas: 6
103-
minReplicas: 2
102+
maxReplicas: 9
103+
minReplicas: 3
104104
scaleTargetRef:
105105
apiVersion: extensions/v1beta1
106106
kind: Deployment

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p5.js-web-editor",
3-
"version": "2.12.10",
3+
"version": "2.12.14",
44
"description": "The web editor for p5.js.",
55
"scripts": {
66
"clean": "rimraf dist",

server/controllers/aws.controller.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ export async function deleteObjectsFromS3(keyList) {
5252
try {
5353
await s3Client.send(new DeleteObjectsCommand(params));
5454
} catch (error) {
55-
if (error.name === 'NotFound') {
56-
console.log('Object does not exist:', error);
57-
} else {
58-
console.error('Error deleting objects from S3: ', error);
55+
if (error instanceof TypeError) {
56+
return null;
5957
}
58+
console.error('Error deleting objects from S3: ', error);
59+
throw error;
6060
}
6161
}
62+
63+
return objectsToDelete;
6264
}
6365

6466
export async function deleteObjectFromS3(req, res) {
@@ -110,12 +112,12 @@ export async function copyObjectInS3(url, userId) {
110112
try {
111113
await s3Client.send(new HeadObjectCommand(headParams));
112114
} catch (error) {
113-
if (error.name === 'NotFound') {
114-
console.log('Object does not exist:', error);
115-
} else {
116-
console.error('Error fetching object metadata:', error);
117-
throw error;
115+
// temporary error handling for sketches with missing assets
116+
if (error instanceof TypeError) {
117+
return null;
118118
}
119+
console.error('Error retrieving object metadat:', error);
120+
throw error;
119121
}
120122

121123
const params = {
@@ -127,16 +129,16 @@ export async function copyObjectInS3(url, userId) {
127129

128130
try {
129131
await s3Client.send(new CopyObjectCommand(params));
130-
return `${s3Bucket}${userId}/${newFilename}`;
131132
} catch (error) {
132133
// temporary error handling for sketches with missing assets
133-
if (error.startsWith('TypeError')) {
134-
console.log('Object does not exist:', error);
134+
if (error instanceof TypeError) {
135135
return null;
136136
}
137137
console.error('Error copying object:', error);
138138
throw error;
139139
}
140+
141+
return `${s3Bucket}${userId}/${newFilename}`;
140142
}
141143

142144
export async function copyObjectInS3RequestHandler(req, res) {
@@ -227,8 +229,7 @@ export async function listObjectsInS3ForUser(userId) {
227229

228230
return { assets: projectAssets, totalSize };
229231
} catch (error) {
230-
if (error.name === 'NotFound') {
231-
console.log('Object does not exist:', error);
232+
if (error instanceof TypeError) {
232233
return null;
233234
}
234235
console.error('Got an error: ', error);

server/controllers/user.controller.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ export async function updateSettings(req, res) {
295295
}
296296
user.username = req.body.username;
297297

298+
if (req.body.newPassword) {
299+
if (user.password === undefined) {
300+
user.password = req.body.newPassword;
301+
saveUser(res, user);
302+
}
303+
if (!req.body.currentPassword) {
304+
res.status(401).json({ error: 'Current password is not provided.' });
305+
return;
306+
}
307+
}
298308
if (req.body.currentPassword) {
299309
const isMatch = await user.comparePassword(req.body.currentPassword);
300310
if (!isMatch) {

0 commit comments

Comments
 (0)