diff --git a/scripts/langindex.json b/scripts/langindex.json index 36318968e..02f70f51f 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1920,6 +1920,8 @@ "core.login.createaccount": "moodle", "core.login.createuserandpass": "moodle", "core.login.credentialsdescription": "local_moodlemobileapp", + "core.login.credentialshelp": "local_moodlemobileapp", + "core.login.credentialssupportsubject": "local_moodlemobileapp", "core.login.emailconfirmsent": "moodle", "core.login.emailconfirmsentnoemail": "local_moodlemobileapp", "core.login.emailconfirmsentsuccess": "moodle", @@ -1997,7 +1999,9 @@ "core.login.recaptchaexpired": "local_moodlemobileapp", "core.login.recaptchaincorrect": "local_moodlemobileapp", "core.login.reconnect": "local_moodlemobileapp", + "core.login.reconnecthelp": "local_moodlemobileapp", "core.login.reconnectssodescription": "local_moodlemobileapp", + "core.login.reconnectsupportsubject": "local_moodlemobileapp", "core.login.reconnecttosite": "local_moodlemobileapp", "core.login.removeaccount": "local_moodlemobileapp", "core.login.resendemail": "moodle", diff --git a/src/core/features/login/lang.json b/src/core/features/login/lang.json index 2b79ba053..c47569d23 100644 --- a/src/core/features/login/lang.json +++ b/src/core/features/login/lang.json @@ -6,7 +6,7 @@ "cancel": "Cancel", "changepassword": "Change password", "changepasswordbutton": "Change password", - "changepasswordhelp": "If you have problems changing your password, please contact your school or learning provider.", + "changepasswordhelp": "If you have problems changing your password, try again later or contact your school or learning provider.", "changepasswordreconnectinstructions": "If you didn't change your password correctly, you'll be asked to do it again.", "changepasswordsupportsubject": "Need help changing my password", "confirmdeletesite": "Are you sure you want to remove the account on {{sitename}}?", @@ -17,6 +17,8 @@ "createaccount": "Create my new account", "createuserandpass": "Choose your username and password", "credentialsdescription": "Please provide your username and password to log in.", + "credentialshelp": "If you have problems logging in, try again later or contact your school or learning provider.", + "credentialssupportsubject": "Need help logging in", "emailconfirmsent": "

An email should have been sent to your address at {{$a}}

It contains easy instructions to complete your registration.

", "emailconfirmsentnoemail": "

An email should have been sent to your address.

It contains easy instructions to complete your registration.

", "emailconfirmsentsuccess": "Confirmation email sent successfully", @@ -94,7 +96,9 @@ "recaptchaexpired": "Verification expired. Answer the security question again.", "recaptchaincorrect": "The security question answer is incorrect.", "reconnect": "Reconnect", + "reconnecthelp": "If you have problems reconnecting, try again later or contact your school or learning provider.", "reconnectssodescription": "Your authentication token is invalid or has expired. You have to reconnect to the site. You need to log in to the site in a browser window.", + "reconnectsupportsubject": "Need help reconnecting", "reconnecttosite": "Reconnect to the site", "removeaccount": "Remove account", "resendemail": "Resend email", diff --git a/src/core/features/login/pages/change-password/change-password.ts b/src/core/features/login/pages/change-password/change-password.ts index 84961975b..f2c063d82 100644 --- a/src/core/features/login/pages/change-password/change-password.ts +++ b/src/core/features/login/pages/change-password/change-password.ts @@ -15,15 +15,12 @@ import { Component, OnDestroy } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreLoginHelper } from '@features/login/services/login-helper'; import { Translate } from '@singletons'; import { CoreNavigator } from '@services/navigator'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreUtils } from '@services/utils/utils'; import { CoreUserSupport } from '@features/user/services/support'; -import { AlertButton } from '@ionic/angular'; -import { CoreUserAuthenticatedSupportConfig } from '@features/user/classes/support/authenticated-support-config'; /** * Page that shows instructions to change the password. @@ -46,29 +43,13 @@ export class CoreLoginChangePasswordPage implements OnDestroy { } /** - * Show a help modal. + * Show help modal. */ showHelp(): void { - const supportConfig = CoreUserAuthenticatedSupportConfig.forCurrentSite(); - const buttons: (AlertButton | string)[] = []; - - if (supportConfig.canContactSupport()) { - buttons.push({ - text: Translate.instant('core.contactsupport'), - handler: () => CoreUserSupport.contact({ - supportConfig, - subject: Translate.instant('core.login.changepasswordsupportsubject'), - }), - }); - } - - buttons.push(Translate.instant('core.ok')); - - CoreDomUtils.showAlertWithOptions({ - header: Translate.instant('core.help'), - message: Translate.instant('core.login.changepasswordhelp'), - buttons, - }); + CoreUserSupport.showHelp( + Translate.instant('core.login.changepasswordhelp'), + Translate.instant('core.login.changepasswordsupportsubject'), + ); } /** diff --git a/src/core/features/login/pages/credentials/credentials.html b/src/core/features/login/pages/credentials/credentials.html index 3f101e383..7e8fbca42 100644 --- a/src/core/features/login/pages/credentials/credentials.html +++ b/src/core/features/login/pages/credentials/credentials.html @@ -12,7 +12,7 @@ - + diff --git a/src/core/features/login/pages/credentials/credentials.ts b/src/core/features/login/pages/credentials/credentials.ts index d9a278485..d52ff07cf 100644 --- a/src/core/features/login/pages/credentials/credentials.ts +++ b/src/core/features/login/pages/credentials/credentials.ts @@ -59,7 +59,6 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { showScanQR = false; loginAttempts = 0; supportConfig?: CoreUserSupportConfig; - canContactSupport?: boolean; protected siteConfig?: CoreSitePublicConfigResponse; protected eventThrown = false; @@ -83,7 +82,6 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { this.siteConfig = CoreNavigator.getRouteParam('siteConfig'); this.urlToOpen = CoreNavigator.getRouteParam('urlToOpen'); this.supportConfig = this.siteConfig && new CoreUserGuestSupportConfig(this.siteConfig); - this.canContactSupport = this.supportConfig?.canContactSupport(); } catch (error) { CoreDomUtils.showErrorModal(error); @@ -132,14 +130,13 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { } /** - * Contact site support. + * Show help modal. */ - async contactSupport(): Promise { - if (!this.supportConfig) { - throw new Error('can\'t contact support'); - } - - await CoreUserSupport.contact({ supportConfig: this.supportConfig }); + showHelp(): void { + CoreUserSupport.showHelp( + Translate.instant('core.login.credentialshelp'), + Translate.instant('core.login.credentialssupportsubject'), + ); } /** diff --git a/src/core/features/login/pages/reconnect/reconnect.html b/src/core/features/login/pages/reconnect/reconnect.html index 905e12abe..c82289263 100644 --- a/src/core/features/login/pages/reconnect/reconnect.html +++ b/src/core/features/login/pages/reconnect/reconnect.html @@ -9,7 +9,7 @@ - + diff --git a/src/core/features/login/pages/reconnect/reconnect.ts b/src/core/features/login/pages/reconnect/reconnect.ts index 41ad23022..7389470ce 100644 --- a/src/core/features/login/pages/reconnect/reconnect.ts +++ b/src/core/features/login/pages/reconnect/reconnect.ts @@ -29,6 +29,7 @@ import { CoreForms } from '@singletons/form'; import { CoreUserSupport } from '@features/user/services/support'; import { CoreUserSupportConfig } from '@features/user/classes/support/support-config'; import { CoreUserAuthenticatedSupportConfig } from '@features/user/classes/support/authenticated-support-config'; +import { Translate } from '@singletons'; /** * Page to enter the user password to reconnect to a site. @@ -60,7 +61,6 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { showLoading = true; reconnectAttempts = 0; supportConfig?: CoreUserSupportConfig; - canContactSupport?: boolean; protected siteConfig?: CoreSitePublicConfigResponse; protected viewLeft = false; @@ -108,7 +108,6 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { this.siteUrl = site.infos.siteurl; this.siteName = site.getSiteName(); this.supportConfig = new CoreUserAuthenticatedSupportConfig(site); - this.canContactSupport = this.supportConfig.canContactSupport(); // If login was OAuth we should only reach this page if the OAuth method ID has changed. this.isOAuth = site.isOAuth(); @@ -142,10 +141,13 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { } /** - * Contact site support. + * Show help modal. */ - async contactSupport(): Promise { - await CoreUserSupport.contact({ supportConfig: this.supportConfig }); + showHelp(): void { + CoreUserSupport.showHelp( + Translate.instant('core.login.reconnecthelp'), + Translate.instant('core.login.reconnectsupportsubject'), + ); } /** diff --git a/src/core/features/user/lang.json b/src/core/features/user/lang.json index 4571d3764..d1c29e8b6 100644 --- a/src/core/features/user/lang.json +++ b/src/core/features/user/lang.json @@ -3,7 +3,7 @@ "useraccount": "User account", "city": "City/town", "completeprofile": "Complete profile", - "completeprofilehelp": "If you have problems completing your profile, please contact your school or learning provider.", + "completeprofilehelp": "If you have problems completing your profile, try again later or contact your school or learning provider.", "completeprofilenotice": "Before you continue, please fill in the required fields in your user profile.", "completeprofilereconnectinstructions": "If you didn't complete your profile correctly, you'll be asked to do it again.", "completeprofilesupportsubject": "Need help completing my profile", diff --git a/src/core/features/user/pages/complete-profile/complete-profile.ts b/src/core/features/user/pages/complete-profile/complete-profile.ts index 28042e741..5e3ad563f 100644 --- a/src/core/features/user/pages/complete-profile/complete-profile.ts +++ b/src/core/features/user/pages/complete-profile/complete-profile.ts @@ -15,15 +15,12 @@ import { Component, OnDestroy } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreLoginHelper } from '@features/login/services/login-helper'; import { Translate } from '@singletons'; import { CoreNavigator } from '@services/navigator'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreUtils } from '@services/utils/utils'; -import { AlertButton } from '@ionic/angular'; import { CoreUserSupport } from '@features/user/services/support'; -import { CoreUserAuthenticatedSupportConfig } from '@features/user/classes/support/authenticated-support-config'; /** * Page that shows instructions to complete the profile. @@ -45,29 +42,13 @@ export class CoreUserCompleteProfilePage implements OnDestroy { } /** - * Show a help modal. + * Show help modal. */ showHelp(): void { - const supportConfig = CoreUserAuthenticatedSupportConfig.forCurrentSite(); - const buttons: (AlertButton | string)[] = []; - - if (supportConfig.canContactSupport()) { - buttons.push({ - text: Translate.instant('core.contactsupport'), - handler: () => CoreUserSupport.contact({ - supportConfig, - subject: Translate.instant('core.login.completeprofilesupportsubject'), - }), - }); - } - - buttons.push(Translate.instant('core.ok')); - - CoreDomUtils.showAlertWithOptions({ - header: Translate.instant('core.help'), - message: Translate.instant('core.user.completeprofilehelp'), - buttons, - }); + CoreUserSupport.showHelp( + Translate.instant('core.user.completeprofilehelp'), + Translate.instant('core.user.completeprofilesupportsubject'), + ); } /** diff --git a/src/core/features/user/services/support.ts b/src/core/features/user/services/support.ts index e295caaeb..9dbc745a9 100644 --- a/src/core/features/user/services/support.ts +++ b/src/core/features/user/services/support.ts @@ -19,9 +19,11 @@ import { InAppBrowserObject } from '@ionic-native/in-app-browser'; import { CorePlatform } from '@services/platform'; import { CoreSites } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; -import { makeSingleton } from '@singletons'; +import { makeSingleton, Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; import { CoreSubscriptions } from '@singletons/subscriptions'; +import { AlertButton } from '@ionic/angular'; +import { CoreDomUtils } from '@services/utils/dom'; /** * Handle site support. @@ -47,6 +49,35 @@ export class CoreUserSupportService { await CoreEvents.waitUntil(CoreEvents.IAB_EXIT); } + /** + * Show a help modal that suggests contacting support if available. + * + * @param message Help message. + * @param supportSubject Support subject. + */ + showHelp(message: string, supportSubject: string): void { + const supportConfig = CoreUserAuthenticatedSupportConfig.forCurrentSite(); + const buttons: (AlertButton | string)[] = []; + + if (supportConfig.canContactSupport()) { + buttons.push({ + text: Translate.instant('core.contactsupport'), + handler: () => CoreUserSupport.contact({ + supportConfig, + subject: supportSubject, + }), + }); + } + + buttons.push(Translate.instant('core.close')); + + CoreDomUtils.showAlertWithOptions({ + header: Translate.instant('core.help'), + message, + buttons, + }); + } + /** * Inject error details into contact support form. *