|
|
|
@ -9,6 +9,8 @@ import { type TeamResourceConfig } from '../CreateTeam/RoadmapSelector'; |
|
|
|
|
import { useToast } from '../../hooks/use-toast'; |
|
|
|
|
import { RoadmapActionButton } from './RoadmapActionButton'; |
|
|
|
|
import { Lock, Shapes } from 'lucide-react'; |
|
|
|
|
import { Modal } from '../Modal'; |
|
|
|
|
import { ShareSuccess } from '../ShareOptions/ShareSuccess'; |
|
|
|
|
|
|
|
|
|
type RoadmapHeaderProps = {}; |
|
|
|
|
|
|
|
|
@ -22,9 +24,11 @@ export function RoadmapHeader(props: RoadmapHeaderProps) { |
|
|
|
|
_id: roadmapId, |
|
|
|
|
creator, |
|
|
|
|
team, |
|
|
|
|
visibility, |
|
|
|
|
} = useStore(currentRoadmap) || {}; |
|
|
|
|
|
|
|
|
|
const [isSharing, setIsSharing] = useState(false); |
|
|
|
|
const [isSharingWithOthers, setIsSharingWithOthers] = useState(false); |
|
|
|
|
const toast = useToast(); |
|
|
|
|
|
|
|
|
|
async function deleteResource() { |
|
|
|
@ -65,6 +69,22 @@ export function RoadmapHeader(props: RoadmapHeaderProps) { |
|
|
|
|
? `${import.meta.env.PUBLIC_AVATAR_BASE_URL}/${creator?.avatar}` |
|
|
|
|
: '/images/default-avatar.png'; |
|
|
|
|
|
|
|
|
|
const sharingWithOthersModal = isSharingWithOthers && ( |
|
|
|
|
<Modal |
|
|
|
|
onClose={() => setIsSharingWithOthers(false)} |
|
|
|
|
wrapperClassName="max-w-lg" |
|
|
|
|
bodyClassName="p-4 flex flex-col" |
|
|
|
|
> |
|
|
|
|
<ShareSuccess |
|
|
|
|
visibility="public" |
|
|
|
|
roadmapId={roadmapId!} |
|
|
|
|
description={description} |
|
|
|
|
onClose={() => setIsSharingWithOthers(false)} |
|
|
|
|
isSharingWithOthers={true} |
|
|
|
|
/> |
|
|
|
|
</Modal> |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div className="border-b"> |
|
|
|
|
<div className="container relative py-5 sm:py-12"> |
|
|
|
@ -117,63 +137,78 @@ export function RoadmapHeader(props: RoadmapHeaderProps) { |
|
|
|
|
<span className="ml-2">Subscribe</span> |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
|
{$canManageCurrentRoadmap && ( |
|
|
|
|
<div className="flex items-center gap-2"> |
|
|
|
|
{isSharing && $currentRoadmap && ( |
|
|
|
|
<ShareOptionsModal |
|
|
|
|
isDiscoverable={$currentRoadmap.isDiscoverable} |
|
|
|
|
description={$currentRoadmap?.description} |
|
|
|
|
visibility={$currentRoadmap?.visibility} |
|
|
|
|
teamId={$currentRoadmap?.teamId} |
|
|
|
|
roadmapId={$currentRoadmap?._id!} |
|
|
|
|
sharedFriendIds={$currentRoadmap?.sharedFriendIds || []} |
|
|
|
|
sharedTeamMemberIds={ |
|
|
|
|
$currentRoadmap?.sharedTeamMemberIds || [] |
|
|
|
|
} |
|
|
|
|
onClose={() => setIsSharing(false)} |
|
|
|
|
onShareSettingsUpdate={(settings) => { |
|
|
|
|
currentRoadmap.set({ |
|
|
|
|
...$currentRoadmap, |
|
|
|
|
...settings, |
|
|
|
|
}); |
|
|
|
|
<div className="flex items-center gap-2"> |
|
|
|
|
{$canManageCurrentRoadmap && ( |
|
|
|
|
<> |
|
|
|
|
{isSharing && $currentRoadmap && ( |
|
|
|
|
<ShareOptionsModal |
|
|
|
|
isDiscoverable={$currentRoadmap.isDiscoverable} |
|
|
|
|
description={$currentRoadmap?.description} |
|
|
|
|
visibility={$currentRoadmap?.visibility} |
|
|
|
|
teamId={$currentRoadmap?.teamId} |
|
|
|
|
roadmapId={$currentRoadmap?._id!} |
|
|
|
|
sharedFriendIds={$currentRoadmap?.sharedFriendIds || []} |
|
|
|
|
sharedTeamMemberIds={ |
|
|
|
|
$currentRoadmap?.sharedTeamMemberIds || [] |
|
|
|
|
} |
|
|
|
|
onClose={() => setIsSharing(false)} |
|
|
|
|
onShareSettingsUpdate={(settings) => { |
|
|
|
|
currentRoadmap.set({ |
|
|
|
|
...$currentRoadmap, |
|
|
|
|
...settings, |
|
|
|
|
}); |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
<a |
|
|
|
|
href={`${import.meta.env.PUBLIC_EDITOR_APP_URL}/${ |
|
|
|
|
$currentRoadmap?._id |
|
|
|
|
}`}
|
|
|
|
|
target="_blank" |
|
|
|
|
className="inline-flex items-center justify-center rounded-md border border-gray-300 bg-white py-1.5 pl-2 pr-2 text-xs font-medium text-black hover:border-gray-300 hover:bg-gray-300 sm:px-3 sm:text-sm" |
|
|
|
|
> |
|
|
|
|
<Shapes className="mr-1.5 h-4 w-4 stroke-[2.5]" /> |
|
|
|
|
<span className="hidden sm:inline-block">Edit Roadmap</span> |
|
|
|
|
<span className="sm:hidden">Edit</span> |
|
|
|
|
</a> |
|
|
|
|
<button |
|
|
|
|
onClick={() => setIsSharing(true)} |
|
|
|
|
className="inline-flex items-center justify-center rounded-md border border-gray-300 bg-white py-1.5 pl-2 pr-2 text-xs font-medium text-black hover:border-gray-300 hover:bg-gray-300 sm:px-3 sm:text-sm" |
|
|
|
|
> |
|
|
|
|
<Lock className="mr-1.5 h-4 w-4 stroke-[2.5]" /> |
|
|
|
|
Sharing |
|
|
|
|
</button> |
|
|
|
|
|
|
|
|
|
<RoadmapActionButton |
|
|
|
|
onDelete={() => { |
|
|
|
|
const confirmation = window.confirm( |
|
|
|
|
'Are you sure you want to delete this roadmap?' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (!confirmation) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
deleteResource().finally(() => null); |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
<a |
|
|
|
|
href={`${import.meta.env.PUBLIC_EDITOR_APP_URL}/${ |
|
|
|
|
$currentRoadmap?._id |
|
|
|
|
}`}
|
|
|
|
|
target="_blank" |
|
|
|
|
className="inline-flex items-center justify-center rounded-md border border-gray-300 bg-white py-1.5 pl-2 pr-2 text-xs font-medium text-black hover:border-gray-300 hover:bg-gray-300 sm:px-3 sm:text-sm" |
|
|
|
|
> |
|
|
|
|
<Shapes className="mr-1.5 h-4 w-4 stroke-[2.5]" /> |
|
|
|
|
<span className="hidden sm:inline-block">Edit Roadmap</span> |
|
|
|
|
<span className="sm:hidden">Edit</span> |
|
|
|
|
</a> |
|
|
|
|
<button |
|
|
|
|
onClick={() => setIsSharing(true)} |
|
|
|
|
className="inline-flex items-center justify-center rounded-md border border-gray-300 bg-white py-1.5 pl-2 pr-2 text-xs font-medium text-black hover:border-gray-300 hover:bg-gray-300 sm:px-3 sm:text-sm" |
|
|
|
|
> |
|
|
|
|
<Lock className="mr-1.5 h-4 w-4 stroke-[2.5]" /> |
|
|
|
|
Sharing |
|
|
|
|
</button> |
|
|
|
|
|
|
|
|
|
<RoadmapActionButton |
|
|
|
|
onDelete={() => { |
|
|
|
|
const confirmation = window.confirm( |
|
|
|
|
'Are you sure you want to delete this roadmap?' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (!confirmation) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
deleteResource().finally(() => null); |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
)} |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
{!$canManageCurrentRoadmap && visibility === 'public' && ( |
|
|
|
|
<> |
|
|
|
|
{sharingWithOthersModal} |
|
|
|
|
<button |
|
|
|
|
onClick={() => setIsSharingWithOthers(true)} |
|
|
|
|
className="inline-flex items-center justify-center rounded-md border border-gray-300 bg-white py-1.5 pl-2 pr-2 text-xs font-medium text-black hover:border-gray-300 hover:bg-gray-300 sm:px-3 sm:text-sm" |
|
|
|
|
> |
|
|
|
|
<Lock className="mr-1.5 h-4 w-4 stroke-[2.5]" /> |
|
|
|
|
Share with Others |
|
|
|
|
</button> |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<RoadmapHint |
|
|
|
|