33// found in the LICENSE file.
44
55import '../../../../ui/components/icon_button/icon_button.js' ;
6+ import '../../../../ui/components/tooltips/tooltips.js' ;
67
78import * as Common from '../../../../core/common/common.js' ;
89import * as i18n from '../../../../core/i18n/i18n.js' ;
910import * as Platform from '../../../../core/platform/platform.js' ;
1011import * as Root from '../../../../core/root/root.js' ;
12+ import * as Buttons from '../../../../ui/components/buttons/buttons.js' ;
1113import * as ComponentHelpers from '../../../../ui/components/helpers/helpers.js' ;
1214import * as UI from '../../../../ui/legacy/legacy.js' ;
1315import * as ThemeSupport from '../../../../ui/legacy/theme_support/theme_support.js' ;
@@ -17,7 +19,7 @@ import * as PanelCommon from '../../../common/common.js';
1719
1820import stylesRaw from './entryLabelOverlay.css.js' ;
1921
20- const { html} = Lit ;
22+ const { html, Directives } = Lit ;
2123
2224// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
2325const styles = new CSSStyleSheet ( ) ;
@@ -42,6 +44,10 @@ const UIStrings = {
4244* Strings that don't need to be translated at this time.
4345*/
4446const UIStringsNotTranslate = {
47+ /**
48+ *@description Tooltip link for the navigating to "AI innovations" page in settings.
49+ */
50+ learnMore : 'Learn more' ,
4551 /**
4652 *@description Security disclaimer text displayed when the information icon on a button that generates an AI label is hovered.
4753 */
@@ -55,12 +61,11 @@ const UIStringsNotTranslate = {
5561 /**
5662 *@description The `Generate AI label button` tooltip disclaimer for when the feature is not available and the reason can be checked in settings.
5763 */
58- autoAnnotationNotAvailableDisclaimer :
59- 'Auto anotations are not available, go to AI Innovations in Settings to learn more.' ,
64+ autoAnnotationNotAvailableDisclaimer : 'Auto annotations are not available.' ,
6065 /**
6166 *@description The `Generate AI label button` tooltip disclaimer for when the feature is not available because the user is offline.
6267 */
63- autoAnnotationNotAvailableOfflineDisclaimer : 'Auto anotations are not available because you are offline.' ,
68+ autoAnnotationNotAvailableOfflineDisclaimer : 'Auto annotations are not available because you are offline.' ,
6469 /**
6570 *@description Header text for the AI-powered annotations suggestions disclaimer dialog.
6671 */
@@ -137,6 +142,7 @@ export class EntryLabelOverlay extends HTMLElement {
137142 #connectorLineContainer: SVGAElement | null = null ;
138143 #label: string ;
139144 #shouldDrawBelowEntry: boolean ;
145+ #richTooltip: Lit . Directives . Ref < HTMLElement > = Directives . createRef ( ) ;
140146 /**
141147 * The entry label overlay consists of 3 parts - the label part with the label string inside,
142148 * the line connecting the label to the entry, and a black box around an entry to highlight the entry with a label.
@@ -459,6 +465,26 @@ export class EntryLabelOverlay extends HTMLElement {
459465 ! Root . Runtime . hostConfig . aidaAvailability ?. blockedByGeo && ! navigator . onLine === false ;
460466 }
461467
468+ #renderAITooltip( opts : { textContent : string , includeSettingsButton : boolean } ) : Lit . TemplateResult {
469+ // clang-format off
470+ return html `< devtools-tooltip variant ="rich " id ="info-tooltip " ${ Directives . ref ( this . #richTooltip) } >
471+ < div class ="info-tooltip-container ">
472+ ${ opts . textContent }
473+ ${ opts . includeSettingsButton ? html `
474+ < button
475+ class ="link tooltip-link "
476+ role ="link "
477+ jslog =${ VisualLogging . link ( 'open-ai-settings' ) . track ( {
478+ click : true ,
479+ } ) }
480+ @click =${ this . #onTooltipLearnMoreClick}
481+ > ${ lockedString ( UIStringsNotTranslate . learnMore ) } </ button >
482+ ` : Lit . nothing }
483+ </ div >
484+ </ devtools-tooltip > ` ;
485+ // clang-format on
486+ }
487+
462488 #renderAiButton( ) : Lit . TemplateResult {
463489 const noLogging = Root . Runtime . hostConfig . aidaAvailability ?. enterprisePolicyValue ===
464490 Root . Runtime . GenAiEnterprisePolicyValue . ALLOW_WITHOUT_LOGGING ;
@@ -480,18 +506,26 @@ export class EntryLabelOverlay extends HTMLElement {
480506 </ devtools-icon >
481507 < span class ="generate-label-text "> ${ i18nString ( UIStrings . generateLabelButton ) } </ span >
482508 </ button >
483- < devtools-icon
509+ < devtools-button
510+ aria-details ="info-tooltip "
484511 class ="pen-icon "
485- title =${ noLogging ? lockedString ( UIStringsNotTranslate . generateLabelSecurityDisclaimerLogginOff ) : lockedString ( UIStringsNotTranslate . generateLabelSecurityDisclaimer ) }
486- .name =${ 'info' }
487- .data=${ {
488- iconName : 'info' , color : 'var(--color-background-inverted)' , width : '20px' } } >
489- </ devtools-icon >
512+ .iconName =${ 'info' }
513+ .variant =${ Buttons . Button . Variant . ICON }
514+ > </ devtools-button >
515+ ${ this . #renderAITooltip( {
516+ textContent : noLogging ? lockedString ( UIStringsNotTranslate . generateLabelSecurityDisclaimerLogginOff ) : lockedString ( UIStringsNotTranslate . generateLabelSecurityDisclaimer ) ,
517+ includeSettingsButton : true ,
518+ } ) }
490519 </ span >
491520 ` ;
492521 // clang-format on
493522 }
494523
524+ #onTooltipLearnMoreClick( ) : void {
525+ this . #richTooltip?. value ?. hidePopover ( ) ;
526+ void UI . ViewManager . ViewManager . instance ( ) . showView ( 'chrome-ai' ) ;
527+ }
528+
495529 // The disabled button rendered when the `generate AI label` feature is not available
496530 // because of the geolocation, age or if they are not logged in into the google account.
497531 //
@@ -509,13 +543,17 @@ export class EntryLabelOverlay extends HTMLElement {
509543 ?disabled =${ true }
510544 @click =${ this . #handleAiButtonClick} >
511545 < devtools-icon
546+ aria-details ="info-tooltip "
512547 class ="pen-icon "
513- title =${ noConnection ? lockedString ( UIStringsNotTranslate . autoAnnotationNotAvailableOfflineDisclaimer ) : lockedString ( UIStringsNotTranslate . autoAnnotationNotAvailableDisclaimer ) }
514548 .name =${ 'pen-spark' }
515549 .data =${ {
516550 iconName : 'pen-spark' , color : 'var(--sys-color-state-disabled)' , width : '20px' } } >
517551 </ devtools-icon >
518552 </ button >
553+ ${ this . #renderAITooltip( {
554+ textContent : noConnection ? lockedString ( UIStringsNotTranslate . autoAnnotationNotAvailableOfflineDisclaimer ) : lockedString ( UIStringsNotTranslate . autoAnnotationNotAvailableDisclaimer ) ,
555+ includeSettingsButton : ! noConnection ,
556+ } ) }
519557 </ span >
520558 ` ;
521559 // clang-format on
0 commit comments