From 5cbac6bcae9ef2053c19b2b83527e4414629e272 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Fri, 18 Jun 2021 21:41:59 +0200 Subject: [PATCH] Remove activate feature from Quick Connect page Also added a heading and updates the layout in general --- src/controllers/user/quickConnect/helper.js | 20 --------- src/controllers/user/quickConnect/index.html | 18 ++++---- src/controllers/user/quickConnect/index.js | 44 ++------------------ 3 files changed, 11 insertions(+), 71 deletions(-) diff --git a/src/controllers/user/quickConnect/helper.js b/src/controllers/user/quickConnect/helper.js index 3b5b364d2e..2441100f7e 100644 --- a/src/controllers/user/quickConnect/helper.js +++ b/src/controllers/user/quickConnect/helper.js @@ -1,6 +1,5 @@ import globalize from '../../../scripts/globalize'; import toast from '../../../components/toast/toast'; -import Dashboard from '../../../scripts/clientUtils'; export const authorize = (code) => { const url = ApiClient.getUrl('/QuickConnect/Authorize?Code=' + code); @@ -16,22 +15,3 @@ export const authorize = (code) => { // prevent bubbling return false; }; - -export const activate = () => { - const url = ApiClient.getUrl('/QuickConnect/Activate'); - return ApiClient.ajax({ - type: 'POST', - url: url - }).then(() => { - toast(globalize.translate('QuickConnectActivationSuccessful')); - return true; - }).catch((e) => { - console.error('Error activating quick connect. Error:', e); - Dashboard.alert({ - title: globalize.translate('HeaderError'), - message: globalize.translate('DefaultErrorMessage') - }); - - throw e; - }); -}; diff --git a/src/controllers/user/quickConnect/index.html b/src/controllers/user/quickConnect/index.html index f64b3d6850..b60727d63f 100644 --- a/src/controllers/user/quickConnect/index.html +++ b/src/controllers/user/quickConnect/index.html @@ -1,19 +1,15 @@
-
- - -
-
- ${QuickConnectDescription} -
+ +
+

${QuickConnect}

+
${QuickConnectDescription}
+
- -
+
+
diff --git a/src/controllers/user/quickConnect/index.js b/src/controllers/user/quickConnect/index.js index 2d8fcf1ab6..6809e449c6 100644 --- a/src/controllers/user/quickConnect/index.js +++ b/src/controllers/user/quickConnect/index.js @@ -1,4 +1,4 @@ -import { activate, authorize } from './helper'; +import { authorize } from './helper'; import globalize from '../../../scripts/globalize'; import toast from '../../../components/toast/toast'; @@ -6,52 +6,16 @@ export default function (view) { view.addEventListener('viewshow', function () { const codeElement = view.querySelector('#txtQuickConnectCode'); - view.querySelector('#btnQuickConnectActivate').addEventListener('click', () => { - activate().then(() => { - renderPage(); - }); - }); + view.querySelector('.quickConnectSettingsContainer').addEventListener('submit', (e) => { + e.preventDefault(); - view.querySelector('#btnQuickConnectAuthorize').addEventListener('click', () => { if (!codeElement.validity.valid) { toast(globalize.translate('QuickConnectInvalidCode')); return; } - const code = codeElement.value; - authorize(code); + authorize(codeElement.value); }); - - view.querySelector('.quickConnectSettingsContainer').addEventListener('submit', (e) => { - e.preventDefault(); - }); - - renderPage(); }); - - function renderPage(forceActive = false) { - ApiClient.getQuickConnect('Status').then((status) => { - const btn = view.querySelector('#btnQuickConnectActivate'); - const container = view.querySelector('.quickConnectSettingsContainer'); - - // The activation button should only be visible when quick connect is unavailable (with the text replaced with an error) or when it is available (so it can be activated) - // The authorization container is only usable when quick connect is active, so it should be hidden otherwise - container.style.display = 'none'; - - if (status === 'Unavailable') { - btn.textContent = globalize.translate('QuickConnectNotAvailable'); - btn.disabled = true; - btn.classList.remove('button-submit'); - btn.classList.add('button'); - } else if (status === 'Active' || forceActive) { - container.style.display = ''; - btn.style.display = 'none'; - } - - return true; - }).catch((e) => { - throw e; - }); - } }