Skip to content

Commit 386f50e

Browse files
Natallia HarshunovaDevtools-frontend LUCI CQ
authored andcommitted
Implement the "Relevant data" rich tooltip in Settings page
According to the design, we're going to have a "Relevant data" tooltip in the settings section Bug: 442032513 Change-Id: I2a5930339baa49b3566aca881c7fb2b2c37835d4 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6945496 Auto-Submit: Natallia Harshunova <[email protected]> Commit-Queue: Natallia Harshunova <[email protected]> Reviewed-by: Ergün Erdoğmuş <[email protected]>
1 parent 12ec291 commit 386f50e

File tree

6 files changed

+71
-23
lines changed

6 files changed

+71
-23
lines changed

front_end/entrypoints/main/main-meta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ const UIStrings = {
195195
* @description Label for a checkbox in the settings UI. Allows developers to opt-in/opt-out
196196
* of receiving Google Developer Program (GDP) badges based on their activity in Chrome DevTools.
197197
*/
198-
receiveBadges: 'Receive badges',
198+
earnBadges: 'Earn badges',
199199
/**
200200
* @description A command available in the command menu to perform searches, for example in the
201201
* elements panel, as user types, rather than only when they press Enter.
@@ -799,7 +799,7 @@ Common.Settings.registerSettingExtension({
799799
settingName: 'receive-gdp-badges',
800800
settingType: Common.Settings.SettingType.BOOLEAN,
801801
storageType: Common.Settings.SettingStorageType.SYNCED,
802-
title: i18nLazyString(UIStrings.receiveBadges),
802+
title: i18nLazyString(UIStrings.earnBadges),
803803
defaultValue: false,
804804
reloadRequired: true,
805805
});

front_end/panels/common/BadgeNotification.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ describeWithEnvironment('BadgeNotification', () => {
105105

106106
assert.strictEqual(input.imageUri, badge.imageUri);
107107
assert.lengthOf(input.actions, 2);
108-
assert.strictEqual(input.actions[0].label, 'Badge settings');
108+
assert.strictEqual(input.actions[0].label, 'Manage settings');
109109
assert.strictEqual(input.actions[1].label, 'View profile');
110-
assertMessageIncludes(input.message, 'It has been added to your Developer Profile.');
110+
assertMessageIncludes(input.message, 'It’s been added to your Developer Profile.');
111111

112112
widget.detach();
113113
});
@@ -126,9 +126,9 @@ describeWithEnvironment('BadgeNotification', () => {
126126
// Should fall back to the activity-based badge flow.
127127
assert.strictEqual(input.imageUri, 'starter-badge-image-uri');
128128
assert.lengthOf(input.actions, 2);
129-
assert.strictEqual(input.actions[0].label, 'Badge settings');
129+
assert.strictEqual(input.actions[0].label, 'Manage settings');
130130
assert.strictEqual(input.actions[1].label, 'View profile');
131-
assertMessageIncludes(input.message, 'It has been added to your Developer Profile.');
131+
assertMessageIncludes(input.message, 'It’s been added to your Developer Profile.');
132132

133133
widget.detach();
134134
});
@@ -146,7 +146,7 @@ describeWithEnvironment('BadgeNotification', () => {
146146
assert.strictEqual(input.imageUri, badge.imageUri);
147147
assert.lengthOf(input.actions, 2);
148148
assert.strictEqual(input.actions[0].label, 'Remind me later');
149-
assert.strictEqual(input.actions[1].label, 'Receive badges');
149+
assert.strictEqual(input.actions[1].label, 'Turn on badges');
150150
assertMessageIncludes(input.message, 'Turn on badges to claim it.');
151151

152152
widget.detach();

front_end/panels/common/BadgeNotification.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ const UIStrings = {
2626
* @description Activity based badge award notification text
2727
* @example {Badge Title} PH1
2828
*/
29-
activityBasedBadgeAwardMessage: 'You earned the {PH1} badge! It has been added to your Developer Profile.',
29+
activityBasedBadgeAwardMessage: 'You earned the {PH1} badge! It’s been added to your Developer Profile.',
3030
/**
3131
* @description Action title for navigating to the badge settings in Google Developer Profile section
3232
*/
33-
badgeSettings: 'Badge settings',
33+
manageSettings: 'Manage settings',
3434
/**
3535
* @description Action title for opening the Google Developer Program profile page of the user in a new tab
3636
*/
@@ -55,7 +55,7 @@ const UIStrings = {
5555
/**
5656
* @description Action title for enabling the "Receive badges" setting
5757
*/
58-
receiveBadges: 'Receive badges',
58+
receiveBadges: 'Turn on badges',
5959
/**
6060
* @description Action title for creating a Google Developer Program profle
6161
*/
@@ -240,7 +240,7 @@ export class BadgeNotification extends UI.Widget.Widget {
240240
message: i18nString(UIStrings.activityBasedBadgeAwardMessage, {PH1: badge.title}),
241241
actions: [
242242
{
243-
label: i18nString(UIStrings.badgeSettings),
243+
label: i18nString(UIStrings.manageSettings),
244244
onClick: () => {
245245
this.#close();
246246
revealBadgeSettings();

front_end/panels/common/GdpSignUpDialog.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,32 @@ const UIStrings = {
3939
/**
4040
* @description Body for the first section of the GDP sign up dialog.
4141
*/
42-
designedForSuccessBody:
43-
'Grow your skills, build with AI, and receive badges you can showcase in your developer profile',
42+
designedForSuccessBody: 'Grow your skills, build with AI, and earn badges you can showcase in your developer profile',
4443
/**
4544
* @description Title for the second section of the GDP sign up dialog.
4645
*/
4746
keepUpdated: 'Keep me updated',
4847
/**
4948
* @description Body for the second section of the GDP sign up dialog.
5049
*/
51-
keepUpdatedBody: 'The latest DevTools features, event invites, and tailored insights directly in your inbox',
50+
keepUpdatedBody: 'The latest DevTools features, event invites, and tailored insights land directly in your inbox',
5251
/**
5352
* @description Title for the third section of the GDP sign up dialog.
5453
*/
55-
thingsToConsider: 'Things to consider',
54+
tailorProfile: 'Tailor your profile',
55+
/**
56+
* @description Body for the third section of the GDP sign up dialog.
57+
*/
58+
tailorProfileBody:
59+
'The name on your Google Account and your interests will be used in your Google Developer Profile. Your name may appear where you contribute and can be changed at any time.',
5660
/**
5761
* @description Body for the third section of the GDP sign up dialog.
5862
* @example {Content Policy} PH1
5963
* @example {Terms of Service} PH2
6064
* @example {Privacy Policy} PH3
6165
*/
62-
thingsToConsiderBody:
63-
'By creating a Developer Profile, you agree to the {PH1}. Google’s {PH2} and {PH3} apply to your use of this service. The name on your Google Account and your interests will be used in your Google Developer Profile. Your name may appear where you contribute and can be changed at any time.',
66+
tailorProfileBodyDisclaimer:
67+
'By creating a Developer Profile, you agree to the {PH1}. Google’s {PH2} and {PH3} apply to your use of this service.',
6468
/**
6569
* @description Button text for learning more about the Google Developer Program.
6670
*/
@@ -140,14 +144,17 @@ export const DEFAULT_VIEW: View = (input, _output, target): void => {
140144
<devtools-icon name="google"></devtools-icon>
141145
</div>
142146
<div class="text-container">
143-
<h3 class="section-title">${i18nString(UIStrings.thingsToConsider)}</h3>
144-
<div class="section-text">${i18n.i18n.getFormatLocalizedString(str_, UIStrings.thingsToConsiderBody, {
147+
<h3 class="section-title">${i18nString(UIStrings.tailorProfile)}</h3>
148+
<div class="section-text">
149+
<div>${i18nString(UIStrings.tailorProfileBody)}</div><br/>
150+
<div>${i18n.i18n.getFormatLocalizedString(str_, UIStrings.tailorProfileBodyDisclaimer, {
145151
PH1: UI.XLink.XLink.create(CONTENT_POLICY_URL, i18nString(UIStrings.contentPolicy), 'link', undefined, 'gdp.content-policy'),
146152
PH2: UI.XLink.XLink.create(TERMS_OF_SERVICE_URL, i18nString(UIStrings.termsOfService), 'link',
147153
undefined, 'gdp.terms-of-service'),
148154
PH3: UI.XLink.XLink.create(PRIVACY_POLICY_URL, i18nString(UIStrings.privacyPolicy), 'link',
149155
undefined, 'gdp.privacy-policy'),
150156
})}</div>
157+
</div>
151158
</div>
152159
</div>
153160
</div>

front_end/panels/settings/components/SyncSection.ts

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,55 @@ const UIStrings = {
7777
* @description Label for Sign-Up button for the Google Developer Program profiles.
7878
*/
7979
signUp: 'Sign up',
80+
/**
81+
* @description Link text for opening the Google Developer Program profile page.
82+
*/
83+
viewProfile: 'View profile',
84+
/**
85+
* @description Text for tooltip shown on hovering over "Relevant Data" in the disclaimer text for AI code completion.
86+
*/
87+
tooltipDisclaimerText:
88+
'When you qualify for a badge, the badge’s identifier and the type of activity you did to earn it are sent to Google',
8089
/**
8190
* @description Text for the data notice right after the settings checkbox.
8291
*/
83-
relevantDataDisclaimer: '(Relevant data is sent to Google)',
92+
relevantData: 'Relevant data',
8493
/**
85-
* @description Link text for opening the Google Developer Program profile page.
94+
* @description Text for the data notice right after the settings checkbox.
95+
* @example {Relevant data} PH1
8696
*/
87-
viewProfile: 'View profile',
97+
dataDisclaimer: '({PH1} is sent to Google)',
8898
} as const;
8999
const str_ = i18n.i18n.registerUIStrings('panels/settings/components/SyncSection.ts', UIStrings);
90100
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
91101

92102
const {html, Directives: {ref, createRef}} = Lit;
93103

104+
let cachedTooltipElement: HTMLElement|undefined;
105+
106+
function renderDataDisclaimer(): HTMLElement {
107+
if (cachedTooltipElement) {
108+
return cachedTooltipElement;
109+
}
110+
111+
const relevantDataTooltipTemplate = html`
112+
<span
113+
tabIndex="0"
114+
class="link"
115+
aria-details="gdp-profile-tooltip"
116+
>${i18nString(UIStrings.relevantData)}</span>
117+
<devtools-tooltip id="gdp-profile-tooltip" variant=${'rich'}>
118+
<div class="tooltip-content">${i18nString(UIStrings.tooltipDisclaimerText)}</div>
119+
</devtools-tooltip>`;
120+
121+
const container = document.createElement('span');
122+
Lit.render(relevantDataTooltipTemplate, container);
123+
cachedTooltipElement = i18n.i18n.getFormatLocalizedString(str_, UIStrings.dataDisclaimer, {
124+
PH1: container,
125+
});
126+
return cachedTooltipElement;
127+
}
128+
94129
function getGdpSubscriptionText(profile: Host.GdpClient.Profile): Platform.UIString.LocalizedString {
95130
if (!profile.activeSubscription ||
96131
profile.activeSubscription.subscriptionStatus !== Host.GdpClient.SubscriptionStatus.ENABLED) {
@@ -289,7 +324,7 @@ function renderGdpSectionIfNeeded({
289324
Badges.UserBadges.instance().recordAction(Badges.BadgeAction.RECEIVE_BADGES_SETTING_ENABLED);
290325
});
291326
}}></setting-checkbox>
292-
<span>${i18nString(UIStrings.relevantDataDisclaimer)}</span>
327+
${renderDataDisclaimer()}
293328
</div>` : Lit.nothing}
294329
</div>
295330
` : html`

front_end/panels/settings/components/syncSection.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,11 @@ fieldset {
114114
align-items: center;
115115
gap: var(--sys-size-2);
116116
}
117+
118+
& .tooltip-content {
119+
max-width: 278px;
120+
padding: var(--sys-size-2) var(--sys-size-3);
121+
font: var(--sys-typescale-body5-regular);
122+
}
117123
}
118124
}

0 commit comments

Comments
 (0)