@@ -154,7 +154,7 @@ const UIStrings = {
154154 /**
155155 * @description Message shown to the user if the age check is not successful.
156156 */
157- ageRestricted : 'This feature is only available to users who are 18 years of age or older' ,
157+ ageRestricted : 'This feature is only available to users who are 18 years of age or older. ' ,
158158 /**
159159 * @description The error message when the user is not logged in into Chrome.
160160 */
@@ -378,24 +378,33 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
378378 // clang-format on
379379 }
380380
381- #getDisabledReason( ) : string | undefined {
381+ #getDisabledReasons( ) : string [ ] {
382+ const reasons = [ ] ;
382383 switch ( this . #aidaAvailability) {
383384 case Host . AidaClient . AidaAccessPreconditions . NO_ACCOUNT_EMAIL :
384385 case Host . AidaClient . AidaAccessPreconditions . SYNC_IS_PAUSED :
385- return i18nString ( UIStrings . notLoggedIn ) ;
386- case Host . AidaClient . AidaAccessPreconditions . NO_INTERNET :
387- return i18nString ( UIStrings . offline ) ;
386+ reasons . push ( i18nString ( UIStrings . notLoggedIn ) ) ;
387+ break ;
388+ // @ts -expect-error
389+ case Host . AidaClient . AidaAccessPreconditions . NO_INTERNET : // fallthrough
390+ reasons . push ( i18nString ( UIStrings . offline ) ) ;
391+ case Host . AidaClient . AidaAccessPreconditions . AVAILABLE : {
392+ // No age check if there is no logged in user. Age check would always fail in that case.
393+ const config = Common . Settings . Settings . instance ( ) . getHostConfig ( ) ;
394+ if ( config ?. aidaAvailability ?. blockedByAge === true ) {
395+ reasons . push ( i18nString ( UIStrings . ageRestricted ) ) ;
396+ }
397+ }
388398 }
389-
390- const config = Common . Settings . Settings . instance ( ) . getHostConfig ( ) ;
391- if ( config ?. aidaAvailability ?. blockedByAge === true ) {
392- return i18nString ( UIStrings . ageRestricted ) ;
393- }
394- // `consoleInsightsSetting` and `aiAssistantSetting` are both disabled for the same reason.
395- return this . #consoleInsightsSetting?. disabledReason ( ) ;
399+ // `consoleInsightsSetting` and `aiAssistantSetting` are both disabled for the same reasons.
400+ const disabledReasons = this . #consoleInsightsSetting?. disabledReasons ( ) || [ ] ;
401+ reasons . push ( ...disabledReasons ) ;
402+ return reasons ;
396403 }
397404
398- #renderConsoleInsightsSetting( disabledReason ?: string ) : LitHtml . TemplateResult {
405+ #renderConsoleInsightsSetting( disabledReasons : string [ ] ) : LitHtml . TemplateResult {
406+ const isDisabled = disabledReasons . length > 0 ;
407+ const disabledReasonsJoined = disabledReasons . join ( '\n' ) || undefined ;
399408 const detailsClasses = {
400409 'whole-row' : true ,
401410 open : this . #isConsoleInsightsSettingExpanded,
@@ -427,15 +436,15 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
427436 </ div >
428437 < div class ="divider "> </ div >
429438 < div class ="toggle-container centered "
430- title =${ ifDefined ( disabledReason ) }
439+ title =${ ifDefined ( disabledReasonsJoined ) }
431440 @click =${ this . #toggleConsoleInsightsSetting. bind ( this ) }
432441 >
433442 < devtools-switch
434- .checked =${ Boolean ( this . #consoleInsightsSetting?. get ( ) ) && ! Boolean ( disabledReason ) }
443+ .checked =${ Boolean ( this . #consoleInsightsSetting?. get ( ) ) && ! isDisabled }
435444 .jslogContext =${ this . #consoleInsightsSetting?. name || '' }
436- .disabled=${ Boolean ( disabledReason ) }
445+ .disabled=${ isDisabled }
437446 @switchchange=${ this . #toggleConsoleInsightsSetting. bind ( this ) }
438- aria-label=${ disabledReason || i18nString ( UIStrings . enableConsoleInsights ) }
447+ aria-label=${ disabledReasonsJoined || i18nString ( UIStrings . enableConsoleInsights ) }
439448 > </ devtools-switch >
440449 </ div >
441450 < div class =${ classMap ( detailsClasses ) } >
@@ -463,7 +472,9 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
463472 // clang-format on
464473 }
465474
466- #renderAiAssistanceSetting( disabledReason ?: string ) : LitHtml . TemplateResult {
475+ #renderAiAssistanceSetting( disabledReasons : string [ ] ) : LitHtml . TemplateResult {
476+ const isDisabled = disabledReasons . length > 0 ;
477+ const disabledReasonsJoined = disabledReasons . join ( '\n' ) || undefined ;
467478 const detailsClasses = {
468479 'whole-row' : true ,
469480 open : this . #isAiAssistanceSettingExpanded,
@@ -495,15 +506,15 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
495506 </ div >
496507 < div class ="divider "> </ div >
497508 < div class ="toggle-container centered "
498- title =${ ifDefined ( disabledReason ) }
509+ title =${ ifDefined ( disabledReasonsJoined ) }
499510 @click =${ this . #toggleAiAssistanceSetting. bind ( this ) }
500511 >
501512 < devtools-switch
502- .checked =${ Boolean ( this . #aiAssistanceSetting?. get ( ) ) && ! Boolean ( disabledReason ) }
513+ .checked =${ Boolean ( this . #aiAssistanceSetting?. get ( ) ) && ! isDisabled }
503514 .jslogContext =${ this . #aiAssistanceSetting?. name || '' }
504- .disabled=${ Boolean ( disabledReason ) }
515+ .disabled=${ isDisabled }
505516 @switchchange=${ this . #toggleAiAssistanceSetting. bind ( this ) }
506- aria-label=${ disabledReason || i18nString ( UIStrings . enableAiAssistance ) }
517+ aria-label=${ disabledReasonsJoined || i18nString ( UIStrings . enableAiAssistance ) }
507518 > </ devtools-switch >
508519 </ div >
509520 < div class =${ classMap ( detailsClasses ) } >
@@ -531,37 +542,41 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
531542 // clang-format on
532543 }
533544
534- #renderDisabledExplainer( disabledReason : string ) : LitHtml . LitTemplate {
545+ #renderDisabledExplainer( disabledReasons : string [ ] ) : LitHtml . LitTemplate {
535546 // Disabled until https://crbug.com/1079231 is fixed.
536547 // clang-format off
537548 return html `
538549 < div class ="disabled-explainer ">
539- < devtools-icon .data =${ {
540- iconName : 'warning' ,
541- color : 'var(--sys-color-orange)' ,
542- width : 'var(--sys-size-8)' ,
543- height : 'var(--sys-size-8)' ,
544- } as IconButton . Icon . IconData } >
545- </ devtools-icon >
546- ${ disabledReason }
550+ ${ disabledReasons . map ( reason => html `
551+ < div class ="disabled-explainer-row ">
552+ < devtools-icon .data =${ {
553+ iconName : 'warning' ,
554+ color : 'var(--sys-color-orange)' ,
555+ width : 'var(--sys-size-8)' ,
556+ height : 'var(--sys-size-8)' ,
557+ } as IconButton . Icon . IconData } >
558+ </ devtools-icon >
559+ ${ reason }
560+ </ div >
561+ ` ) }
547562 </ div >
548563 ` ;
549564 // clang-format on
550565 }
551566
552567 override async render ( ) : Promise < void > {
553- const disabledReason = this . #getDisabledReason ( ) ;
568+ const disabledReasons = this . #getDisabledReasons ( ) ;
554569
555570 // Disabled until https://crbug.com/1079231 is fixed.
556571 // clang-format off
557572 LitHtml . render ( html `
558573 < div class ="settings-container-wrapper " jslog =${ VisualLogging . pane ( 'chrome-ai' ) } >
559574 ${ this . #renderSharedDisclaimer( ) }
560575 ${ this . #consoleInsightsSetting || this . #aiAssistanceSetting ? html `
561- ${ Boolean ( disabledReason ) ? this . #renderDisabledExplainer( disabledReason as string ) : LitHtml . nothing }
576+ ${ disabledReasons . length ? this . #renderDisabledExplainer( disabledReasons ) : LitHtml . nothing }
562577 < div class ="settings-container ">
563- ${ this . #consoleInsightsSetting ? this . #renderConsoleInsightsSetting( disabledReason ) : LitHtml . nothing }
564- ${ this . #aiAssistanceSetting ? this . #renderAiAssistanceSetting( disabledReason ) : LitHtml . nothing }
578+ ${ this . #consoleInsightsSetting ? this . #renderConsoleInsightsSetting( disabledReasons ) : LitHtml . nothing }
579+ ${ this . #aiAssistanceSetting ? this . #renderAiAssistanceSetting( disabledReasons ) : LitHtml . nothing }
565580 </ div >
566581 ` : LitHtml . nothing }
567582 </ div >
0 commit comments