From 8c8e6d736f8ae0a930fec0abd00daf97651ed80b Mon Sep 17 00:00:00 2001 From: Artur Moczulski Date: Mon, 28 Oct 2019 00:59:04 -0700 Subject: [PATCH] feature(installer): style installation pages; ref #5 --- .../classes/RollbarConfigureController.cls | 17 ++- .../main/default/classes/RollbarInstaller.cls | 36 ++++- .../components/RemoteSiteHelper.component | 12 +- .../main/default/pages/RollbarConfigure.page | 118 ++++++++++++++--- .../pages/RollbarInstallationCheck.page | 123 ++++++++++++++++-- 5 files changed, 262 insertions(+), 44 deletions(-) diff --git a/force-app/main/default/classes/RollbarConfigureController.cls b/force-app/main/default/classes/RollbarConfigureController.cls index 58f31b9..ad0f5d7 100644 --- a/force-app/main/default/classes/RollbarConfigureController.cls +++ b/force-app/main/default/classes/RollbarConfigureController.cls @@ -1,6 +1,7 @@ public with sharing class RollbarConfigureController { public Map checks { get; private set; } + public Boolean installed { get; private set; } protected RollbarSettings__c settings { get; set; } public String accessToken { @@ -13,6 +14,7 @@ public with sharing class RollbarConfigureController { } public RollbarConfigureController() { + this.installed = false; this.settings = RollbarSettings__c.getOrgDefaults(); } @@ -22,7 +24,9 @@ public with sharing class RollbarConfigureController { RollbarInstaller.install(config); - return null; + PageReference checkPage = new PageReference('/apex/RollbarInstallationCheck'); + checkPage.setRedirect(true); + return checkPage; } public Pagereference check() @@ -30,7 +34,16 @@ public with sharing class RollbarConfigureController { Config config = new Config(this.accessToken, UserInfo.getOrganizationId()); this.checks = RollbarInstaller.check(config); - + + Boolean installed = true; + for (String key : this.checks.keySet()) { + if (!this.checks.get(key)) { + installed = false; + break; + } + } + this.installed = installed; + return null; } } diff --git a/force-app/main/default/classes/RollbarInstaller.cls b/force-app/main/default/classes/RollbarInstaller.cls index 203d95f..6e78be9 100644 --- a/force-app/main/default/classes/RollbarInstaller.cls +++ b/force-app/main/default/classes/RollbarInstaller.cls @@ -1,16 +1,38 @@ public with sharing class RollbarInstaller { - public Map checks { get; private set; } - public static Map check(Config config) { Map checks = new Map(); - checks.put('rollbarApiEndpointAllowed', rollbarApiEndpointAllowed(config.endpoint())); - checks.put('rollbarPingSuccessful', rollbarPingSuccessful()); - checks.put('rollbarEmailServiceSetUp', rollbarEmailServiceSetUp()); - checks.put('apexNotificationsForwardingSetUp', apexNotificationsForwardingSetUp()); - checks.put('accessTokenCorrect', accessTokenCorrect(config)); + try { + checks.put('rollbarApiEndpointAllowed', rollbarApiEndpointAllowed(config.endpoint())); + } catch (Exception ex) { + checks.put('rollbarApiEndpointAllowed', false); + } + + try { + checks.put('rollbarPingSuccessful', rollbarPingSuccessful()); + } catch (Exception ex) { + checks.put('rollbarPingSuccessful', false); + } + + try { + checks.put('rollbarEmailServiceSetUp', rollbarEmailServiceSetUp()); + } catch (Exception ex) { + checks.put('rollbarEmailServiceSetUp', false); + } + + try { + checks.put('apexNotificationsForwardingSetUp', apexNotificationsForwardingSetUp()); + } catch (Exception ex) { + checks.put('apexNotificationsForwardingSetUp', false); + } + + try { + checks.put('accessTokenCorrect', accessTokenCorrect(config)); + } catch (Exception ex) { + checks.put('accessTokenCorrect', false); + } return checks; } diff --git a/force-app/main/default/components/RemoteSiteHelper.component b/force-app/main/default/components/RemoteSiteHelper.component index 7338a2a..ae97646 100644 --- a/force-app/main/default/components/RemoteSiteHelper.component +++ b/force-app/main/default/components/RemoteSiteHelper.component @@ -2,11 +2,6 @@ - - - - -