From 75e221d256a2026a587eb21f21ee3623ad8136d4 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Tue, 4 Jun 2019 15:53:10 +0100 Subject: [PATCH] ui: ACL Policies. Catch all server errors (#5836) Always show any server errors under Rules, not just invalid HCL --- ui-v2/app/components/policy-selector.js | 4 ++- .../app/templates/components/policy-form.hbs | 2 +- .../dc/acls/policies/as-many/add-new.feature | 27 +++++++++++++++ ui-v2/tests/pages.js | 2 +- ui-v2/tests/pages/components/policy-form.js | 9 +++-- .../tests/pages/components/policy-selector.js | 2 +- ui-v2/tests/steps/assertions/page.js | 34 ++++++++++++------- 7 files changed, 62 insertions(+), 18 deletions(-) diff --git a/ui-v2/app/components/policy-selector.js b/ui-v2/app/components/policy-selector.js index 778c7296eb..295afce423 100644 --- a/ui-v2/app/components/policy-selector.js +++ b/ui-v2/app/components/policy-selector.js @@ -4,6 +4,7 @@ import { inject as service } from '@ember/service'; import updateArrayObject from 'consul-ui/utils/update-array-object'; const ERROR_PARSE_RULES = 'Failed to parse ACL rules'; +const ERROR_INVALID_POLICY = 'Invalid service policy'; const ERROR_NAME_EXISTS = 'Invalid Policy: A Policy with Name'; export default ChildSelectorComponent.extend({ @@ -38,10 +39,11 @@ export default ChildSelectorComponent.extend({ const err = e.error; if (typeof err.errors !== 'undefined') { const error = err.errors[0]; - let prop; + let prop = 'Rules'; let message = error.detail; switch (true) { case message.indexOf(ERROR_PARSE_RULES) === 0: + case message.indexOf(ERROR_INVALID_POLICY) === 0: prop = 'Rules'; message = error.detail; break; diff --git a/ui-v2/app/templates/components/policy-form.hbs b/ui-v2/app/templates/components/policy-form.hbs index eeee86e85f..c573ee5a1a 100644 --- a/ui-v2/app/templates/components/policy-form.hbs +++ b/ui-v2/app/templates/components/policy-form.hbs @@ -28,7 +28,7 @@ {{item.error.Name.validation}} {{/if}} -