From 0200e2d0385259b4112cf8b445208f455b926e00 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Thu, 15 Dec 2022 11:29:03 -0500 Subject: [PATCH] Simplified error passing for policy editor --- .changelog/15435.txt | 3 +++ ui/app/components/policy-editor.js | 14 ++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 .changelog/15435.txt diff --git a/.changelog/15435.txt b/.changelog/15435.txt new file mode 100644 index 00000000000..383647319ed --- /dev/null +++ b/.changelog/15435.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: The web UI now provides a Token Management interface for management users on policy pages +``` diff --git a/ui/app/components/policy-editor.js b/ui/app/components/policy-editor.js index d3818b7dc8f..d37ef128743 100644 --- a/ui/app/components/policy-editor.js +++ b/ui/app/components/policy-editor.js @@ -2,7 +2,6 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { alias } from '@ember/object/computed'; -import messageForError from 'nomad-ui/utils/message-from-adapter-error'; export default class PolicyEditorComponent extends Component { @service flashMessages; @@ -22,14 +21,9 @@ export default class PolicyEditorComponent extends Component { try { const nameRegex = '^[a-zA-Z0-9-]{1,128}$'; if (!this.policy.name?.match(nameRegex)) { - throw { - errors: [ - { - detail: - 'Policy name must be 1-128 characters long and can only contain letters, numbers, and dashes.', - }, - ], - }; + throw new Error( + `Policy name must be 1-128 characters long and can only contain letters, numbers, and dashes.` + ); } const shouldRedirectAfterSave = this.policy.isNew; @@ -60,7 +54,7 @@ export default class PolicyEditorComponent extends Component { } catch (error) { this.flashMessages.add({ title: `Error creating Policy ${this.policy.name}`, - message: messageForError(error), + message: error, type: 'error', destroyOnClick: false, sticky: true,