From bb40d1652b2a0b0e5c927c3963955fd7a6012ce9 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 30 Aug 2018 11:21:49 +0200 Subject: [PATCH] MOBILE-2568 login: Improve legacy error in desktop apps --- src/core/login/lang/en.json | 1 + src/core/login/providers/helper.ts | 8 +++++++- src/providers/sites.ts | 10 +++++++++- src/providers/utils/dom.ts | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/core/login/lang/en.json b/src/core/login/lang/en.json index c9031b28d..66b50a90d 100644 --- a/src/core/login/lang/en.json +++ b/src/core/login/lang/en.json @@ -33,6 +33,7 @@ "invalidvaluemax": "The maximum value is {{$a}}", "invalidvaluemin": "The minimum value is {{$a}}", "legacymoodleversion": "You are trying to connect to an unsupported Moodle version. Please, download the Moodle Classic app to access this Moodle site.", + "legacymoodleversiondesktop": "You are trying to connect to {{$a}}.

This site is running an outdated unsupported version of Moodle which will not work with this Moodle Desktop App.

If this is your site please contact your local moodle partner to get assistance to update it.

See our contact page to submit a request for assistance.", "localmobileunexpectedresponse": "Moodle Mobile Additional Features check returned an unexpected response, you will be authenticated using the standard Mobile service.", "login": "Log in", "loginbutton": "Log in", diff --git a/src/core/login/providers/helper.ts b/src/core/login/providers/helper.ts index 86b99c7ba..381c61d62 100644 --- a/src/core/login/providers/helper.ts +++ b/src/core/login/providers/helper.ts @@ -956,7 +956,13 @@ export class CoreLoginHelperProvider { buttons: buttons }); - alert.present(); + alert.present().then(() => { + if (!isAndroid && !isIOS) { + // Treat all anchors so they don't override the app. + const alertMessageEl: HTMLElement = alert.pageRef().nativeElement.querySelector('.alert-message'); + this.domUtils.treatAnchors(alertMessageEl); + } + }); } /** diff --git a/src/providers/sites.ts b/src/providers/sites.ts index e7239b659..11825e259 100644 --- a/src/providers/sites.ts +++ b/src/providers/sites.ts @@ -494,8 +494,16 @@ export class CoreSitesProvider { return siteId; }); } else if (result == this.LEGACY_APP_VERSION) { + let errorKey = 'core.login.legacymoodleversion', + params; + + if (this.appProvider.isDesktop()) { + errorKey += 'desktop'; + params = {$a: siteUrl}; + } + return Promise.reject({ - error: this.translate.instant('core.login.legacymoodleversion'), + error: this.translate.instant(errorKey, params), errorcode: 'legacymoodleversion' }); } else { diff --git a/src/providers/utils/dom.ts b/src/providers/utils/dom.ts index d8ebbe017..361fabcd9 100644 --- a/src/providers/utils/dom.ts +++ b/src/providers/utils/dom.ts @@ -1205,7 +1205,7 @@ export class CoreDomUtilsProvider { * * @param {HTMLElement} container The HTMLElement that can contain anchors. */ - protected treatAnchors(container: HTMLElement): void { + treatAnchors(container: HTMLElement): void { const anchors = Array.from(container.querySelectorAll('a')); anchors.forEach((anchor) => {