Skip to content

Commit

Permalink
[SHv2] Make Safety Hub entry point icon color dynamic
Browse files Browse the repository at this point in the history
The entry point icon on the Privacy page should be blue when there are recommendations and grey otherwise. Make sure the other entry points
(on Site Settings and Notifications pages) are always blue.

Bug: 1443466
Screenshots: https://crbug.com/1443466#c107
Change-Id: I2911759044995c942a1120ef1e8ab710b5512682
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4982285
Reviewed-by: Side YILMAZ <sideyilmaz@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Aisulu Rakhmetullina <aisulu@google.com>
Cr-Commit-Position: refs/heads/main@{#1216219}
  • Loading branch information
Aisulu Rakhmetullina authored and Chromium LUCI CQ committed Oct 27, 2023
1 parent 13c509e commit e62c070
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ <h2>$i18n{siteSettingsDefaultBehavior}</h2>
<settings-safety-hub-module id="safetyHubEntryPoint"
header="[[notificationPermissionsReviewHeader_]]"
subheader="[[notificationPermissionsReviewSubheader_]]"
header-icon="cr:security">
header-icon="cr:security" header-icon-color="blue">
<cr-button id="safetyHubButton" slot="button-container"
on-click="onSafetyHubButtonClick_">
$i18n{safetyHubEntryPointButton}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<style include="cr-shared-style">
</style>

<!-- TODO(1443466): Change icon color based on state. -->
<!-- TODO(1443466): Right-align button. -->
<settings-safety-hub-module class="cr-row first" id="module"
header$="[[headerString_]]" subheader$="[[subheaderString_]]"
header-icon="cr:security">
header-icon-color$="[[headerIconColor_]]" header-icon="cr:security">
<cr-button id="button" on-click="onClick_" slot="button-container"
class$="[[buttonClass_]]">
$i18n{safetyHubEntryPointButton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export class SettingsSafetyHubEntryPointElement extends
},

subheaderString_: String,

headerIconColor_: {
type: String,
computed: 'computeHeaderIconColor_(hasRecommendations_)',
},
};
}

Expand All @@ -67,6 +72,7 @@ export class SettingsSafetyHubEntryPointElement extends
private hasRecommendations_: boolean;
private headerString_: string;
private subheaderString_: string;
private headerIconColor_: string;

override connectedCallback() {
super.connectedCallback();
Expand All @@ -90,6 +96,10 @@ export class SettingsSafetyHubEntryPointElement extends
'';
}

private computeHeaderIconColor_() {
return this.hasRecommendations_ ? 'blue' : '';
}

private onClick_() {
Router.getInstance().navigateTo(routes.SAFETY_HUB);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,12 @@ export class SettingsSafetyHubModuleElement extends
}

private onHeaderIconChanged_() {
switch (this.headerIcon) {
case 'cr:check':
this.headerIconColor = 'green';
break;
case 'cr:security':
this.headerIconColor = 'blue';
break;
default:
this.headerIconColor = '';
// The check icon is always green for all Safety Hub modules.
if (this.headerIcon === 'cr:check') {
this.headerIconColor = 'green';
// The Safety Check icon color is managed in specific Safety Hub modules.
} else if (this.headerIcon !== 'cr:security') {
this.headerIconColor = '';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<settings-safety-hub-module id="safetyHubModule"
header="[[unusedSitePermissionsHeader_]]"
subheader="[[unusedSitePermissionsSubheader_]]"
header-icon="cr:security">
header-icon="cr:security" header-icon-color="blue">
<cr-button id="safetyHubButton" slot="button-container"
on-click="onSafetyHubButtonClick_">
$i18n{safetyHubEntryPointButton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {TestSafetyHubBrowserProxy} from './test_safety_hub_browser_proxy.js';

// clang-format on

suite('SafetyHubEntryPointUI', function() {
suite('SafetyHubEntryPoint', function() {
let browserProxy: TestSafetyHubBrowserProxy;
let page: SettingsSafetyHubEntryPointElement;

Expand Down Expand Up @@ -47,6 +47,9 @@ suite('SafetyHubEntryPointUI', function() {
page.i18n('safetyHubEntryPointHeader'));
assertTrue(page.$.module.hasAttribute('subheader'));
assertEquals(page.$.module.getAttribute('subheader')!.trim(), subheader);
assertTrue(page.$.module.hasAttribute('header-icon-color'));
assertEquals(
page.$.module.getAttribute('header-icon-color')!.trim(), 'blue');

// Entry point has primary button leading to Safety Hub.
assertEquals(page.$.button!.getAttribute('class'), 'action-button');
Expand All @@ -65,6 +68,8 @@ suite('SafetyHubEntryPointUI', function() {
assertEquals(
page.$.module.getAttribute('subheader')!.trim(),
page.i18n('safetyHubEntryPointNothingToDo'));
assertTrue(page.$.module.hasAttribute('header-icon-color'));
assertEquals(page.$.module.getAttribute('header-icon-color')!.trim(), '');

// Entry point has secondary button leading to Safety Hub.
assertEquals(page.$.button!.getAttribute('class'), '');
Expand Down

0 comments on commit e62c070

Please sign in to comment.