massive refactor toDrop cascadeStudio and add CadQuery + OpenSCAD
resolves #400
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
import MainLayout from 'src/layouts/MainLayout'
|
||||
import AdminPartsCell from 'src/components/AdminPartsCell'
|
||||
|
||||
const PartsPage = () => {
|
||||
return (
|
||||
<MainLayout>
|
||||
<AdminPartsCell />
|
||||
</MainLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default PartsPage
|
||||
12
app/web/src/pages/AdminProjectsPage/AdminProjectsPage.tsx
Normal file
12
app/web/src/pages/AdminProjectsPage/AdminProjectsPage.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import MainLayout from 'src/layouts/MainLayout/MainLayout'
|
||||
import AdminProjectsCell from 'src/components/AdminProjectsCell'
|
||||
|
||||
const ProjectsPage = () => {
|
||||
return (
|
||||
<MainLayout>
|
||||
<AdminProjectsCell />
|
||||
</MainLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProjectsPage
|
||||
@@ -1,19 +1,16 @@
|
||||
import { createContext } from 'react'
|
||||
import Seo from 'src/components/Seo/Seo'
|
||||
import IdeWrapper from 'src/components/IdeWrapper/IdeWrapper'
|
||||
import { Toaster } from '@redwoodjs/web/toast'
|
||||
import { useIdeState, State, initialState } from 'src/helpers/hooks/useIdeState'
|
||||
import { useIdeState } from 'src/helpers/hooks/useIdeState'
|
||||
import type { Project } from 'src/components/IdeProjectCell/IdeProjectCell'
|
||||
import { IdeContext } from 'src/helpers/hooks/useIdeContext'
|
||||
|
||||
interface IdeContextType {
|
||||
state: State
|
||||
thunkDispatch: (actionOrThunk: any) => any
|
||||
interface Props {
|
||||
cadPackage: string
|
||||
project?: Project
|
||||
}
|
||||
|
||||
export const IdeContext = createContext<IdeContextType>({
|
||||
state: initialState,
|
||||
thunkDispatch: () => {},
|
||||
})
|
||||
const DevIdePage = ({ cadPackage }) => {
|
||||
const DevIdePage = ({ cadPackage, project }: Props) => {
|
||||
const [state, thunkDispatch] = useIdeState()
|
||||
return (
|
||||
<div className="h-screen flex flex-col">
|
||||
@@ -23,7 +20,7 @@ const DevIdePage = ({ cadPackage }) => {
|
||||
lang="en-US"
|
||||
/>
|
||||
<Toaster timeout={9000} />
|
||||
<IdeContext.Provider value={{ state, thunkDispatch }}>
|
||||
<IdeContext.Provider value={{ state, thunkDispatch, project }}>
|
||||
<IdeWrapper cadPackage={cadPackage} />
|
||||
</IdeContext.Provider>
|
||||
</div>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import MainLayout from 'src/layouts/MainLayout'
|
||||
import IdeCascadeStudio from 'src/components/IdeCascadeStudio'
|
||||
import Seo from 'src/components/Seo/Seo'
|
||||
|
||||
const DraftPartPage = () => {
|
||||
return (
|
||||
<MainLayout shouldRemoveFooterInIde>
|
||||
<Seo
|
||||
title="draft part"
|
||||
description="black slate to hack on a new part"
|
||||
lang="en-US"
|
||||
/>
|
||||
<IdeCascadeStudio />
|
||||
</MainLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default DraftPartPage
|
||||
@@ -1,7 +0,0 @@
|
||||
import DraftPartPage from './DraftPartPage'
|
||||
|
||||
export const generated = () => {
|
||||
return <DraftPartPage />
|
||||
}
|
||||
|
||||
export default { title: 'Pages/DraftPartPage' }
|
||||
@@ -0,0 +1,7 @@
|
||||
import DraftProjectPage from './DraftProjectPage'
|
||||
|
||||
export const generated = () => {
|
||||
return <DraftProjectPage />
|
||||
}
|
||||
|
||||
export default { title: 'Pages/DraftProjectPage' }
|
||||
11
app/web/src/pages/DraftProjectPage/DraftProjectPage.test.tsx
Normal file
11
app/web/src/pages/DraftProjectPage/DraftProjectPage.test.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { render } from '@redwoodjs/testing'
|
||||
|
||||
import DraftProjectPage from './DraftProjectPage'
|
||||
|
||||
describe('DraftProjectPage', () => {
|
||||
it('renders successfully', () => {
|
||||
expect(() => {
|
||||
render(<DraftProjectPage />)
|
||||
}).not.toThrow()
|
||||
})
|
||||
})
|
||||
36
app/web/src/pages/DraftProjectPage/DraftProjectPage.tsx
Normal file
36
app/web/src/pages/DraftProjectPage/DraftProjectPage.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { useMutation } from '@redwoodjs/web'
|
||||
import { toast } from '@redwoodjs/web/toast'
|
||||
import { useEffect } from 'react'
|
||||
import { useAuth } from '@redwoodjs/auth'
|
||||
import { navigate, routes } from '@redwoodjs/router'
|
||||
|
||||
import DevIdePage from 'src/pages/DevIdePage/DevIdePage'
|
||||
import useUser from 'src/helpers/hooks/useUser'
|
||||
import { CREATE_PROJECT_MUTATION } from 'src/components/ProjectCell/ProjectCell'
|
||||
|
||||
const DraftProjectPage = ({ cadPackage }: { cadPackage: string }) => {
|
||||
const { isAuthenticated } = useAuth()
|
||||
const { user, loading } = useUser()
|
||||
const [createProject] = useMutation(CREATE_PROJECT_MUTATION, {
|
||||
onCompleted: ({ createProject }) => {
|
||||
navigate(
|
||||
routes.ide({
|
||||
userName: createProject?.user?.userName,
|
||||
projectTitle: createProject?.title,
|
||||
})
|
||||
)
|
||||
toast.success('Project Created.')
|
||||
},
|
||||
})
|
||||
useEffect(() => {
|
||||
if (isAuthenticated && user) {
|
||||
createProject({ variables: { input: { userId: user.id, cadPackage } } })
|
||||
}
|
||||
}, [isAuthenticated, user])
|
||||
if (loading || user?.id) {
|
||||
return <div>loading</div>
|
||||
}
|
||||
return <DevIdePage cadPackage={cadPackage} />
|
||||
}
|
||||
|
||||
export default DraftProjectPage
|
||||
@@ -1,7 +0,0 @@
|
||||
import EditPartPage from './EditPartPage'
|
||||
|
||||
export const generated = () => {
|
||||
return <EditPartPage />
|
||||
}
|
||||
|
||||
export default { title: 'Pages/EditPartPage' }
|
||||
@@ -0,0 +1,7 @@
|
||||
import EditProjectPage from './EditProjectPage'
|
||||
|
||||
export const generated = () => {
|
||||
return <EditProjectPage />
|
||||
}
|
||||
|
||||
export default { title: 'Pages/EditProjectPage' }
|
||||
@@ -1,11 +1,11 @@
|
||||
import { render } from '@redwoodjs/testing'
|
||||
|
||||
import DraftPartPage from './DraftPartPage'
|
||||
import EditProjectPage from './EditProjectPage'
|
||||
|
||||
describe('DraftPartPage', () => {
|
||||
describe('EditProjectPage', () => {
|
||||
it('renders successfully', () => {
|
||||
expect(() => {
|
||||
render(<DraftPartPage />)
|
||||
render(<EditProjectPage />)
|
||||
}).not.toThrow()
|
||||
})
|
||||
})
|
||||
@@ -1,18 +1,18 @@
|
||||
import { useAuth } from '@redwoodjs/auth'
|
||||
|
||||
import MainLayout from 'src/layouts/MainLayout'
|
||||
import PartCell from 'src/components/PartCell'
|
||||
import ProjectCell from 'src/components/ProjectCell'
|
||||
import Seo from 'src/components/Seo/Seo'
|
||||
|
||||
const EditPartPage = ({ userName, partTitle }) => {
|
||||
const EditProjectPage = ({ userName, projectTitle }) => {
|
||||
const { currentUser } = useAuth()
|
||||
return (
|
||||
<MainLayout>
|
||||
<Seo title={partTitle} description="Edit part page" lang="en-US" />
|
||||
<Seo title={projectTitle} description="Edit project page" lang="en-US" />
|
||||
|
||||
<PartCell
|
||||
<ProjectCell
|
||||
userName={userName}
|
||||
partTitle={partTitle}
|
||||
projectTitle={projectTitle}
|
||||
currentUserId={currentUser?.sub}
|
||||
isEditable
|
||||
/>
|
||||
@@ -20,4 +20,4 @@ const EditPartPage = ({ userName, partTitle }) => {
|
||||
)
|
||||
}
|
||||
|
||||
export default EditPartPage
|
||||
export default EditProjectPage
|
||||
@@ -5,7 +5,7 @@ import Seo from 'src/components/Seo/Seo'
|
||||
const UserPage = ({ userName }) => {
|
||||
return (
|
||||
<MainLayout>
|
||||
<Seo title={userName} description="Add new part page" lang="en-US" />
|
||||
<Seo title={userName} description="Add new project page" lang="en-US" />
|
||||
|
||||
<EditUserCell userName={userName} isEditable />
|
||||
</MainLayout>
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import MainLayout from 'src/layouts/MainLayout'
|
||||
import PartsCell from 'src/components/PartsCell'
|
||||
import ProjectsCell from 'src/components/ProjectsCell'
|
||||
import LandingSection from 'src/components/LandingSection'
|
||||
import Seo from 'src/components/Seo/Seo'
|
||||
|
||||
const PartsPage = () => {
|
||||
const ProjectsPage = () => {
|
||||
return (
|
||||
<MainLayout>
|
||||
<Seo title="Parts page" description="Cadhub parts page" lang="en-US" />
|
||||
<Seo
|
||||
title="Projects page"
|
||||
description="Cadhub Projects page"
|
||||
lang="en-US"
|
||||
/>
|
||||
<LandingSection />
|
||||
<PartsCell shouldFilterPartsWithoutImage />
|
||||
<ProjectsCell shouldFilterProjectsWithoutImage />
|
||||
</MainLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default PartsPage
|
||||
export default ProjectsPage
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import MainLayout from 'src/layouts/MainLayout'
|
||||
import IdePartCell from 'src/components/IdePartCell'
|
||||
import Seo from 'src/components/Seo/Seo'
|
||||
|
||||
const IdePartPage = ({ userName, partTitle }) => {
|
||||
return (
|
||||
<MainLayout shouldRemoveFooterInIde>
|
||||
<Seo title={partTitle} description={partTitle} lang="en-US" />
|
||||
|
||||
<IdePartCell userName={userName} partTitle={partTitle} />
|
||||
</MainLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default IdePartPage
|
||||
@@ -1,11 +1,11 @@
|
||||
import { render } from '@redwoodjs/testing'
|
||||
|
||||
import EditPartPage from './EditPartPage'
|
||||
import IdeProjectPage from './IdeProjectPage'
|
||||
|
||||
describe('EditPartPage', () => {
|
||||
describe('IdeProjectPage', () => {
|
||||
it('renders successfully', () => {
|
||||
expect(() => {
|
||||
render(<EditPartPage />)
|
||||
render(<IdeProjectPage />)
|
||||
}).not.toThrow()
|
||||
})
|
||||
})
|
||||
13
app/web/src/pages/IdeProjectPage/IdeProjectPage.tsx
Normal file
13
app/web/src/pages/IdeProjectPage/IdeProjectPage.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import IdeProjectCell from 'src/components/IdeProjectCell'
|
||||
import Seo from 'src/components/Seo/Seo'
|
||||
|
||||
const IdeProjectPage = ({ userName, projectTitle }) => {
|
||||
return (
|
||||
<>
|
||||
<Seo title={projectTitle} description={projectTitle} lang="en-US" />
|
||||
<IdeProjectCell userName={userName} projectTitle={projectTitle} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default IdeProjectPage
|
||||
@@ -1,7 +0,0 @@
|
||||
import NewPartPage from './NewPartPage'
|
||||
|
||||
export const generated = () => {
|
||||
return <NewPartPage />
|
||||
}
|
||||
|
||||
export default { title: 'Pages/NewPartPage' }
|
||||
@@ -0,0 +1,7 @@
|
||||
import NewProjectPage from './NewProjectPage'
|
||||
|
||||
export const generated = () => {
|
||||
return <NewProjectPage />
|
||||
}
|
||||
|
||||
export default { title: 'Pages/NewProjectPage' }
|
||||
@@ -1,11 +1,11 @@
|
||||
import { render } from '@redwoodjs/testing'
|
||||
|
||||
import NewPartPage from './NewPartPage'
|
||||
import NewProjectPage from './NewProjectPage'
|
||||
|
||||
describe('NewPartPage', () => {
|
||||
describe('NewProjectPage', () => {
|
||||
it('renders successfully', () => {
|
||||
expect(() => {
|
||||
render(<NewPartPage />)
|
||||
render(<NewProjectPage />)
|
||||
}).not.toThrow()
|
||||
})
|
||||
})
|
||||
@@ -3,19 +3,23 @@ import { useAuth } from '@redwoodjs/auth'
|
||||
import { navigate, routes } from '@redwoodjs/router'
|
||||
|
||||
import MainLayout from 'src/layouts/MainLayout'
|
||||
import PartCell from 'src/components/PartCell'
|
||||
import ProjectCell from 'src/components/ProjectCell'
|
||||
import Seo from 'src/components/Seo/Seo'
|
||||
|
||||
const NewPartPage = ({ userName }) => {
|
||||
const NewProjectPage = ({ userName }) => {
|
||||
const { isAuthenticated, currentUser } = useAuth()
|
||||
useEffect(() => {
|
||||
!isAuthenticated && navigate(routes.home())
|
||||
}, [currentUser])
|
||||
return (
|
||||
<MainLayout>
|
||||
<Seo title="New part" description="Add new part page" lang="en-US" />
|
||||
<Seo
|
||||
title="New project"
|
||||
description="Add new project page"
|
||||
lang="en-US"
|
||||
/>
|
||||
|
||||
<PartCell
|
||||
<ProjectCell
|
||||
userName={userName}
|
||||
currentUserId={currentUser?.sub}
|
||||
isEditable
|
||||
@@ -24,4 +28,4 @@ const NewPartPage = ({ userName }) => {
|
||||
)
|
||||
}
|
||||
|
||||
export default NewPartPage
|
||||
export default NewProjectPage
|
||||
@@ -1,22 +0,0 @@
|
||||
import { useAuth } from '@redwoodjs/auth'
|
||||
|
||||
import MainLayout from 'src/layouts/MainLayout'
|
||||
import PartCell from 'src/components/PartCell'
|
||||
import Seo from 'src/components/Seo/Seo'
|
||||
|
||||
const PartPage = ({ userName, partTitle }) => {
|
||||
const { currentUser } = useAuth()
|
||||
return (
|
||||
<MainLayout>
|
||||
<Seo title={partTitle} description={partTitle} lang="en-US" />
|
||||
|
||||
<PartCell
|
||||
userName={userName}
|
||||
partTitle={partTitle}
|
||||
currentUserId={currentUser?.sub}
|
||||
/>
|
||||
</MainLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default PartPage
|
||||
@@ -1,7 +0,0 @@
|
||||
import PartPage from './PartPage'
|
||||
|
||||
export const generated = () => {
|
||||
return <PartPage />
|
||||
}
|
||||
|
||||
export default { title: 'Pages/PartPage' }
|
||||
@@ -1,11 +0,0 @@
|
||||
import { render } from '@redwoodjs/testing'
|
||||
|
||||
import PartPage from './PartPage'
|
||||
|
||||
describe('PartPage', () => {
|
||||
it('renders successfully', () => {
|
||||
expect(() => {
|
||||
render(<PartPage />)
|
||||
}).not.toThrow()
|
||||
})
|
||||
})
|
||||
7
app/web/src/pages/ProjectPage/ProjectPage.stories.tsx
Normal file
7
app/web/src/pages/ProjectPage/ProjectPage.stories.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import ProjectPage from './ProjectPage'
|
||||
|
||||
export const generated = () => {
|
||||
return <ProjectPage />
|
||||
}
|
||||
|
||||
export default { title: 'Pages/ProjectPage' }
|
||||
@@ -1,11 +1,11 @@
|
||||
import { render } from '@redwoodjs/testing'
|
||||
|
||||
import IdePartPage from './IdePartPage'
|
||||
import ProjectPage from './ProjectPage'
|
||||
|
||||
describe('IdePartPage', () => {
|
||||
describe('ProjectPage', () => {
|
||||
it('renders successfully', () => {
|
||||
expect(() => {
|
||||
render(<IdePartPage />)
|
||||
render(<ProjectPage />)
|
||||
}).not.toThrow()
|
||||
})
|
||||
})
|
||||
25
app/web/src/pages/ProjectPage/ProjectPage.tsx
Normal file
25
app/web/src/pages/ProjectPage/ProjectPage.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useAuth } from '@redwoodjs/auth'
|
||||
|
||||
import ProjectCell from 'src/components/ProjectCell'
|
||||
import Seo from 'src/components/Seo/Seo'
|
||||
import { useIdeState } from 'src/helpers/hooks/useIdeState'
|
||||
import { IdeContext } from 'src/helpers/hooks/useIdeContext'
|
||||
|
||||
const ProjectPage = ({ userName, projectTitle }) => {
|
||||
const { currentUser } = useAuth()
|
||||
const [state, thunkDispatch] = useIdeState()
|
||||
return (
|
||||
<>
|
||||
<Seo title={projectTitle} description={projectTitle} lang="en-US" />
|
||||
<IdeContext.Provider value={{ state, thunkDispatch, project: null }}>
|
||||
<ProjectCell
|
||||
userName={userName}
|
||||
projectTitle={projectTitle}
|
||||
currentUserId={currentUser?.sub}
|
||||
/>
|
||||
</IdeContext.Provider>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProjectPage
|
||||
@@ -19,7 +19,7 @@ export const QUERY = gql`
|
||||
updatedAt
|
||||
image
|
||||
bio
|
||||
Parts {
|
||||
Projects {
|
||||
id
|
||||
title
|
||||
description
|
||||
@@ -32,7 +32,7 @@ export const QUERY = gql`
|
||||
Reaction {
|
||||
id
|
||||
emote
|
||||
part {
|
||||
project {
|
||||
id
|
||||
title
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export const QUERY = gql`
|
||||
Comment {
|
||||
id
|
||||
text
|
||||
part {
|
||||
project {
|
||||
id
|
||||
title
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user