@@ -342,11 +342,24 @@ var useViewState = function useViewState(state, props) {
342
342
343
343
if ( hasLatestRelease && ( 0 , _typeUtil . exists ) ( baseProduct ) ) {
344
344
hasLatestReleaseBundle = _BundleService . default . isProductInBundle ( bundlesContext , latestReleaseObject . release , baseProduct . productCode ) ;
345
+ } // Determine if the bundle product has data for the specified release.
346
+
347
+
348
+ var isBundleProductInRelease = true ;
349
+
350
+ if ( hasBundleProduct && hasSpecifiedRelease && ! isAppliedReleaseLatestNonProv ) {
351
+ var _bundleProduct ;
352
+
353
+ var bundleHasRelease = ( _bundleProduct = bundleProduct ) === null || _bundleProduct === void 0 ? void 0 : _bundleProduct . releases . find ( function ( r ) {
354
+ return r . release === appliedRenderedReleaseTag ;
355
+ } ) ;
356
+ isBundleProductInRelease = ( 0 , _typeUtil . exists ) ( bundleHasRelease ) ;
345
357
} // Determine if the citable product should be the bundle container product
346
358
// or the currently specified product.
359
+ // eslint-disable-next-line max-len
347
360
348
361
349
- var citableBaseProduct = hasBundleProduct ? bundleProduct : baseProduct ; // Determine the product to use for citing within the applicable release
362
+ var citableBaseProduct = hasBundleProduct && isBundleProductInRelease ? bundleProduct : baseProduct ; // Determine the product to use for citing within the applicable release
350
363
// and within the context of bundles.
351
364
352
365
var citableReleaseProduct = null ;
@@ -357,6 +370,7 @@ var useViewState = function useViewState(state, props) {
357
370
if ( ! hasSpecifiedRelease && ! hasLatestReleaseBundle ) {
358
371
citableReleaseProduct = baseProduct ;
359
372
} else {
373
+ // Has a specified release, or if not, has latest release bundle.
360
374
// When a bundled product code is available for the given release,
361
375
// get the product for the parent code and release.
362
376
// Otherwise, the citable product is the current product for the specified
@@ -383,7 +397,22 @@ var useViewState = function useViewState(state, props) {
383
397
} // Determine if there's a valid product to generate the citation with.
384
398
385
399
386
- var hasValidProduct = ( 0 , _typeUtil . exists ) ( citableBaseProduct ) ; // Determine the overall citation display status.
400
+ var hasValidProduct = ( 0 , _typeUtil . exists ) ( citableBaseProduct ) ;
401
+ var hasValidReleaseProduct = ( 0 , _typeUtil . exists ) ( citableReleaseProduct ) ; // Verify identified release product is in the applied release.
402
+
403
+ var isCitableReleaseProductInRelease = false ; // If looking at latest release non provisional, consider in release.
404
+
405
+ if ( isAppliedReleaseLatestNonProv ) {
406
+ isCitableReleaseProductInRelease = true ;
407
+ } else if ( hasValidReleaseProduct ) {
408
+ var _citableReleaseProduc ;
409
+
410
+ var productHasRelease = ( _citableReleaseProduc = citableReleaseProduct ) === null || _citableReleaseProduc === void 0 ? void 0 : _citableReleaseProduc . releases . find ( function ( r ) {
411
+ return r . release === appliedRenderedReleaseTag ;
412
+ } ) ;
413
+ isCitableReleaseProductInRelease = ( 0 , _typeUtil . exists ) ( productHasRelease ) ;
414
+ } // Determine the overall citation display status.
415
+
387
416
388
417
var appliedStatus = status ;
389
418
var displayType = _ViewState . DisplayType . CONDITIONAL ;
@@ -402,8 +431,15 @@ var useViewState = function useViewState(state, props) {
402
431
// not show a release citation, show not available display state.
403
432
displayType = _ViewState . DisplayType . NOT_AVAILABLE ;
404
433
} else if ( hasAppliedReleaseDoi ) {
405
- if ( ( 0 , _typeUtil . exists ) ( citableReleaseProduct ) ) {
406
- displayType = _ViewState . DisplayType . RELEASE ;
434
+ if ( hasValidReleaseProduct ) {
435
+ // If the identified release product doesn't have data in the
436
+ // release and we're viewing a specific release, report
437
+ // as not available for that release.
438
+ if ( ! isCitableReleaseProductInRelease ) {
439
+ displayType = _ViewState . DisplayType . NOT_AVAILABLE ;
440
+ } else {
441
+ displayType = _ViewState . DisplayType . RELEASE ;
442
+ }
407
443
} else {
408
444
// If the component is ready and a release was specified but
409
445
// failed to resolve the appropriate citable release product,
@@ -418,14 +454,18 @@ var useViewState = function useViewState(state, props) {
418
454
// a special case, render as not available.
419
455
displayType = _ViewState . DisplayType . NOT_AVAILABLE ;
420
456
}
457
+ } else if ( ! isCitableReleaseProductInRelease ) {
458
+ // If the detected citable release product is not in the applied
459
+ // release, then consider the display as provisional.
460
+ displayType = _ViewState . DisplayType . PROVISIONAL ;
421
461
} else if ( ! hasLatestRelease || hideLatestReleaseCitation || disableConditional ) {
422
462
// If display is determined to be conditional, but we haven't identified
423
463
// a valid latest release or it's set to hide the citation for that
424
464
// release, then display as provisional.
425
465
// If an override has been presented by the component, also
426
466
// display as provisional.
427
467
displayType = _ViewState . DisplayType . PROVISIONAL ;
428
- } else if ( ! hasValidProduct || ! ( 0 , _typeUtil . exists ) ( citableReleaseProduct ) ) {
468
+ } else if ( ! hasValidProduct || ! hasValidReleaseProduct ) {
429
469
// If the component is ready and the display state is conditional
430
470
// and a valid product and release product were not found, error state.
431
471
appliedStatus = _State . ContextStatus . ERROR ;
0 commit comments