1- import { ArrowDown , ArrowsClockwise } from "@phosphor-icons/react" ;
1+ import {
2+ ArrowDown ,
3+ ArrowRight ,
4+ ArrowsClockwise ,
5+ Gift ,
6+ } from "@phosphor-icons/react" ;
27import { useHostTRPC } from "@posthog/host-router/react" ;
38import { MarkdownRenderer } from "@posthog/ui/features/editor/components/MarkdownRenderer" ;
9+ import { ReleaseNotesSections } from "@posthog/ui/features/updates/ReleaseNotesSections" ;
10+ import { parseReleaseNotes } from "@posthog/ui/features/updates/releaseNotes" ;
411import { useUpdateModalStore } from "@posthog/ui/features/updates/updateModalStore" ;
512import {
613 useInstallUpdate ,
@@ -41,48 +48,82 @@ export function UpdateAvailableModal() {
4148 const downloadMutation = useMutation (
4249 hostTRPC . updates . download . mutationOptions ( ) ,
4350 ) ;
51+ const { data : releasesData } = useQuery ( {
52+ ...hostTRPC . githubReleases . list . queryOptions ( ) ,
53+ enabled : isOpen ,
54+ } ) ;
4455
4556 const targetVersion = version ?? availableVersion ;
4657 const percent = Math . round ( downloadPercent ?? 0 ) ;
4758 const isDownloading = status === "downloading" ;
4859 const isReady = status === "ready" || status === "installing" ;
4960
61+ const releases = releasesData ?. releases ?? [ ] ;
62+ const latestRelease = releases . find ( ( r ) => ! r . isPrerelease ) ?? releases [ 0 ] ;
63+ const noteRelease =
64+ releases . find ( ( r ) => r . version === targetVersion ) ?? latestRelease ;
65+ const rawNotes = noteRelease ?. notes ?. trim ( )
66+ ? noteRelease . notes
67+ : releaseNotes ;
68+ const parsedNotes = rawNotes ? parseReleaseNotes ( rawNotes ) : null ;
69+ const hasParsedNotes =
70+ ! ! parsedNotes &&
71+ ( parsedNotes . improved . length > 0 || parsedNotes . fixed . length > 0 ) ;
72+
5073 return (
5174 < Dialog . Root
5275 open = { isOpen }
5376 onOpenChange = { ( open ) => {
5477 if ( ! open ) close ( ) ;
5578 } }
5679 >
57- < Dialog . Content maxWidth = "460px" >
58- < Flex direction = "column" gap = "3" >
59- < Flex direction = "column" gap = "1" >
60- < Dialog . Title className = "mb-0" > Update Available</ Dialog . Title >
61- < Dialog . Description >
62- < Text color = "gray" size = "2" >
63- { targetVersion
64- ? `PostHog Code ${ targetVersion } is ready`
65- : "A new version is ready" }
66- </ Text >
67- </ Dialog . Description >
80+ < Dialog . Content maxWidth = "440px" >
81+ < Flex direction = "column" gap = "4" >
82+ < Flex align = "center" gap = "3" >
83+ < Flex
84+ align = "center"
85+ justify = "center"
86+ className = "size-10 shrink-0 rounded-full bg-accent-3 text-accent-11"
87+ >
88+ < Gift size = { 22 } weight = "duotone" />
89+ </ Flex >
90+ < Flex direction = "column" >
91+ < Dialog . Title className = "mb-0" size = "4" >
92+ { isReady ? "Update ready" : "Update available" }
93+ </ Dialog . Title >
94+ < Dialog . Description >
95+ < Text color = "gray" size = "2" >
96+ { targetVersion
97+ ? `PostHog Code ${ targetVersion } `
98+ : "A new version is available" }
99+ </ Text >
100+ </ Dialog . Description >
101+ </ Flex >
68102 </ Flex >
69103
70104 { currentVersion ? (
71105 < Flex
72106 align = "center"
73- gap = "2"
74- className = "rounded-3 border border-gray-5 bg-gray-2 px-3 py-2"
107+ justify = "center"
108+ gap = "3"
109+ className = "rounded-3 border border-gray-5 bg-gray-2 px-3 py-2.5"
75110 >
76- < Text size = "2" color = "gray" >
77- You're currently on version
78- </ Text >
79- < Code variant = "soft" > { currentVersion } </ Code >
111+ < Code variant = "soft" color = "gray" >
112+ { currentVersion }
113+ </ Code >
114+ < ArrowRight size = { 14 } className = "shrink-0 text-gray-9" />
115+ < Code variant = "soft" > { targetVersion ?? "latest" } </ Code >
80116 </ Flex >
81117 ) : null }
82118
83- { releaseNotes ? (
84- < Flex direction = "column" gap = "1" >
85- < Text size = "2" weight = "medium" color = "gray" >
119+ { hasParsedNotes || rawNotes ? (
120+ < Flex direction = "column" gap = "2" >
121+ < Text
122+ size = "1"
123+ weight = "medium"
124+ color = "gray"
125+ className = "uppercase tracking-wide"
126+ >
86127 Release notes
87128 </ Text >
88129 < ScrollArea
@@ -91,7 +132,11 @@ export function UpdateAvailableModal() {
91132 style = { { maxHeight : 240 } }
92133 >
93134 < div className = "pr-3" >
94- < MarkdownRenderer content = { releaseNotes } />
135+ { hasParsedNotes && parsedNotes ? (
136+ < ReleaseNotesSections notes = { parsedNotes } />
137+ ) : rawNotes ? (
138+ < MarkdownRenderer content = { rawNotes } />
139+ ) : null }
95140 </ div >
96141 </ ScrollArea >
97142 </ Flex >
@@ -111,27 +156,28 @@ export function UpdateAvailableModal() {
111156 </ Flex >
112157 ) : null }
113158
114- < Flex justify = "end" align = "center" gap = "3 " mt = "1" >
115- < Button variant = "ghost " color = "gray" onClick = { close } >
159+ < Flex justify = "end" align = "center" gap = "2 " mt = "1" >
160+ < Button variant = "soft " color = "gray" size = "2 " onClick = { close } >
116161 Later
117162 </ Button >
118163 { isReady ? (
119- < Button onClick = { ( ) => void installUpdate ( ) } >
164+ < Button size = "2" onClick = { ( ) => void installUpdate ( ) } >
120165 < ArrowsClockwise size = { 16 } />
121166 Restart to update
122167 </ Button >
123168 ) : isDownloading ? (
124- < Button disabled >
169+ < Button size = "2" disabled >
125170 < ArrowsClockwise size = { 16 } className = "animate-spin" />
126171 Downloading...
127172 </ Button >
128173 ) : (
129174 < Button
175+ size = "2"
130176 onClick = { ( ) => downloadMutation . mutate ( undefined ) }
131177 disabled = { downloadMutation . isPending }
132178 >
133179 < ArrowDown size = { 16 } />
134- Download Update
180+ Download update
135181 </ Button >
136182 ) }
137183 </ Flex >
0 commit comments