From 22dc166f4ce4e03dcad5aad2fc1590cb0c7e3466 Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Tue, 17 Nov 2020 04:37:01 +1100 Subject: [PATCH] Clean up after making changes --- README.md | 6 + .../IdeCascadeStudio/IdeCascadeStudio.js | 117 +----------------- web/src/components/IdePartCell/IdePartCell.js | 2 - 3 files changed, 11 insertions(+), 114 deletions(-) diff --git a/README.md b/README.md index 8061bdc..90364ec 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,12 @@ yarn rw db up yarn rw db seed ``` +Move some files to the public directory +``` +yarn move-cad-worker +``` +The above step should be repeated whenever you modify anything in the git submodule `web/src/cascade/*` + ### Fire up dev ```terminal yarn rw dev diff --git a/web/src/components/IdeCascadeStudio/IdeCascadeStudio.js b/web/src/components/IdeCascadeStudio/IdeCascadeStudio.js index bac37fe..9b815fc 100644 --- a/web/src/components/IdeCascadeStudio/IdeCascadeStudio.js +++ b/web/src/components/IdeCascadeStudio/IdeCascadeStudio.js @@ -1,18 +1,9 @@ -import { useMutation, useFlash } from '@redwoodjs/web' import { useAuth } from '@redwoodjs/auth' -import { Link, routes, navigate } from '@redwoodjs/router' -import { initialize } from 'src/cascade/js/MainPage/CascadeMain' +import { Link, routes } from '@redwoodjs/router' import CascadeController from 'src/helpers/cascadeController' import IdeToolbar from 'src/components/IdeToolbar' import { useEffect, useState } from 'react' -const DELETE_PART_MUTATION = gql` - mutation DeletePartMutation($id: Int!) { - deletePart(id: $id) { - id - } - } -` const domNode = document.createElement('div').setAttribute('id', 'sickId') const IdeCascadeStudio = ({ part, saveCode, loading, error }) => { @@ -20,6 +11,9 @@ const IdeCascadeStudio = ({ part, saveCode, loading, error }) => { const { currentUser } = useAuth() const canEdit = currentUser?.sub === part?.user?.id useEffect(() => { + // Cascade studio attaches "cascade-container" a div outside the react app in 'web/src/index.html', and so we are + // "opening" and "closing" it for the ide part of the app by displaying none or block. Which is why this useEffect + // returns a clean up function that hides the div again. const onCodeChange = (code) => setCode(code) CascadeController.initialise(onCodeChange, part.code, domNode) const element = document.getElementById('cascade-container') @@ -27,35 +21,11 @@ const IdeCascadeStudio = ({ part, saveCode, loading, error }) => { return () => { element.setAttribute('style', 'display: none; overflow: hidden; height: calc(100vh - 8rem)') // eslint-disable-line } - }, []) + }, [part.code]) const isChanges = code !== part.code - const { addMessage } = useFlash() - const [deletePart] = useMutation(DELETE_PART_MUTATION, { - onCompleted: () => { - // navigate(routes.parts()) - addMessage('Part deleted.', { classes: 'rw-flash-success' }) - }, - }) - - const onDeleteClick = (id) => { - if (confirm('Are you sure you want to delete part ' + id + '?')) { - deletePart({ variables: { id } }) - } - } return ( <> -
{ }} onExport={(type) => threejsViewport[`saveShape${type}`]()} /> - - {/*
*/}
) diff --git a/web/src/components/IdePartCell/IdePartCell.js b/web/src/components/IdePartCell/IdePartCell.js index de8da61..a0fb71b 100644 --- a/web/src/components/IdePartCell/IdePartCell.js +++ b/web/src/components/IdePartCell/IdePartCell.js @@ -1,7 +1,6 @@ import { useMutation, useFlash } from '@redwoodjs/web' import { navigate, routes } from '@redwoodjs/router' import IdeCascadeStudio from 'src/components/IdeCascadeStudio' -// import Part from 'src/components/Part'a export const QUERY = gql` query FIND_PART_BY_USENAME_TITLE($partTitle: String!, $userName: String!) { @@ -46,7 +45,6 @@ export const Success = ({ part, refetch }) => { const { addMessage } = useFlash() const [updatePart, { loading, error }] = useMutation(UPDATE_PART_MUTATION, { onCompleted: () => { - // navigate(routes.part({id: updatePart.id})) addMessage('Part updated.', { classes: 'rw-flash-success' }) }, })