From e67b315df4610719666487e943c8dedcca6a154d Mon Sep 17 00:00:00 2001 From: shinytang6 <1074461480@qq.com> Date: Wed, 21 Feb 2018 20:52:22 +0800 Subject: [PATCH 1/5] enhance saving --- client/modules/IDE/components/ErrorModal.jsx | 10 ++++++++++ client/modules/IDE/pages/IDEView.jsx | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/client/modules/IDE/components/ErrorModal.jsx b/client/modules/IDE/components/ErrorModal.jsx index 6f264658cd..a463501af7 100644 --- a/client/modules/IDE/components/ErrorModal.jsx +++ b/client/modules/IDE/components/ErrorModal.jsx @@ -14,6 +14,14 @@ class ErrorModal extends React.Component { ); } + unauthorizedProject() { + return ( +
+ You have no access to save the sketch. +
+ ); + } + staleSession() { return (@@ -41,6 +49,8 @@ class ErrorModal extends React.Component { return this.staleSession(); } else if (this.props.type === 'staleProject') { return this.staleProject(); + } else if (this.props.type === 'unauthorizedProject') { + return this.unauthorizedProject(); } })()} diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index b7f6a51149..3597f42a68 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -156,8 +156,13 @@ class IDEView extends React.Component { if (e.keyCode === 83 && ((e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac))) { e.preventDefault(); e.stopPropagation(); - if (this.isUserOwner() || (this.props.user.authenticated && !this.props.project.owner)) { + console.log(this.isUserOwner()); + if (this.isUserOwner()) { this.props.saveProject(); + } else if (this.props.user.authenticated) { + this.props.showErrorModal('unauthorizedProject'); + } else { + this.props.showErrorModal('forceAuthentication'); } // 13 === enter } else if (e.keyCode === 13 && e.shiftKey && ((e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac))) { From 101abae68509384ba4bd09cf3f2fcbd2d885e9f1 Mon Sep 17 00:00:00 2001 From: shinytang6 <1074461480@qq.com> Date: Wed, 21 Feb 2018 20:59:54 +0800 Subject: [PATCH 2/5] remove console --- client/modules/IDE/pages/IDEView.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx index 3597f42a68..2004a7f869 100644 --- a/client/modules/IDE/pages/IDEView.jsx +++ b/client/modules/IDE/pages/IDEView.jsx @@ -156,7 +156,6 @@ class IDEView extends React.Component { if (e.keyCode === 83 && ((e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac))) { e.preventDefault(); e.stopPropagation(); - console.log(this.isUserOwner()); if (this.isUserOwner()) { this.props.saveProject(); } else if (this.props.user.authenticated) { From d0e34b158488bc860ab648911d2399d9235195f4 Mon Sep 17 00:00:00 2001 From: shinytang6 <1074461480@qq.com> Date: Wed, 21 Feb 2018 21:06:46 +0800 Subject: [PATCH 3/5] rename --- client/modules/IDE/components/ErrorModal.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/modules/IDE/components/ErrorModal.jsx b/client/modules/IDE/components/ErrorModal.jsx index a463501af7..1f58de5fdd 100644 --- a/client/modules/IDE/components/ErrorModal.jsx +++ b/client/modules/IDE/components/ErrorModal.jsx @@ -17,7 +17,7 @@ class ErrorModal extends React.Component { unauthorizedProject() { return (
- You have no access to save the sketch. + You have no access to save the project.
); } From 0d4123e3e8c53b452eb112b5b1c037b4bff44a51 Mon Sep 17 00:00:00 2001 From: shinytang6 <1074461480@qq.com> Date: Thu, 22 Feb 2018 23:44:47 +0800 Subject: [PATCH 4/5] duplicate when saving others' projects --- client/modules/IDE/components/ErrorModal.jsx | 10 ---------- client/modules/IDE/pages/IDEView.jsx | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/client/modules/IDE/components/ErrorModal.jsx b/client/modules/IDE/components/ErrorModal.jsx index 1f58de5fdd..6f264658cd 100644 --- a/client/modules/IDE/components/ErrorModal.jsx +++ b/client/modules/IDE/components/ErrorModal.jsx @@ -14,14 +14,6 @@ class ErrorModal extends React.Component { ); } - unauthorizedProject() { - return ( -- You have no access to save the project. -
- ); - } - staleSession() { return (
@@ -49,8 +41,6 @@ class ErrorModal extends React.Component {
return this.staleSession();
} else if (this.props.type === 'staleProject') {
return this.staleProject();
- } else if (this.props.type === 'unauthorizedProject') {
- return this.unauthorizedProject();
}
})()}
diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx
index 2004a7f869..1f5629adb9 100644
--- a/client/modules/IDE/pages/IDEView.jsx
+++ b/client/modules/IDE/pages/IDEView.jsx
@@ -156,10 +156,10 @@ class IDEView extends React.Component {
if (e.keyCode === 83 && ((e.metaKey && this.isMac) || (e.ctrlKey && !this.isMac))) {
e.preventDefault();
e.stopPropagation();
- if (this.isUserOwner()) {
+ if (this.isUserOwner() || (this.props.user.authenticated && !this.props.project.owner)) {
this.props.saveProject();
} else if (this.props.user.authenticated) {
- this.props.showErrorModal('unauthorizedProject');
+ this.props.cloneProject();
} else {
this.props.showErrorModal('forceAuthentication');
}
From 6902ff66c8be996a84bf0242b5cce9e34d699c12 Mon Sep 17 00:00:00 2001
From: shinytang6 <1074461480@qq.com>
Date: Fri, 23 Feb 2018 16:45:00 +0800
Subject: [PATCH 5/5] fix a bug
---
client/modules/IDE/pages/IDEView.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/modules/IDE/pages/IDEView.jsx b/client/modules/IDE/pages/IDEView.jsx
index 1f5629adb9..eb41229f00 100644
--- a/client/modules/IDE/pages/IDEView.jsx
+++ b/client/modules/IDE/pages/IDEView.jsx
@@ -497,10 +497,10 @@ class IDEView extends React.Component {