From 7532cab20b0f086bdb351278f0c09289183cf913 Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Wed, 30 Dec 2020 09:20:26 +1100 Subject: [PATCH 1/4] Make start hacking button link to draft --- .../LandingSection/LandingSection.js | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/web/src/components/LandingSection/LandingSection.js b/web/src/components/LandingSection/LandingSection.js index 4dcd5f5..0156516 100644 --- a/web/src/components/LandingSection/LandingSection.js +++ b/web/src/components/LandingSection/LandingSection.js @@ -7,19 +7,12 @@ import { } from './mockEditorParts' import Svg from 'src/components/Svg' import OutBound from 'src/components/OutBound' -import ReactGA from 'react-ga' import LoginModal from 'src/components/LoginModal' import { useState } from 'react' +import { routes, Link } from '@redwoodjs/router' const LandingSection = () => { const [isLoginModalOpen, setIsLoginModalOpen] = useState(false) - const recordedLogin = async () => { - ReactGA.event({ - category: 'login', - action: 'landing section CTA', - }) - setIsLoginModalOpen(true) - } return (
@@ -163,14 +156,13 @@ const LandingSection = () => { {' '} with more integrations coming soon.

- + +
+ + Start Hacking Now + +
+
-- 2.39.5 From 8a87ddf0957e9b56ac2a085d2f10efaa90e58dbd Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Wed, 30 Dec 2020 11:14:00 +1100 Subject: [PATCH 2/4] Make title save able from draft --- web/src/components/IdeToolbar/IdeToolbar.js | 77 +++++++++++++++------ 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/web/src/components/IdeToolbar/IdeToolbar.js b/web/src/components/IdeToolbar/IdeToolbar.js index c9fd12c..f923188 100644 --- a/web/src/components/IdeToolbar/IdeToolbar.js +++ b/web/src/components/IdeToolbar/IdeToolbar.js @@ -26,21 +26,10 @@ const IdeToolbar = ({ const [isLoginModalOpen, setIsLoginModalOpen] = useState(false) const { isAuthenticated, currentUser } = useAuth() const showForkButton = !(canEdit || isDraft) + const [title, setTitle] = useState('untitled-part') const { addMessage } = useFlash() - const [forkPart] = useMutation(FORK_PART_MUTATION, { - onCompleted: ({ forkPart }) => { - navigate( - routes.ide({ - userName: forkPart?.user?.userName, - partTitle: forkPart?.title, - }) - ) - addMessage(`Part created with title: ${forkPart?.title}.`, { - classes: 'rw-flash-success', - }) - }, - }) + const [forkPart] = useMutation(FORK_PART_MUTATION) const handleClick = ({ event, whichPopup }) => { setAnchorEl(event.currentTarget) @@ -52,21 +41,42 @@ const IdeToolbar = ({ setWhichPopup(null) } - const handleSave = () => { - if (isDraft && isAuthenticated) - forkPart({ - variables: { - input: { - userId: currentUser.sub, - title: 'draft', - code, - }, + const saveFork = () => + forkPart({ + variables: { + input: { + userId: currentUser.sub, + title, + code, }, + }, + }) + + const handleSave = async () => { + if (isDraft && isAuthenticated) { + const { data } = await saveFork() + navigate( + routes.ide({ + userName: data?.forkPart?.user?.userName, + partTitle: data?.forkPart?.title, + }) + ) + addMessage(`Part created with title: ${data?.forkPart?.title}.`, { + classes: 'rw-flash-success', }) - else if (isAuthenticated) onSave() + } else if (isAuthenticated) onSave() else recordedLogin() } + const handleSaveAndEdit = async () => { + const { data } = await saveFork() + const { + user: { userName }, + title: partTitle, + } = data?.forkPart || { user: {} } + navigate(routes.part({ userName, partTitle })) + } + const recordedLogin = async () => { ReactGA.event({ category: 'login', @@ -135,6 +145,27 @@ const IdeToolbar = ({ )} + {isDraft && ( +
+ +
title:
+ + setTitle(target?.value.replace(/([^a-zA-Z\d_:])/g, '-')) + } + /> +
+
+ )}
+ {isEditable && ( + + )} - {isDraft && ( + {isDraft && isAuthenticated && (