From efe5193a5992315b5b65d4c887330e8e66a32aea Mon Sep 17 00:00:00 2001 From: Jordan Reimer Date: Fri, 23 Sep 2022 08:18:20 -0600 Subject: [PATCH] HCP Link Status Parsing and Modal Update (#17279) * updates hcp link status parsing for new format and updates to modal view * fixes missing wormhole in tests * fixes transit backend tests * reverts adding wormhole to LinkStatus for testing and instead adds it to impacted tests --- ui/app/components/link-status.js | 42 +----- ui/app/styles/core/buttons.scss | 1 - ui/app/templates/components/link-status.hbs | 53 +++++++- .../templates/components/oidc/scope-form.hbs | 2 +- ui/mirage/handlers/hcp-link.js | 13 +- ui/tests/acceptance/transit-test.js | 4 +- .../components/link-status-test.js | 128 +++++++----------- .../integration/components/nav-header-test.js | 1 + .../components/replication-header-test.js | 24 ++-- 9 files changed, 125 insertions(+), 143 deletions(-) diff --git a/ui/app/components/link-status.js b/ui/app/components/link-status.js index 153d4667c..f7493ed4b 100644 --- a/ui/app/components/link-status.js +++ b/ui/app/components/link-status.js @@ -14,7 +14,6 @@ import { inject as service } from '@ember/service'; */ export default class LinkStatus extends Component { - @service store; @service version; get state() { @@ -28,47 +27,14 @@ export default class LinkStatus extends Component { get timestamp() { try { - return this.state !== 'connected' ? this.args.status.split('since')[1].split('m=')[0].trim() : null; + return this.state !== 'connected' ? this.args.status.split('since')[1].split(';')[0].trim() : null; } catch { return null; } } - get message() { - if (this.args.status) { - const error = this.args.status.split('error:')[1] || ''; - const timestamp = this.timestamp ? ` [${this.timestamp}]` : ''; - const sinceTimestamp = timestamp ? ` since${timestamp}` : ''; - if (this.state === 'disconnected') { - // if generally disconnected hide the banner - return !error || error.includes('UNKNOWN') - ? null - : `Vault has been disconnected from HCP${sinceTimestamp}. Error: ${error}`; - } else if (this.state === 'connecting') { - if (error.includes('connection refused')) { - return `Vault has been trying to connect to HCP${sinceTimestamp}, but HCP is not reachable. Vault will try again soon.`; - } else if (error.includes('principal does not have permission to register as provider')) { - return `Vault tried connecting to HCP, but the Resource ID is invalid. Check your resource ID.${timestamp}`; - } else if (error.includes('cannot fetch token: 401 Unauthorized')) { - return `Vault tried connecting to HCP, but the authorization information is wrong. Update it and try again.${timestamp}`; - } else { - // catch all for any unknown errors or missing error - const errorMessage = error ? ` Error: ${error}` : ''; - return `Vault has been trying to connect to HCP${sinceTimestamp}. Vault will try again soon.${errorMessage}`; - } - } - } - return null; - } - - get showStatus() { - // enterprise only feature at this time but will expand to OSS in future release - if (!this.version.isEnterprise || !this.args.status) { - return false; - } - if (this.state !== 'connected' && !this.message) { - return false; - } - return true; + get error() { + const status = this.args.status; + return status && status !== 'connected' ? status.split('error:')[1] : null; } } diff --git a/ui/app/styles/core/buttons.scss b/ui/app/styles/core/buttons.scss index 9ae0a2e84..2d8cf8ffb 100644 --- a/ui/app/styles/core/buttons.scss +++ b/ui/app/styles/core/buttons.scss @@ -280,5 +280,4 @@ a.button.disabled { font-size: inherit; font-weight: inherit; cursor: pointer; - color: $link; } diff --git a/ui/app/templates/components/link-status.hbs b/ui/app/templates/components/link-status.hbs index ba89101a9..2ff89bd0d 100644 --- a/ui/app/templates/components/link-status.hbs +++ b/ui/app/templates/components/link-status.hbs @@ -1,4 +1,4 @@ -{{#if this.showStatus}} +{{#if (and this.state this.version.isEnterprise)}} -{{/if}} \ No newline at end of file +{{/if}} + + + +
+ +
+
\ No newline at end of file diff --git a/ui/app/templates/components/oidc/scope-form.hbs b/ui/app/templates/components/oidc/scope-form.hbs index b5af5588b..108aa8e45 100644 --- a/ui/app/templates/components/oidc/scope-form.hbs +++ b/ui/app/templates/components/oidc/scope-form.hbs @@ -39,7 +39,7 @@ You can use Alt+Tab (Option+Tab on MacOS) in the code editor to skip to the next field. See