Commit 4ab9a24c authored by Rainhard Findling's avatar Rainhard Findling Committed by Commit Bot

Safety check UI: collapse for children elements

* Adds the safety check collapse for safety check children elements
* Adds common styling used by multiple children

Bug: 1015841
Change-Id: I8dfb3d325d4134d7804155ee3d1b8af822c44cdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2070239
Commit-Queue: Rainhard Findling <rainhard@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744613}
parent f0e35bae
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<link rel="import" href="chrome://resources/html/assert.html"> <link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="../i18n_setup.html"> <link rel="import" href="../i18n_setup.html">
<link rel="import" href="../prefs/prefs_behavior.html"> <link rel="import" href="../prefs/prefs_behavior.html">
...@@ -17,9 +18,9 @@ ...@@ -17,9 +18,9 @@
<!-- // TODO(crbug.com/1010001): Release block M82 beta: <!-- // TODO(crbug.com/1010001): Release block M82 beta:
Support dark mode. --> Support dark mode. -->
<style include="settings-shared"> <style include="settings-shared">
.icon-blue { #safetyCheckCollapse .list-item.selected {
fill: var(--google-blue-600); min-height: var(--settings-row-two-line-min-height);
} }
iron-icon { iron-icon {
display: flex; display: flex;
...@@ -27,6 +28,14 @@ ...@@ -27,6 +28,14 @@
padding-inline-end: var(--cr-icon-button-margin-start); padding-inline-end: var(--cr-icon-button-margin-start);
width: var(--cr-link-row-icon-width, var(--cr-icon-size)); width: var(--cr-link-row-icon-width, var(--cr-icon-size));
} }
.icon-blue {
fill: var(--google-blue-600);
}
.icon-red {
fill: var(--google-red-600);
}
</style> </style>
<div class="settings-box first two-line"> <div class="settings-box first two-line">
<iron-icon icon="[[getParentIcon_(parentStatus_)]]" <iron-icon icon="[[getParentIcon_(parentStatus_)]]"
...@@ -36,14 +45,15 @@ ...@@ -36,14 +45,15 @@
<div class="start settings-box-text" no-search> <div class="start settings-box-text" no-search>
[[getParentPrimaryLabelText_(parentStatus_)]] [[getParentPrimaryLabelText_(parentStatus_)]]
</div> </div>
<template is="dom-if" if="[[showParentButton_(parentStatus_)]]" restamp> <template is="dom-if" if="[[shouldShowParentButton_(parentStatus_)]]"
restamp>
<div class="separator"></div> <div class="separator"></div>
<cr-button id="safetyCheckParentButton" <cr-button id="safetyCheckParentButton"
on-click="onRunSafetyCheckClick_" no-search> on-click="onRunSafetyCheckClick_" no-search>
$i18n{safetyCheckParentButton} $i18n{safetyCheckParentButton}
</cr-button> </cr-button>
</template> </template>
<template is="dom-if" if="[[showParentIconButton_(parentStatus_)]]" <template is="dom-if" if="[[shouldShowParentIconButton_(parentStatus_)]]"
restamp> restamp>
<div class="separator"></div> <div class="separator"></div>
<cr-icon-button id="safetyCheckParentIconButton" <cr-icon-button id="safetyCheckParentIconButton"
...@@ -52,6 +62,9 @@ ...@@ -52,6 +62,9 @@
</cr-icon-button> </cr-icon-button>
</template> </template>
</div> </div>
<iron-collapse id="safetyCheckCollapse"
opened="[[shouldShowChildren_(parentStatus_)]]">
</iron-collapse>
</template> </template>
<script src="safety_check_page.js"></script> <script src="safety_check_page.js"></script>
</dom-module> </dom-module>
...@@ -155,27 +155,22 @@ Polymer({ ...@@ -155,27 +155,22 @@ Polymer({
this.updatesStatus_ = status; this.updatesStatus_ = status;
break; break;
case SafetyCheckComponent.PASSWORDS: case SafetyCheckComponent.PASSWORDS:
this.passwordsStatus_ = status;
this.passwordsCompromisedCount_ = event['passwordsCompromised']; this.passwordsCompromisedCount_ = event['passwordsCompromised'];
this.passwordsStatus_ = status;
break; break;
case SafetyCheckComponent.SAFE_BROWSING: case SafetyCheckComponent.SAFE_BROWSING:
this.safeBrowsingStatus_ = status; this.safeBrowsingStatus_ = status;
break; break;
case SafetyCheckComponent.EXTENSIONS: case SafetyCheckComponent.EXTENSIONS:
this.extensionsStatus_ = status;
this.badExtensionsCount_ = event['badExtensions']; this.badExtensionsCount_ = event['badExtensions'];
this.extensionsStatus_ = status;
break; break;
default: default:
assertNotReached(); assertNotReached();
} }
// If all children elements received updates: update parent element. // If all children elements received updates: update parent element.
if (this.updatesStatus_ != settings.SafetyCheckUpdatesStatus.CHECKING && if (this.areAllChildrenStatesSet_()) {
this.passwordsStatus_ != settings.SafetyCheckPasswordsStatus.CHECKING &&
this.safeBrowsingStatus_ !=
settings.SafetyCheckSafeBrowsingStatus.CHECKING &&
this.extensionsStatus_ !=
settings.SafetyCheckExtensionsStatus.CHECKING) {
this.parentStatus_ = ParentStatus.AFTER; this.parentStatus_ = ParentStatus.AFTER;
} }
}, },
...@@ -184,7 +179,19 @@ Polymer({ ...@@ -184,7 +179,19 @@ Polymer({
* @private * @private
* @return {boolean} * @return {boolean}
*/ */
showParentButton_: function() { areAllChildrenStatesSet_: function() {
return this.updatesStatus_ != settings.SafetyCheckUpdatesStatus.CHECKING &&
this.passwordsStatus_ != settings.SafetyCheckPasswordsStatus.CHECKING &&
this.safeBrowsingStatus_ !=
settings.SafetyCheckSafeBrowsingStatus.CHECKING &&
this.extensionsStatus_ != settings.SafetyCheckExtensionsStatus.CHECKING;
},
/**
* @private
* @return {boolean}
*/
shouldShowParentButton_: function() {
return this.parentStatus_ == ParentStatus.BEFORE; return this.parentStatus_ == ParentStatus.BEFORE;
}, },
...@@ -192,7 +199,7 @@ Polymer({ ...@@ -192,7 +199,7 @@ Polymer({
* @private * @private
* @return {boolean} * @return {boolean}
*/ */
showParentIconButton_: function() { shouldShowParentIconButton_: function() {
return this.parentStatus_ == ParentStatus.AFTER; return this.parentStatus_ == ParentStatus.AFTER;
}, },
...@@ -254,11 +261,17 @@ Polymer({ ...@@ -254,11 +261,17 @@ Polymer({
case ParentStatus.BEFORE: case ParentStatus.BEFORE:
case ParentStatus.CHECKING: case ParentStatus.CHECKING:
return 'icon-blue'; return 'icon-blue';
case ParentStatus.AFTER:
return '';
default: default:
assertNotReached(); return '';
} }
}, },
/**
* @private
* @return {boolean}
*/
shouldShowChildren_: function() {
return this.parentStatus_ != ParentStatus.BEFORE;
},
}); });
})(); })();
...@@ -17,13 +17,17 @@ suite('SafetyCheckUiTests', function() { ...@@ -17,13 +17,17 @@ suite('SafetyCheckUiTests', function() {
page.remove(); page.remove();
}); });
test('parentBeforeCheckUiTest', function() { /** Tests parent element and collapse. */
test('beforeCheckUiTest', function() {
// Only the text button is present. // Only the text button is present.
assertTrue(!!page.$$('#safetyCheckParentButton')); assertTrue(!!page.$$('#safetyCheckParentButton'));
assertFalse(!!page.$$('#safetyCheckParentIconButton')); assertFalse(!!page.$$('#safetyCheckParentIconButton'));
// Collapse is not opened.
assertFalse(page.$$('#safetyCheckCollapse').opened);
}); });
test('parentDuringCheckUiTest', function() { /** Tests parent element and collapse. */
test('duringCheckUiTest', function() {
// User starts check. // User starts check.
page.$$('#safetyCheckParentButton').click(); page.$$('#safetyCheckParentButton').click();
...@@ -31,9 +35,12 @@ suite('SafetyCheckUiTests', function() { ...@@ -31,9 +35,12 @@ suite('SafetyCheckUiTests', function() {
// No button is present. // No button is present.
assertFalse(!!page.$$('#safetyCheckParentButton')); assertFalse(!!page.$$('#safetyCheckParentButton'));
assertFalse(!!page.$$('#safetyCheckParentIconButton')); assertFalse(!!page.$$('#safetyCheckParentIconButton'));
// Collapse is opened.
assertTrue(page.$$('#safetyCheckCollapse').opened);
}); });
test('parentAfterCheckUiTest', function() { /** Tests parent element and collapse. */
test('afterCheckUiTest', function() {
// User starts check. // User starts check.
page.$$('#safetyCheckParentButton').click(); page.$$('#safetyCheckParentButton').click();
...@@ -60,5 +67,7 @@ suite('SafetyCheckUiTests', function() { ...@@ -60,5 +67,7 @@ suite('SafetyCheckUiTests', function() {
// Only the icon button is present. // Only the icon button is present.
assertFalse(!!page.$$('#safetyCheckParentButton')); assertFalse(!!page.$$('#safetyCheckParentButton'));
assertTrue(!!page.$$('#safetyCheckParentIconButton')); assertTrue(!!page.$$('#safetyCheckParentIconButton'));
// Collapse is opened.
assertTrue(page.$$('#safetyCheckCollapse').opened);
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment