From aef02964722ff6e597e03f5ff1074feba89c7a87 Mon Sep 17 00:00:00 2001 From: claire bontempo <68122737+hellobontempo@users.noreply.github.com> Date: Tue, 7 Feb 2023 12:09:17 -0800 Subject: [PATCH] UI: add error-handling and validation to pki cross-signing (#19022) * return signed ca_chain if request fails, check for existing issuer name * update docs * add error border class to input --- .../addon/components/object-list-input.hbs | 100 ++++++++++-------- .../addon/components/object-list-input.js | 3 + .../components/pki-issuer-cross-sign.hbs | 6 +- .../addon/components/pki-issuer-cross-sign.js | 38 ++++++- 4 files changed, 96 insertions(+), 51 deletions(-) diff --git a/ui/lib/core/addon/components/object-list-input.hbs b/ui/lib/core/addon/components/object-list-input.hbs index 543f3b4aa..6bf7ac0ea 100644 --- a/ui/lib/core/addon/components/object-list-input.hbs +++ b/ui/lib/core/addon/components/object-list-input.hbs @@ -1,49 +1,59 @@ {{yield}} {{#each this.inputList as |row index|}} -
- {{#each-in row as |inputKey value|}} - {{#let (find-by "key" inputKey @objectKeys) as |field|}} -
- {{#if (eq index 0)}} -

{{field.label}}

- {{/if}} - -
- {{/let}} - {{/each-in}} -
- {{#if (eq (inc index) this.inputList.length)}} - - {{else}} - - {{/if}} + {{#let (get @validationErrors index) as |rowValidations|}} +
+ {{#each-in row as |inputKey value|}} + {{#let (find-by "key" inputKey @objectKeys) as |field|}} +
+ {{#if (eq index 0)}} +

{{field.label}}

+ {{/if}} + {{#let (get rowValidations field.key) as |inputError|}} + + {{#if (and (not inputError.isValid) inputError.errors)}} + + {{/if}} + {{/let}} +
+ {{/let}} + {{/each-in}} +
+ {{#if (eq index 0)}} +
+ {{/if}} + {{#if (eq (inc index) this.inputList.length)}} + + {{else}} + + {{/if}} +
-
+ {{/let}} {{/each}} \ No newline at end of file diff --git a/ui/lib/core/addon/components/object-list-input.js b/ui/lib/core/addon/components/object-list-input.js index e9449cd03..4a02e5f70 100644 --- a/ui/lib/core/addon/components/object-list-input.js +++ b/ui/lib/core/addon/components/object-list-input.js @@ -22,6 +22,9 @@ import { assert } from '@ember/debug'; * @param {array} objectKeys - an array of objects (sample above), the length determines the number of columns the component renders * @callback onChange - callback triggered when any input changes or when a row is deleted, called with array of objects containing each input's key and value ex: [ { attrKey: 'some input value' } ] * @param {string} [inputValue] - an array of objects to pre-fill the component inputs, key name must match objectKey[key] + * @param {array} [validationErrors] - an array of validation objects, the index of each object corresponds to the row with an invalid input. each object has a key that matches a key in objectKeys + * ex: (the nested object with 'errors' and 'isValid' matches the structure returned by the model validations decorator) + * { "attrKey": { "errors": ["Name is required."], "isValid": false } } */ export default class ObjectListInput extends Component { diff --git a/ui/lib/pki/addon/components/pki-issuer-cross-sign.hbs b/ui/lib/pki/addon/components/pki-issuer-cross-sign.hbs index 1b8893c95..5786e033a 100644 --- a/ui/lib/pki/addon/components/pki-issuer-cross-sign.hbs +++ b/ui/lib/pki/addon/components/pki-issuer-cross-sign.hbs @@ -81,7 +81,11 @@ {{else}}
- +