Format and tweak 554
This commit is contained in:
@@ -60,14 +60,15 @@ export default function IdeHeader({
|
|||||||
}) {
|
}) {
|
||||||
const { currentUser } = useAuth()
|
const { currentUser } = useAuth()
|
||||||
const { project, state } = useIdeContext()
|
const { project, state } = useIdeContext()
|
||||||
const hasUnsavedChanges = project?.code && state?.code && project?.code !== state?.code
|
const hasUnsavedChanges =
|
||||||
|
project?.code && state?.code && project?.code !== state?.code
|
||||||
|
|
||||||
const isProfile = context === 'profile'
|
const isProfile = context === 'profile'
|
||||||
const canEdit =
|
const canEdit =
|
||||||
(currentUser && currentUser?.sub === project?.user?.id) ||
|
(currentUser && currentUser?.sub === project?.user?.id) ||
|
||||||
currentUser?.roles?.includes('admin')
|
currentUser?.roles?.includes('admin')
|
||||||
const projectOwner = project?.user?.userName
|
const projectOwner = project?.user?.userName
|
||||||
const showForkMessage = !canEdit && hasUnsavedChanges
|
const showForkMessage = !canEdit && hasUnsavedChanges && currentUser?.sub
|
||||||
|
|
||||||
const [createFork] = useMutation(FORK_PROJECT_MUTATION, {
|
const [createFork] = useMutation(FORK_PROJECT_MUTATION, {
|
||||||
onCompleted: ({ forkProject }) => {
|
onCompleted: ({ forkProject }) => {
|
||||||
@@ -204,17 +205,24 @@ export default function IdeHeader({
|
|||||||
</Popover>
|
</Popover>
|
||||||
{currentUser?.sub && (
|
{currentUser?.sub && (
|
||||||
<TopButton
|
<TopButton
|
||||||
onClick={handleFork}
|
onClick={handleFork}
|
||||||
name="Fork"
|
name="Fork"
|
||||||
className={ showForkMessage ? " bg-ch-blue-650 bg-opacity-80 hover:bg-opacity-100 text-ch-gray-300 border-blue-300 border-2"
|
className={
|
||||||
: " bg-ch-blue-650 bg-opacity-30 hover:bg-opacity-80 text-ch-gray-300" }
|
showForkMessage
|
||||||
>
|
? ' bg-ch-blue-650 bg-opacity-80 hover:bg-opacity-100 text-ch-gray-300 border-blue-300 border-2'
|
||||||
<Svg name="fork-new" className="w-6 h-6 text-ch-blue-400" />
|
: ' bg-ch-blue-650 bg-opacity-30 hover:bg-opacity-80 text-ch-gray-300'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Svg name="fork-new" className="w-6 h-6 text-ch-blue-400" />
|
||||||
</TopButton>
|
</TopButton>
|
||||||
)}
|
)}
|
||||||
{currentUser?.sub && showForkMessage && (
|
{showForkMessage && (
|
||||||
<div className="fixed bg-white w-60 h-10 top-20 right-20 z-10 rounded-md font-bold text-sm flex p-2 items-center">
|
<div className="fixed bg-white w-60 h-10 top-16 right-24 z-10 rounded-md text-sm flex p-2 items-center">
|
||||||
<Svg name="exclamation-circle" className="text-red-400 w-8 h-8 mx-2"/> Fork to save your work
|
<Svg
|
||||||
|
name="exclamation-circle"
|
||||||
|
className="w-8 h-8 mx-2 text-ch-blue-500"
|
||||||
|
/>{' '}
|
||||||
|
Fork to save your work
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user