From 17ea0f03884050487d0886cf3117edb2d102b357 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Fri, 24 Sep 2021 11:07:21 -0600 Subject: [PATCH 01/22] get credentials card test and setup --- ui/app/components/get-credentials-card.js | 30 ++++++++++++++----- .../components/get-credentials-card.hbs | 5 +++- ui/app/templates/components/input-search.hbs | 1 + .../templates/components/search-select.hbs | 1 + .../components/get-credentials-card-test.js | 18 +++++++++-- 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/ui/app/components/get-credentials-card.js b/ui/app/components/get-credentials-card.js index 9bc650aac3114..a989205bc72d8 100644 --- a/ui/app/components/get-credentials-card.js +++ b/ui/app/components/get-credentials-card.js @@ -5,11 +5,16 @@ * * @example * ```js - * + * * ``` * @param title=null {String} - The title displays the card title * @param searchLabel=null {String} - The text above the searchSelect component * @param models=null {Array} - An array of model types to fetch from the API. Passed through to SearchSelect component + * @param type=null {String} - Determines where the transitionTo goes. If role to backend.credentials, if secret backend.show + * @param shouldUseFallback=[false] {Boolean} - If true the input is used instead of search select. + * @param subText=[null] {String} - Text below title + * @param placeHolder=[null] {String} - Only works if shouldUseFallback is true. Displays the helper text inside the input. + * @param backend=null {String} - Name of the backend to look up on search. */ import Component from '@glimmer/component'; @@ -20,25 +25,36 @@ export default class GetCredentialsCard extends Component { @service router; @service store; @tracked role = ''; + @tracked secret = ''; @action async transitionToCredential() { const role = this.role; + const secret = this.secret; if (role) { this.router.transitionTo('vault.cluster.secrets.backend.credentials', role); } + if (secret) { + this.router.transitionTo('vault.cluster.secrets.backend.show', secret); + } } get buttonDisabled() { - return !this.role; + return !this.role && !this.secret; } @action handleRoleInput(value) { - // if it comes in from the fallback component then the value is a string otherwise it's an array - let role = value; - if (Array.isArray(value)) { - role = value[0]; + if (this.args.type === 'role') { + // if it comes in from the fallback component then the value is a string otherwise it's an array + // which currently only happens if type is role. + if (Array.isArray(value)) { + this.role = value[0]; + } else { + this.role = value; + } + } + if (this.args.type === 'secret') { + this.secret = value; } - this.role = role; } } diff --git a/ui/app/templates/components/get-credentials-card.hbs b/ui/app/templates/components/get-credentials-card.hbs index 8e2d06d8c0530..5a539af5af3ab 100644 --- a/ui/app/templates/components/get-credentials-card.hbs +++ b/ui/app/templates/components/get-credentials-card.hbs @@ -1,18 +1,21 @@ -
+

{{@title}}

{{@searchLabel}}

+

{{@subText}}

diff --git a/ui/lib/core/addon/templates/components/search-select.hbs b/ui/lib/core/addon/templates/components/search-select.hbs index bc876e1f8d6f0..6cccd18d20f36 100644 --- a/ui/lib/core/addon/templates/components/search-select.hbs +++ b/ui/lib/core/addon/templates/components/search-select.hbs @@ -5,6 +5,7 @@ onChange=(action "onChange") inputValue=inputValue helpText=helpText + placeHolder=placeHolder }} {{else}}