11import styled from 'styled-components' ;
22import { ProgressBar } from '@primer/react' ;
3- import { Virtuoso } from 'react-virtuoso' ;
43import { AppCard } from './AppCard' ;
54import { Pagination } from './Pagination' ;
6- import { AuditLogProgress } from './AuditLogProgress' ;
75import { SectionTitle , EmptyState , MutedText } from './shared/styles' ;
8- import type { AppInstallation , GitHubApp , Organization } from '../types' ;
6+ import type { AppInstallation , GitHubApp } from '../types' ;
97import type { BackgroundProgress } from '../hooks/useDashboardData' ;
10- import type { UsageProgress } from '../hooks/useAppUsage' ;
118import type { AppUsageInfo } from '../types' ;
129
1310const ContentHeader = styled . div `
@@ -71,12 +68,7 @@ interface AppsViewProps {
7168 loadedAppsPages : number ;
7269 appsPerPage : number ;
7370 backgroundProgress : BackgroundProgress | null ;
74- isFirstLoad : boolean ;
7571 smoothedAuditProgress : { checked : number ; total : number ; found : number } ;
76- usageLoading : boolean ;
77- usageLoadingStarted : boolean ;
78- usageProgress : UsageProgress | null ;
79- organizations : Organization [ ] ;
8072 token : string ;
8173 enterpriseUrl : string ;
8274 getUsageForApp : ( slug : string ) => AppUsageInfo | undefined ;
@@ -93,16 +85,17 @@ export function AppsView({
9385 loadedAppsPages,
9486 appsPerPage,
9587 backgroundProgress,
96- isFirstLoad,
9788 smoothedAuditProgress,
98- usageLoading,
99- usageLoadingStarted,
100- usageProgress,
101- organizations,
10289 token,
10390 enterpriseUrl,
10491 getUsageForApp,
10592} : AppsViewProps ) {
93+ // Use expectedTotalApps as the denominator while Phase 2 is still loading
94+ const activityTotal = backgroundProgress ?. isLoading
95+ ? Math . max ( smoothedAuditProgress . total , expectedTotalApps )
96+ : smoothedAuditProgress . total ;
97+ const activityProgress = activityTotal > 0 ? Math . min ( ( smoothedAuditProgress . checked / activityTotal ) * 100 , 100 ) : 0 ;
98+
10699 return (
107100 < div >
108101 < ContentHeader >
@@ -135,56 +128,39 @@ export function AppsView({
135128 </ BackgroundLoadingText >
136129 </ BackgroundLoadingBar >
137130 ) }
138- { ! isFirstLoad && smoothedAuditProgress . total > 0 && smoothedAuditProgress . checked < smoothedAuditProgress . total && (
131+ { activityTotal > 0 && smoothedAuditProgress . checked < activityTotal && (
139132 < AuditLogLoadingBar >
140133 < AuditLogLoadingText >
141- Checking activity... ({ smoothedAuditProgress . checked } /{ smoothedAuditProgress . total } apps, { smoothedAuditProgress . found } active)
134+ Checking activity... ({ smoothedAuditProgress . checked } /{ activityTotal } apps, { smoothedAuditProgress . found } active)
142135 </ AuditLogLoadingText >
143136 < BackgroundProgressWrapper >
144137 < ProgressBar
145- progress = { smoothedAuditProgress . total > 0 ? Math . min ( ( smoothedAuditProgress . checked / smoothedAuditProgress . total ) * 100 , 100 ) : 0 }
138+ progress = { activityProgress }
146139 barSize = "small"
147140 aria-label = "Audit log loading progress"
148141 />
149142 </ BackgroundProgressWrapper >
150143 < AuditLogLoadingText >
151- { smoothedAuditProgress . total > 0 ? Math . min ( Math . round ( ( smoothedAuditProgress . checked / smoothedAuditProgress . total ) * 100 ) , 100 ) : 0 } %
144+ { Math . round ( activityProgress ) } %
152145 </ AuditLogLoadingText >
153146 </ AuditLogLoadingBar >
154147 ) }
155- { isFirstLoad && ( usageLoading || usageLoadingStarted ) && (
156- < AuditLogProgress
157- progress = { usageProgress || {
158- org : organizations [ 0 ] ?. login || '' ,
159- appsChecked : 0 ,
160- totalApps : apps . size ,
161- appsFound : 0 ,
162- currentPhase : 'fetching' as const ,
163- message : 'Preparing to scan audit logs...' ,
164- } }
165- totalOrgs = { organizations . length }
166- />
167- ) }
168148 { paginatedApps . length > 0 ? (
169- < Virtuoso
170- useWindowScroll
171- data = { paginatedApps }
172- computeItemKey = { ( _ , [ slug ] ) => slug }
173- itemContent = { ( _ , [ slug , insts ] ) => {
174- const app = apps . get ( slug ) ;
175- if ( ! app ) return < div /> ;
176- const usageInfo = getUsageForApp ( slug ) ;
177- return (
178- < AppCard
179- app = { app }
180- installations = { insts }
181- token = { token }
182- enterpriseUrl = { enterpriseUrl }
183- usageInfo = { usageInfo }
184- />
185- ) ;
186- } }
187- />
149+ paginatedApps . map ( ( [ slug , insts ] ) => {
150+ const app = apps . get ( slug ) ;
151+ if ( ! app ) return null ;
152+ const usageInfo = getUsageForApp ( slug ) ;
153+ return (
154+ < AppCard
155+ key = { slug }
156+ app = { app }
157+ installations = { insts }
158+ token = { token }
159+ enterpriseUrl = { enterpriseUrl }
160+ usageInfo = { usageInfo }
161+ />
162+ ) ;
163+ } )
188164 ) : (
189165 < EmptyState >
190166 < MutedText > No apps found matching your filters.</ MutedText >
0 commit comments