From d31a0199bc60d0e007f98f0af692fd58e9f6209c Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 6 May 2020 14:24:16 -0600 Subject: [PATCH 1/3] Add default dialog aesthetics to avoid empty SSO dialogs in future --- .../views/dialogs/InteractiveAuthDialog.js | 32 +++++++++++++++++-- src/i18n/strings/en_EN.json | 3 ++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/components/views/dialogs/InteractiveAuthDialog.js b/src/components/views/dialogs/InteractiveAuthDialog.js index af5dc5108c..d9cc13e11c 100644 --- a/src/components/views/dialogs/InteractiveAuthDialog.js +++ b/src/components/views/dialogs/InteractiveAuthDialog.js @@ -25,6 +25,7 @@ import { _t } from '../../../languageHandler'; import AccessibleButton from '../elements/AccessibleButton'; import {ERROR_USER_CANCELLED} from "../../structures/InteractiveAuth"; +import {SSOAuthEntry} from "../auth/InteractiveAuthEntryComponents"; export default createReactClass({ displayName: 'InteractiveAuthDialog', @@ -66,6 +67,8 @@ export default createReactClass({ // } // } // } + // + // Default is defined in _getDefaultDialogAesthetics() aestheticsForStagePhases: PropTypes.object, }, @@ -79,6 +82,28 @@ export default createReactClass({ }; }, + _getDefaultDialogAesthetics: function() { + const ssoAesthetics = { + [SSOAuthEntry.PHASE_PREAUTH]: { + title: _t("Use Single Sign On to continue"), + body: _t("To continue, use Single Sign On to prove your identity."), + continueText: _t("Single Sign On"), + continueKind: "primary", + }, + [SSOAuthEntry.PHASE_POSTAUTH]: { + title: _t("Confirm to continue"), + body: _t("Click the button below to confirm your identity."), + continueText: _t("Confirm"), + continueKind: "primary", + }, + }; + + return { + [SSOAuthEntry.LOGIN_TYPE]: ssoAesthetics, + [SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: ssoAesthetics, + } + }, + _onAuthFinished: function(success, result) { if (success) { this.props.onFinished(true, result); @@ -113,9 +138,10 @@ export default createReactClass({ let body = this.state.authError ? null : this.props.body; let continueText = null; let continueKind = null; - if (!this.state.authError && this.props.aestheticsForStagePhases) { - if (this.props.aestheticsForStagePhases[this.state.uiaStage]) { - const aesthetics = this.props.aestheticsForStagePhases[this.state.uiaStage][this.state.uiaStagePhase]; + const dialogAesthetics = this.props.aestheticsForStagePhases || this._getDefaultDialogAesthetics(); + if (!this.state.authError && dialogAesthetics) { + if (dialogAesthetics[this.state.uiaStage]) { + const aesthetics = dialogAesthetics[this.state.uiaStage][this.state.uiaStagePhase]; if (aesthetics && aesthetics.title) title = aesthetics.title; if (aesthetics && aesthetics.body) body = aesthetics.body; if (aesthetics && aesthetics.continueText) continueText = aesthetics.continueText; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index a24b2bde73..dc92ef310d 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1639,6 +1639,9 @@ "Enable 'Manage Integrations' in Settings to do this.": "Enable 'Manage Integrations' in Settings to do this.", "Integrations not allowed": "Integrations not allowed", "Your Riot doesn't allow you to use an Integration Manager to do this. Please contact an admin.": "Your Riot doesn't allow you to use an Integration Manager to do this. Please contact an admin.", + "To continue, use Single Sign On to prove your identity.": "To continue, use Single Sign On to prove your identity.", + "Confirm to continue": "Confirm to continue", + "Click the button below to confirm your identity.": "Click the button below to confirm your identity.", "Failed to invite the following users to chat: %(csvUsers)s": "Failed to invite the following users to chat: %(csvUsers)s", "We couldn't create your DM. Please check the users you want to invite and try again.": "We couldn't create your DM. Please check the users you want to invite and try again.", "Something went wrong trying to invite the users.": "Something went wrong trying to invite the users.", From 17be9805e15c094fc1942deb30eb7f57bccdcf9e Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 6 May 2020 14:24:37 -0600 Subject: [PATCH 2/3] Set SSO dialog aesthetics for cross-signing setup Fixes https://github.com/vector-im/riot-web/issues/13042 --- .../CreateSecretStorageDialog.js | 21 +++++++++++++++++++ src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js index 2c05f231e7..c8ddd361fc 100644 --- a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js +++ b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js @@ -25,6 +25,7 @@ import { _t } from '../../../../languageHandler'; import Modal from '../../../../Modal'; import { promptForBackupPassphrase } from '../../../../CrossSigningManager'; import {copyNode} from "../../../../utils/strings"; +import {SSOAuthEntry} from "../../../../components/views/auth/InteractiveAuthEntryComponents"; const PHASE_LOADING = 0; const PHASE_LOADERROR = 1; @@ -209,12 +210,32 @@ export default class CreateSecretStorageDialog extends React.PureComponent { }); } else { const InteractiveAuthDialog = sdk.getComponent("dialogs.InteractiveAuthDialog"); + + const dialogAesthetics = { + [SSOAuthEntry.PHASE_PREAUTH]: { + title: _t("Use Single Sign On to continue"), + body: _t("To continue, use Single Sign On to prove your identity."), + continueText: _t("Single Sign On"), + continueKind: "primary", + }, + [SSOAuthEntry.PHASE_POSTAUTH]: { + title: _t("Confirm encryption setup"), + body: _t("Click the button below to confirm setting up encryption."), + continueText: _t("Confirm"), + continueKind: "primary", + }, + }; + const { finished } = Modal.createTrackedDialog( 'Cross-signing keys dialog', '', InteractiveAuthDialog, { title: _t("Setting up keys"), matrixClient: MatrixClientPeg.get(), makeRequest, + aestheticsForStagePhases: { + [SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics, + [SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics, + }, }, ); const [confirmed] = await finished; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index dc92ef310d..7d2e016394 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2193,6 +2193,8 @@ "The export file will be protected with a passphrase. You should enter the passphrase here, to decrypt the file.": "The export file will be protected with a passphrase. You should enter the passphrase here, to decrypt the file.", "File to import": "File to import", "Import": "Import", + "Confirm encryption setup": "Confirm encryption setup", + "Click the button below to confirm setting up encryption.": "Click the button below to confirm setting up encryption.", "Enter your account password to confirm the upgrade:": "Enter your account password to confirm the upgrade:", "Restore your key backup to upgrade your encryption": "Restore your key backup to upgrade your encryption", "Restore": "Restore", From b8fd50c5e328058a0928ff007c22e959b843de6d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 6 May 2020 14:27:32 -0600 Subject: [PATCH 3/3] Appease the linter --- src/components/views/dialogs/InteractiveAuthDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/InteractiveAuthDialog.js b/src/components/views/dialogs/InteractiveAuthDialog.js index d9cc13e11c..b06ce63ecd 100644 --- a/src/components/views/dialogs/InteractiveAuthDialog.js +++ b/src/components/views/dialogs/InteractiveAuthDialog.js @@ -101,7 +101,7 @@ export default createReactClass({ return { [SSOAuthEntry.LOGIN_TYPE]: ssoAesthetics, [SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: ssoAesthetics, - } + }; }, _onAuthFinished: function(success, result) {