Commit b3de1b05 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[Dice] Add error action button to account control in settings

When the user has an actionable sync error, a button to resolve
the error is shown in the sync account control row on settings
pages.

Exception: The passphrase action button is not shown on the sync
page because this page has its customized passphrase UI.

Bug: 902949
Change-Id: I558a79be8cb75f2a9260bf8e3236e7ef956627db
Reviewed-on: https://chromium-review.googlesource.com/c/1333768
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608405}
parent 40935b1b
...@@ -7123,7 +7123,7 @@ Please help our engineers fix this problem. Tell us what happened right before y ...@@ -7123,7 +7123,7 @@ Please help our engineers fix this problem. Tell us what happened right before y
</if> </if>
<if expr="not chromeos"> <if expr="not chromeos">
<message name="IDS_SYNC_RELOGIN_LINK_LABEL" desc="The text to display on in the hyperlink when the user needs to sign in again to use sync."> <message name="IDS_SYNC_RELOGIN_LINK_LABEL" desc="The text to display on in the hyperlink when the user needs to sign in again to use sync.">
Sign in Sign in again
</message> </message>
</if> </if>
<if expr="chromeos"> <if expr="chromeos">
......
...@@ -364,13 +364,13 @@ Polymer({ ...@@ -364,13 +364,13 @@ Polymer({
onSyncTap_: function() { onSyncTap_: function() {
// When unified-consent is enabled, users can go to sync subpage regardless // When unified-consent is enabled, users can go to sync subpage regardless
// of sync status. // of sync status.
// TODO(scottchen): figure out how to deal with sync error states in the
// subpage (https://crbug.com/824546).
if (this.unifiedConsentEnabled_) { if (this.unifiedConsentEnabled_) {
settings.navigateTo(settings.routes.SYNC); settings.navigateTo(settings.routes.SYNC);
return; return;
} }
// TODO(crbug.com/862983): Remove this code once UnifiedConsent is rolled
// out to 100%.
assert(this.syncStatus.signedIn); assert(this.syncStatus.signedIn);
assert(this.syncStatus.syncSystemEnabled); assert(this.syncStatus.syncSystemEnabled);
......
...@@ -201,12 +201,11 @@ ...@@ -201,12 +201,11 @@
disabled="[[syncStatus.setupInProgress]]"> disabled="[[syncStatus.setupInProgress]]">
$i18n{turnOffSync} $i18n{turnOffSync}
</paper-button> </paper-button>
<paper-button id="sync-paused-button" class="action-button" <paper-button id="sync-error-button" class="action-button"
hidden="[[!shouldShowSigninAgainButton_( hidden="[[!shouldShowErrorActionButton_(syncStatus)]]"
syncStatus.signedIn, syncStatus.hasError, on-click="onErrorButtonTap_"
syncStatus.statusAction)]]" disabled="[[syncStatus.setupInProgress]]">
on-click="onSigninTap_" disabled="[[syncStatus.setupInProgress]]"> [[syncStatus.statusActionText]]
$i18n{signInAgain}
</paper-button> </paper-button>
</div> </div>
<template is="dom-if" if="[[!syncStatus.signedIn]]" restamp> <template is="dom-if" if="[[!syncStatus.signedIn]]" restamp>
......
...@@ -258,10 +258,16 @@ Polymer({ ...@@ -258,10 +258,16 @@ Polymer({
* @return {boolean} * @return {boolean}
* @private * @private
*/ */
shouldShowSigninAgainButton_: function() { shouldShowErrorActionButton_: function() {
if (this.embeddedInSubpage &&
this.syncStatus.statusAction ==
settings.StatusAction.ENTER_PASSPHRASE) {
// In a subpage the passphrase button is not required.
return false;
}
return !this.hideButtons && !!this.syncStatus.signedIn && return !this.hideButtons && !!this.syncStatus.signedIn &&
!!this.syncStatus.hasError && !!this.syncStatus.hasError &&
this.syncStatus.statusAction == settings.StatusAction.REAUTHENTICATE; this.syncStatus.statusAction != settings.StatusAction.NO_ACTION;
}, },
/** /**
...@@ -283,10 +289,35 @@ Polymer({ ...@@ -283,10 +289,35 @@ Polymer({
return this.syncStatus.signedIn || this.storedAccounts_.length > 0; return this.syncStatus.signedIn || this.storedAccounts_.length > 0;
}, },
/** @private */
onErrorButtonTap_: function() {
switch (this.syncStatus.statusAction) {
case settings.StatusAction.REAUTHENTICATE:
this.syncBrowserProxy_.startSignIn();
break;
case settings.StatusAction.SIGNOUT_AND_SIGNIN:
if (this.syncStatus.domain)
settings.navigateTo(settings.routes.SIGN_OUT);
else {
// Silently sign the user out without deleting their profile and
// prompt them to sign back in.
this.syncBrowserProxy_.signOut(false);
this.syncBrowserProxy_.startSignIn();
}
break;
case settings.StatusAction.UPGRADE_CLIENT:
settings.navigateTo(settings.routes.ABOUT);
break;
case settings.StatusAction.ENTER_PASSPHRASE:
case settings.StatusAction.CONFIRM_SYNC_SETTINGS:
default:
settings.navigateTo(settings.routes.SYNC);
}
},
/** @private */ /** @private */
onSigninTap_: function() { onSigninTap_: function() {
this.syncBrowserProxy_.startSignIn(); this.syncBrowserProxy_.startSignIn();
// Need to close here since one menu item also triggers this function. // Need to close here since one menu item also triggers this function.
if (this.$$('#menu')) { if (this.$$('#menu')) {
/** @type {!CrActionMenuElement} */ (this.$$('#menu')).close(); /** @type {!CrActionMenuElement} */ (this.$$('#menu')).close();
......
...@@ -30,6 +30,7 @@ settings.StoredAccount; ...@@ -30,6 +30,7 @@ settings.StoredAccount;
* signedInUsername: (string|undefined), * signedInUsername: (string|undefined),
* signinAllowed: (boolean|undefined), * signinAllowed: (boolean|undefined),
* statusAction: (!settings.StatusAction), * statusAction: (!settings.StatusAction),
* statusActionText: (string|undefined),
* statusText: (string|undefined), * statusText: (string|undefined),
* supervisedUser: (boolean|undefined), * supervisedUser: (boolean|undefined),
* syncSystemEnabled: (boolean|undefined)}} * syncSystemEnabled: (boolean|undefined)}}
......
...@@ -999,6 +999,7 @@ PeopleHandler::GetSyncStatusDictionary() { ...@@ -999,6 +999,7 @@ PeopleHandler::GetSyncStatusDictionary() {
&link_label, &link_label,
&action_type) == sync_ui_util::SYNC_ERROR; &action_type) == sync_ui_util::SYNC_ERROR;
sync_status->SetString("statusText", status_label); sync_status->SetString("statusText", status_label);
sync_status->SetString("statusActionText", link_label);
sync_status->SetBoolean("hasError", status_has_error); sync_status->SetBoolean("hasError", status_has_error);
sync_status->SetString("statusAction", GetSyncErrorAction(action_type)); sync_status->SetString("statusAction", GetSyncErrorAction(action_type));
......
...@@ -234,7 +234,7 @@ cr.define('settings_sync_account_control', function() { ...@@ -234,7 +234,7 @@ cr.define('settings_sync_account_control', function() {
assertVisible(testElement.$$('#sync-button'), false); assertVisible(testElement.$$('#sync-button'), false);
assertVisible(testElement.$$('#turn-off'), true); assertVisible(testElement.$$('#turn-off'), true);
assertVisible(testElement.$$('#sync-paused-button'), false); assertVisible(testElement.$$('#sync-error-button'), false);
testElement.$$('#avatar-row .secondary-button').click(); testElement.$$('#avatar-row .secondary-button').click();
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -257,6 +257,8 @@ cr.define('settings_sync_account_control', function() { ...@@ -257,6 +257,8 @@ cr.define('settings_sync_account_control', function() {
assertFalse(displayedText.includes('barName')); assertFalse(displayedText.includes('barName'));
assertFalse(displayedText.includes('fooName')); assertFalse(displayedText.includes('fooName'));
assertTrue(displayedText.includes('Sync isn\'t working')); assertTrue(displayedText.includes('Sync isn\'t working'));
// The sync error button is shown to resolve the error.
assertVisible(testElement.$$('#sync-error-button'), true);
testElement.syncStatus = { testElement.syncStatus = {
signedIn: true, signedIn: true,
...@@ -273,8 +275,8 @@ cr.define('settings_sync_account_control', function() { ...@@ -273,8 +275,8 @@ cr.define('settings_sync_account_control', function() {
assertFalse(displayedText.includes('barName')); assertFalse(displayedText.includes('barName'));
assertFalse(displayedText.includes('fooName')); assertFalse(displayedText.includes('fooName'));
assertTrue(displayedText.includes('Sync is paused')); assertTrue(displayedText.includes('Sync is paused'));
// The sync-paused button is shown to resolve the error. // The sync error button is shown to resolve the error.
assertVisible(testElement.$$('#sync-paused-button'), true); assertVisible(testElement.$$('#sync-error-button'), true);
testElement.syncStatus = { testElement.syncStatus = {
signedIn: true, signedIn: true,
...@@ -292,6 +294,7 @@ cr.define('settings_sync_account_control', function() { ...@@ -292,6 +294,7 @@ cr.define('settings_sync_account_control', function() {
assertFalse(displayedText.includes('barName')); assertFalse(displayedText.includes('barName'));
assertFalse(displayedText.includes('fooName')); assertFalse(displayedText.includes('fooName'));
assertTrue(displayedText.includes('Sync disabled')); assertTrue(displayedText.includes('Sync disabled'));
assertVisible(testElement.$$('#sync-error-button'), false);
testElement.syncStatus = { testElement.syncStatus = {
signedIn: true, signedIn: true,
...@@ -326,7 +329,7 @@ cr.define('settings_sync_account_control', function() { ...@@ -326,7 +329,7 @@ cr.define('settings_sync_account_control', function() {
}; };
assertVisible(testElement.$$('#turn-off'), false); assertVisible(testElement.$$('#turn-off'), false);
assertVisible(testElement.$$('#sync-paused-button'), false); assertVisible(testElement.$$('#sync-error-button'), false);
testElement.embeddedInSubpage = true; testElement.embeddedInSubpage = true;
testElement.syncStatus = { testElement.syncStatus = {
...@@ -338,7 +341,7 @@ cr.define('settings_sync_account_control', function() { ...@@ -338,7 +341,7 @@ cr.define('settings_sync_account_control', function() {
disabled: false, disabled: false,
}; };
assertVisible(testElement.$$('#turn-off'), false); assertVisible(testElement.$$('#turn-off'), false);
assertVisible(testElement.$$('#sync-paused-button'), true); assertVisible(testElement.$$('#sync-error-button'), true);
testElement.embeddedInSubpage = true; testElement.embeddedInSubpage = true;
testElement.syncStatus = { testElement.syncStatus = {
...@@ -350,7 +353,20 @@ cr.define('settings_sync_account_control', function() { ...@@ -350,7 +353,20 @@ cr.define('settings_sync_account_control', function() {
disabled: false, disabled: false,
}; };
assertVisible(testElement.$$('#turn-off'), false); assertVisible(testElement.$$('#turn-off'), false);
assertVisible(testElement.$$('#sync-paused-button'), true); assertVisible(testElement.$$('#sync-error-button'), true);
testElement.embeddedInSubpage = true;
testElement.syncStatus = {
signedIn: true,
signedInUsername: 'bar@bar.com',
hasError: true,
hasUnrecoverableError: false,
statusAction: settings.StatusAction.ENTER_PASSPHRASE,
disabled: false,
};
assertVisible(testElement.$$('#turn-off'), false);
// Don't show passphrase error button on embedded page.
assertVisible(testElement.$$('#sync-error-button'), false);
testElement.embeddedInSubpage = true; testElement.embeddedInSubpage = true;
testElement.syncStatus = { testElement.syncStatus = {
...@@ -362,7 +378,7 @@ cr.define('settings_sync_account_control', function() { ...@@ -362,7 +378,7 @@ cr.define('settings_sync_account_control', function() {
disabled: false, disabled: false,
}; };
assertVisible(testElement.$$('#turn-off'), false); assertVisible(testElement.$$('#turn-off'), false);
assertVisible(testElement.$$('#sync-paused-button'), false); assertVisible(testElement.$$('#sync-error-button'), false);
}); });
test('hide buttons', function() { test('hide buttons', function() {
...@@ -377,7 +393,7 @@ cr.define('settings_sync_account_control', function() { ...@@ -377,7 +393,7 @@ cr.define('settings_sync_account_control', function() {
}; };
assertVisible(testElement.$$('#turn-off'), false); assertVisible(testElement.$$('#turn-off'), false);
assertVisible(testElement.$$('#sync-paused-button'), false); assertVisible(testElement.$$('#sync-error-button'), false);
testElement.syncStatus = { testElement.syncStatus = {
signedIn: true, signedIn: true,
...@@ -388,7 +404,18 @@ cr.define('settings_sync_account_control', function() { ...@@ -388,7 +404,18 @@ cr.define('settings_sync_account_control', function() {
disabled: false, disabled: false,
}; };
assertVisible(testElement.$$('#turn-off'), false); assertVisible(testElement.$$('#turn-off'), false);
assertVisible(testElement.$$('#sync-paused-button'), false); assertVisible(testElement.$$('#sync-error-button'), false);
testElement.syncStatus = {
signedIn: true,
signedInUsername: 'bar@bar.com',
hasError: true,
hasUnrecoverableError: false,
statusAction: settings.StatusAction.ENTER_PASSPHRASE,
disabled: false,
};
assertVisible(testElement.$$('#turn-off'), false);
assertVisible(testElement.$$('#sync-error-button'), false);
}); });
}); });
}); });
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