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