@@ -4,6 +4,7 @@ import { Auth } from './auth.js';
44import { User } from './user.js' ;
55import { Stats } from './stats.js' ;
66import { Robots } from './robots.js' ;
7+ import { Changelog } from './changelog.js' ;
78
89const App = ( ( ) => {
910 "use strict" ;
@@ -25,6 +26,17 @@ const App = (() => {
2526 const parseURL = ( ) => {
2627 const path = window . location . pathname ;
2728
29+ // Check for changelog page patterns: /changelog/gh/org/username or /changelog/gh/org or /changelog/gh/*/username
30+ const changelogMatch = path . match ( / ^ \/ c h a n g e l o g \/ g h \/ ( [ ^ \/ ] + ) (?: \/ ( [ ^ \/ ] + ) ) ? $ / ) ;
31+ if ( changelogMatch ) {
32+ const [ , org , username ] = changelogMatch ;
33+ return {
34+ org : org === '*' ? null : org ,
35+ username : username || null ,
36+ isChangelog : true ,
37+ } ;
38+ }
39+
2840 // Check for robot page patterns: /robots or /robots/gh/org
2941 if ( path === '/robots' ) {
3042 return {
@@ -115,6 +127,7 @@ const App = (() => {
115127 const statsLink = $ ( "statsLink" ) ;
116128 const settingsLink = $ ( "settingsLink" ) ;
117129 const notificationsLink = $ ( "notificationsLink" ) ;
130+ const changelogLink = $ ( "changelogLink" ) ;
118131 const orgSelect = $ ( "orgSelect" ) ;
119132 const urlContext = parseURL ( ) ;
120133 const { username, org : urlOrg } = urlContext || { } ;
@@ -141,6 +154,18 @@ const App = (() => {
141154 if ( notificationsLink ) {
142155 notificationsLink . href = selectedOrg ? `/notifications/gh/${ selectedOrg } ` : '/notifications' ;
143156 }
157+
158+ if ( changelogLink ) {
159+ if ( selectedOrg && targetUsername ) {
160+ changelogLink . href = `/changelog/gh/${ selectedOrg } /${ targetUsername } ` ;
161+ } else if ( selectedOrg ) {
162+ changelogLink . href = `/changelog/gh/${ selectedOrg } ` ;
163+ } else if ( targetUsername ) {
164+ changelogLink . href = `/changelog/gh/*/${ targetUsername } ` ;
165+ } else {
166+ changelogLink . href = '/changelog/gh/*' ;
167+ }
168+ }
144169 } ;
145170
146171 const setupHamburgerMenu = ( ) => {
@@ -223,6 +248,19 @@ const App = (() => {
223248 } ) ;
224249 }
225250
251+ const changelogLink = $ ( "changelogLink" ) ;
252+ if ( changelogLink ) {
253+ if ( path . startsWith ( '/changelog' ) ) {
254+ changelogLink . classList . add ( "active" ) ;
255+ }
256+
257+ changelogLink . addEventListener ( "click" , ( e ) => {
258+ e . preventDefault ( ) ;
259+ closeMenu ( ) ;
260+ window . location . href = changelogLink . href ;
261+ } ) ;
262+ }
263+
226264 const settingsLink = $ ( "settingsLink" ) ;
227265 if ( settingsLink ) {
228266 if ( path . startsWith ( '/robots' ) ) {
@@ -269,6 +307,15 @@ const App = (() => {
269307 window . location . href = selectedOrg ? `/robots/gh/${ selectedOrg } ` : '/robots' ;
270308 } else if ( path . startsWith ( '/notifications' ) ) {
271309 window . location . href = selectedOrg ? `/notifications/gh/${ selectedOrg } ` : '/notifications' ;
310+ } else if ( path . startsWith ( '/changelog' ) ) {
311+ const currentUser = state . currentUser || state . viewingUser ;
312+ if ( selectedOrg && currentUser ?. login ) {
313+ window . location . href = `/changelog/gh/${ selectedOrg } /${ currentUser . login } ` ;
314+ } else if ( selectedOrg ) {
315+ window . location . href = `/changelog/gh/${ selectedOrg } ` ;
316+ } else {
317+ window . location . href = '/changelog/gh/*' ;
318+ }
272319 } else {
273320 // For root or unknown pages, go to user dashboard
274321 const currentUser = state . currentUser || state . viewingUser ;
@@ -547,6 +594,29 @@ const App = (() => {
547594 return ;
548595 }
549596
597+ // Handle changelog page routing
598+ if ( urlContext && urlContext . isChangelog ) {
599+ updateSearchInputVisibility ( ) ;
600+ const token = Auth . getStoredToken ( ) ;
601+ if ( token ) {
602+ try {
603+ await loadCurrentUser ( ) ;
604+ User . updateUserDisplay ( state , initiateLogin ) ;
605+ setupHamburgerMenu ( ) ;
606+ await User . updateOrgFilter ( state , parseURL , githubAPI ) ;
607+
608+ // Setup org dropdown handler
609+ const orgSelect = $ ( "orgSelect" ) ;
610+ if ( orgSelect ) {
611+ orgSelect . addEventListener ( "change" , handleOrgChange ) ;
612+ }
613+ } catch ( error ) {
614+ console . error ( "Failed to load user for changelog:" , error ) ;
615+ }
616+ }
617+ await Changelog . showChangelogPage ( state , githubAPI , parseURL ) ;
618+ return ;
619+ }
550620 // Handle notifications page routing
551621 const path = window . location . pathname ;
552622 if ( path === '/notifications' || path . match ( / ^ \/ n o t i f i c a t i o n s \/ g h \/ [ ^ \/ ] + $ / ) ) {
0 commit comments