@@ -21,10 +21,18 @@ interface Props {
2121interface BannerProps {
2222 courseId ?: string ;
2323 isBlockDataPending ?: boolean ;
24+ limitIsExceeded ?: boolean ;
25+ limitNumber ?: number ;
2426 unsupportedBlockPercentage : number ;
2527}
2628
27- const Banner = ( { courseId, isBlockDataPending, unsupportedBlockPercentage } : BannerProps ) => {
29+ const Banner = ( {
30+ courseId,
31+ isBlockDataPending,
32+ limitIsExceeded,
33+ limitNumber,
34+ unsupportedBlockPercentage,
35+ } : BannerProps ) => {
2836 const { data, isPending } = useCourseDetails ( courseId ) ;
2937 const { libraryId } = useLibraryContext ( ) ;
3038 const { data : migrationInfoData , isPending : migrationInfoIsPending } = useMigrationInfo (
@@ -65,6 +73,22 @@ const Banner = ({ courseId, isBlockDataPending, unsupportedBlockPercentage }: Ba
6573 ) ;
6674 }
6775
76+ if ( limitIsExceeded ) {
77+ return (
78+ < >
79+ < Alert variant = "danger" icon = { Info } >
80+ < Alert . Heading >
81+ < FormattedMessage { ...messages . importBlockedTitle } />
82+ </ Alert . Heading >
83+ </ Alert >
84+ < FormattedMessage
85+ { ...messages . importBlockedBody }
86+ values = { { limitNumber } }
87+ />
88+ </ >
89+ ) ;
90+ }
91+
6892 if ( currentMigrationInfo ) {
6993 return (
7094 < >
@@ -223,58 +247,46 @@ export const ReviewImportDetails = ({
223247 } , [ blockTypes , finalUnsupportedBlocks ] ) ;
224248
225249 const limitIsExceeded = useMemo ( ( ) => (
226- libraryData ?. numBlocks || 0 ) + ( totalBlocks || 0 ) > ( libraryBlockLimits ?. maxBlocksPerContentLibrary || 0
250+ libraryBlockLimits !== undefined
251+ && ( libraryData ?. numBlocks || 0 ) + ( totalBlocks || 0 ) > libraryBlockLimits . maxBlocksPerContentLibrary
227252 ) , [ libraryData ?. numBlocks , totalBlocks , libraryBlockLimits ?. maxBlocksPerContentLibrary ] ) ;
228253
229254 useEffect ( ( ) => {
230255 setImportIsBlocked ( limitIsExceeded ) ;
231256 } , [ limitIsExceeded , setImportIsBlocked ] ) ;
232257
233- // If the total blocks exceeds the permitted limit, render the page to block import
234- if ( limitIsExceeded ) {
235- return (
236- < Stack gap = { 4 } >
237- < Alert variant = "danger" icon = { Info } >
238- < Alert . Heading >
239- < FormattedMessage { ...messages . importBlockedTitle } />
240- </ Alert . Heading >
241- </ Alert >
242- < FormattedMessage
243- { ...messages . importBlockedBody }
244- values = { {
245- limitNumber : libraryBlockLimits ?. maxBlocksPerContentLibrary || 0 ,
246- } }
247- />
248- </ Stack >
249- ) ;
250- }
251-
252258 return (
253259 < Stack gap = { 4 } >
254260 < Banner
255261 courseId = { courseId }
256262 isBlockDataPending = { isBlockDataPending }
263+ limitIsExceeded = { limitIsExceeded }
264+ limitNumber = { libraryBlockLimits ?. maxBlocksPerContentLibrary || 0 }
257265 unsupportedBlockPercentage = { unsupportedBlockPercentage }
258266 />
259- < h4 > < FormattedMessage { ...messages . importCourseAnalysisSummary } /> </ h4 >
260- < SummaryCard
261- totalBlocks = { totalBlocks }
262- totalComponents = { totalComponents }
263- sections = { blockTypes ?. chapter }
264- subsections = { blockTypes ?. sequential }
265- units = { blockTypes ?. vertical }
266- unsupportedBlocks = { finalUnsupportedBlocks }
267- isPending = { isBlockDataPending }
268- />
269- { ! isBlockDataPending && finalUnsupportedBlocks > 0
270- && (
267+ { ! limitIsExceeded && (
271268 < >
272- < h4 > < FormattedMessage { ...messages . importCourseAnalysisDetails } /> </ h4 >
273- < Stack className = "align-items-center" gap = { 3 } >
274- < FormattedMessage { ...messages . importCourseAnalysisDetailsUnsupportedBlocksBody } />
275- </ Stack >
269+ < h4 > < FormattedMessage { ...messages . importCourseAnalysisSummary } /> </ h4 >
270+ < SummaryCard
271+ totalBlocks = { totalBlocks }
272+ totalComponents = { totalComponents }
273+ sections = { blockTypes ?. chapter }
274+ subsections = { blockTypes ?. sequential }
275+ units = { blockTypes ?. vertical }
276+ unsupportedBlocks = { finalUnsupportedBlocks }
277+ isPending = { isBlockDataPending }
278+ />
279+ { ! isBlockDataPending && finalUnsupportedBlocks > 0
280+ && (
281+ < >
282+ < h4 > < FormattedMessage { ...messages . importCourseAnalysisDetails } /> </ h4 >
283+ < Stack className = "align-items-center" gap = { 3 } >
284+ < FormattedMessage { ...messages . importCourseAnalysisDetailsUnsupportedBlocksBody } />
285+ </ Stack >
286+ </ >
287+ ) }
276288 </ >
277- ) }
289+ ) }
278290 </ Stack >
279291 ) ;
280292} ;
0 commit comments