From db9a703def0ac6455f24b5ad8903d44c3b4112ce Mon Sep 17 00:00:00 2001 From: josephmwells Date: Mon, 3 Aug 2020 11:40:48 -0700 Subject: [PATCH 01/17] Add character limit to sketch name on the back end #568 --- server/controllers/project.controller/createProject.js | 3 ++- server/models/project.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/controllers/project.controller/createProject.js b/server/controllers/project.controller/createProject.js index e4040268..3c12fd37 100644 --- a/server/controllers/project.controller/createProject.js +++ b/server/controllers/project.controller/createProject.js @@ -8,8 +8,9 @@ export default function createProject(req, res) { projectValues = Object.assign(projectValues, req.body); + // TODO: Error handling to match spec function sendFailure() { - res.json({ success: false }); + res.status(422).json({ success: false }); } function populateUserData(newProject) { diff --git a/server/models/project.js b/server/models/project.js index bf8c992e..98f83d92 100644 --- a/server/models/project.js +++ b/server/models/project.js @@ -29,7 +29,7 @@ fileSchema.set('toJSON', { const projectSchema = new Schema( { - name: { type: String, default: "Hello p5.js, it's the server" }, + name: { type: String, default: "Hello p5.js, it's the server", maxlength: 256 }, user: { type: Schema.Types.ObjectId, ref: 'User' }, serveSecure: { type: Boolean, default: false }, files: { type: [fileSchema] }, From 76bcf9cb097285495b2a8c22a68cc7f06e0c0d2f Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Mon, 3 Aug 2020 16:42:28 -0400 Subject: [PATCH 02/17] [#1529] Send status codes, run validator --- server/controllers/project.controller.js | 7 ++++--- server/controllers/project.controller/createProject.js | 3 +-- server/models/project.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/controllers/project.controller.js b/server/controllers/project.controller.js index 7f118c23..2a83aa6a 100644 --- a/server/controllers/project.controller.js +++ b/server/controllers/project.controller.js @@ -30,14 +30,15 @@ export function updateProject(req, res) { $set: req.body }, { - new: true + new: true, + runValidators: true } ) .populate('user', 'username') .exec((updateProjectErr, updatedProject) => { if (updateProjectErr) { console.log(updateProjectErr); - res.json({ success: false }); + res.status(400).json({ success: false }); return; } if (req.body.files && updatedProject.files.length !== req.body.files.length) { @@ -50,7 +51,7 @@ export function updateProject(req, res) { updatedProject.save((innerErr, savedProject) => { if (innerErr) { console.log(innerErr); - res.json({ success: false }); + res.status(400).json({ success: false }); return; } res.json(savedProject); diff --git a/server/controllers/project.controller/createProject.js b/server/controllers/project.controller/createProject.js index 3c12fd37..74529c0d 100644 --- a/server/controllers/project.controller/createProject.js +++ b/server/controllers/project.controller/createProject.js @@ -8,9 +8,8 @@ export default function createProject(req, res) { projectValues = Object.assign(projectValues, req.body); - // TODO: Error handling to match spec function sendFailure() { - res.status(422).json({ success: false }); + res.status(400).json({ success: false }); } function populateUserData(newProject) { diff --git a/server/models/project.js b/server/models/project.js index 98f83d92..3581e998 100644 --- a/server/models/project.js +++ b/server/models/project.js @@ -29,7 +29,7 @@ fileSchema.set('toJSON', { const projectSchema = new Schema( { - name: { type: String, default: "Hello p5.js, it's the server", maxlength: 256 }, + name: { type: String, default: "Hello p5.js, it's the server", maxlength: 128 }, user: { type: Schema.Types.ObjectId, ref: 'User' }, serveSecure: { type: Boolean, default: false }, files: { type: [fileSchema] }, From 6827983adcfd19b70dba9e42018c95a99b29e930 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Thu, 6 Aug 2020 12:47:07 -0400 Subject: [PATCH 03/17] 1.0.7 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04592b99..8abec584 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "p5.js-web-editor", - "version": "1.0.6", + "version": "1.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ba2680a8..01f558f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p5.js-web-editor", - "version": "1.0.6", + "version": "1.0.7", "description": "The web editor for p5.js.", "scripts": { "clean": "rimraf dist", From 7558cf5e1ca2dddd771ba5901120f00c0b5376f9 Mon Sep 17 00:00:00 2001 From: ghalestrilo Date: Fri, 7 Aug 2020 19:05:46 -0300 Subject: [PATCH 04/17] :sparkles: make dropdown for sketch and collection creation --- client/modules/Mobile/MobileDashboardView.jsx | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/client/modules/Mobile/MobileDashboardView.jsx b/client/modules/Mobile/MobileDashboardView.jsx index ac4205d2..7cf22939 100644 --- a/client/modules/Mobile/MobileDashboardView.jsx +++ b/client/modules/Mobile/MobileDashboardView.jsx @@ -7,7 +7,7 @@ import { withRouter, Link } from 'react-router'; import Screen from '../../components/mobile/MobileScreen'; import Header from '../../components/mobile/Header'; import IconButton from '../../components/mobile/IconButton'; -import { ExitIcon } from '../../common/icons'; +import { ExitIcon, MoreIcon } from '../../common/icons'; import Footer from '../../components/mobile/Footer'; import { prop, remSize } from '../../theme'; import SketchList from '../IDE/components/SketchList'; @@ -16,6 +16,8 @@ import AssetList from '../IDE/components/AssetList'; import Content from './MobileViewContent'; import { SketchSearchbar, CollectionSearchbar } from '../IDE/components/Searchbar'; import Button from '../../common/Button'; +import useAsModal from '../../components/useAsModal'; +import Dropdown from '../../components/Dropdown'; const EXAMPLE_USERNAME = 'p5'; @@ -94,10 +96,11 @@ const Panels = { assets: AssetList }; -const CreatePathname = { - sketches: '/mobile', - collections: '/mobile/:username/collections/create', -}; + +const navOptions = username => [ + { title: 'Create Sketch', href: '/mobile' }, + { title: 'Create Collection', href: `/mobile/${username}/collections/create` } +]; const getPanel = (pathname) => { @@ -106,7 +109,10 @@ const getPanel = (pathname) => { return matches && matches.length > 0 && matches[0]; }; -const getCreatePathname = (panel, username) => (CreatePathname[panel] || '#').replace(':username', username); +const NavItem = styled.li` + position: relative; +`; + const isOwner = (user, params) => user && params && user.username === params.username; @@ -114,27 +120,41 @@ const renderPanel = (name, props) => (Component => (Component && { const user = useSelector(state => state.user); - const { username } = params; + const { username: paramsUsername } = params; const { pathname } = location; const Tabs = Object.keys(Panels); - const isExamples = username === EXAMPLE_USERNAME; + const isExamples = paramsUsername === EXAMPLE_USERNAME; const panel = getPanel(pathname); + + const [toggleNavDropdown, NavDropdown] = useAsModal(); + return (
+ + + + +
- {isOwner(user, params) && (panel !== Tabs[2]) && new} {panel === Tabs[0] && } {panel === Tabs[1] && } - {renderPanel(panel, { username, key: pathname })} + {renderPanel(panel, { paramsUsername, key: pathname })}