From ce8eaaeacaaa395aba4f0dda40b47ab5f0bf6158 Mon Sep 17 00:00:00 2001 From: CiviCRM Date: Fri, 18 Dec 2015 20:08:46 -0800 Subject: [PATCH] CRM-16173 - crmCxn - When reconnecting, display the *new* details/permissions. --- ang/crmCxn/ConfirmReconnectCtrl.html | 9 +++++---- ang/crmCxn/ManageCtrl.html | 2 +- ang/crmCxn/ManageCtrl.js | 22 +++++++++++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ang/crmCxn/ConfirmReconnectCtrl.html b/ang/crmCxn/ConfirmReconnectCtrl.html index 04f7252c6b..0b60bd8792 100644 --- a/ang/crmCxn/ConfirmReconnectCtrl.html +++ b/ang/crmCxn/ConfirmReconnectCtrl.html @@ -1,5 +1,5 @@
-

{{ts('Are you sure you want to reconnect \"%1\"?', {1: cxn.app_meta.title})}}

+

{{ts('Are you sure you want to reconnect \"%1\"?', {1: appMeta.title})}}

{{ts('Reconnecting will change the connection details (such as callback URLs and permissions). This can be useful in a few cases, such as:')}}

@@ -7,16 +7,17 @@
  • {{ts('After your site has migrated to a new URL.')}}
  • {{ts('After the application has migrated to a new URL.')}}
  • {{ts('After the application has changed permission requirements.')}}
  • +
  • {{ts('After the application has a major failure or reset.')}}
  • -
    +
    -
    +
    -
    +
    diff --git a/ang/crmCxn/ManageCtrl.html b/ang/crmCxn/ManageCtrl.html index d6dd5b2795..2087eb05f5 100644 --- a/ang/crmCxn/ManageCtrl.html +++ b/ang/crmCxn/ManageCtrl.html @@ -55,7 +55,7 @@
  • {{ts('Reconnect')}}
  • diff --git a/ang/crmCxn/ManageCtrl.js b/ang/crmCxn/ManageCtrl.js index f8929e5895..97615f0fb8 100644 --- a/ang/crmCxn/ManageCtrl.js +++ b/ang/crmCxn/ManageCtrl.js @@ -19,18 +19,30 @@ crmUiAlert({text: alert.message, title: alert.title, type: 'error'}); }); - $scope.findCxnByAppId = function(appId) { - var result = _.where($scope.cxns, { - app_guid: appId - }); + // Convert array [x] to x|null|error + function asOne(result, msg) { switch (result.length) { case 0: return null; case 1: return result[0]; default: - throw "Error: Too many connections for appId: " + appId; + throw msg; } + } + + $scope.findCxnByAppId = function(appId) { + var result = _.where($scope.cxns, { + app_guid: appId + }); + return asOne(result, "Error: Too many connections for appId: " + appId); + }; + + $scope.findAppByAppId = function(appId) { + var result = _.where($scope.appMetas, { + appId: appId + }); + return asOne(result, "Error: Too many apps for appId: " + appId); }; $scope.hasAvailApps = function() { -- 2.25.1