added navigation to new project on fork
This commit is contained in:
committed by
Kurt Hutten
parent
02463db741
commit
2d7fb91f92
@@ -90,14 +90,16 @@ export const forkProject = async ({ input }) => {
|
||||
title = await generateUniqueString(title, isUniqueCallback)
|
||||
|
||||
const { code, description, cadPackage } = projectData
|
||||
const data = foreignKeyReplacement({
|
||||
...input,
|
||||
title,
|
||||
code,
|
||||
description,
|
||||
cadPackage,
|
||||
})
|
||||
console.log('forking data', data)
|
||||
return db.project.create({
|
||||
data: foreignKeyReplacement({
|
||||
...input,
|
||||
title,
|
||||
code,
|
||||
description,
|
||||
cadPackage,
|
||||
}),
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useMutation } from '@redwoodjs/web'
|
||||
import Gravatar from 'src/components/Gravatar/Gravatar'
|
||||
import EditableProjectTitle from 'src/components/EditableProjecTitle/EditableProjecTitle'
|
||||
import CaptureButton from 'src/components/CaptureButton/CaptureButton'
|
||||
import { toast } from '@redwoodjs/web/toast'
|
||||
|
||||
import { ReactNode } from 'react'
|
||||
|
||||
@@ -20,8 +21,10 @@ const FORK_PROJECT_MUTATION = gql`
|
||||
forkProject(input: $input) {
|
||||
id
|
||||
title
|
||||
description
|
||||
code
|
||||
user {
|
||||
id
|
||||
userName
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -144,7 +147,14 @@ function DefaultTopButtons({
|
||||
}) {
|
||||
const { currentUser } = useAuth()
|
||||
const [createFork] = useMutation(FORK_PROJECT_MUTATION, {
|
||||
onCompleted: () => {},
|
||||
onCompleted: ({ forkProject }) => {
|
||||
navigate(
|
||||
routes.ide({
|
||||
userName: forkProject?.user?.userName,
|
||||
projectTitle: forkProject?.title,
|
||||
})
|
||||
)
|
||||
},
|
||||
})
|
||||
const handleFork = () => {
|
||||
const prom = createFork({
|
||||
@@ -155,11 +165,11 @@ function DefaultTopButtons({
|
||||
},
|
||||
},
|
||||
})
|
||||
// toast.promise(prom, {
|
||||
// loading: 'Saving Image/s',
|
||||
// success: <b>Image/s saved!</b>,
|
||||
// error: <b>Problem saving.</b>,
|
||||
// })
|
||||
toast.promise(prom, {
|
||||
loading: 'Forking...',
|
||||
success: <b>Forked successfully!</b>,
|
||||
error: <b>Problem forking.</b>,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -244,7 +254,7 @@ function DefaultTopButtons({
|
||||
)
|
||||
}}
|
||||
</Popover>
|
||||
{currentUser?.id && (
|
||||
{currentUser?.sub && (
|
||||
<TopButton
|
||||
onClick={handleFork}
|
||||
name="Fork"
|
||||
|
||||
@@ -28,6 +28,14 @@ export const QUERY = gql`
|
||||
updatedAt
|
||||
userId
|
||||
cadPackage
|
||||
forkedFromId
|
||||
forkedFrom {
|
||||
id
|
||||
title
|
||||
user {
|
||||
userName
|
||||
}
|
||||
}
|
||||
Reaction {
|
||||
emote
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ const ProjectProfile = ({
|
||||
const hasPermissionToEdit =
|
||||
currentUser?.sub === userProject.id || currentUser?.roles.includes('admin')
|
||||
const project = userProject?.Project
|
||||
console.log({ project })
|
||||
|
||||
const emotes = countEmotes(project?.Reaction)
|
||||
const userEmotes = project?.userReactions.map(({ emote }) => emote)
|
||||
useEffect(() => {
|
||||
@@ -145,6 +147,9 @@ const ProjectProfile = ({
|
||||
<KeyValue keyName="Updated on">
|
||||
{new Date(project?.updatedAt).toDateString()}
|
||||
</KeyValue>
|
||||
{ project.forkedFrom && <KeyValue keyName="Forked from">
|
||||
{ project.forkedFrom.title } by { project.forkedFrom.user.userName }
|
||||
</KeyValue> }
|
||||
</div>
|
||||
<KeyValue keyName="Reactions">
|
||||
<EmojiReaction
|
||||
|
||||
Reference in New Issue
Block a user