Merge branch 'develop' into ICU-617-add-username-to-account-list
This commit is contained in:
6 files changed
+142
-12
No files matched your search
@@ -0,0 +1,6 @@
|
||||
<Rose::Message @title={{t (concat "errors." this.messageCode ".title")}} @subtitle={{concat (t "errors.titles.error") " " this.status}} @icon={{this.icon}} as |message|>
|
||||
<message.description>{{t (concat "errors." this.messageCode ".description")}}</message.description>
|
||||
{{#if this.helpRoute}}
|
||||
<message.link @route={{this.helpRoute}}>{{t "actions.help"}}</message.link>
|
||||
{{/if}}
|
||||
</Rose::Message>
|
||||
@@ -0,0 +1,61 @@
|
||||
import Message from 'rose/components/rose/message';
|
||||
import { computed } from '@ember/object';
|
||||
|
||||
/*
|
||||
* Helpful error booleans are attached based on the error status code:
|
||||
*
|
||||
* - 401 - `error.isUnauthenticated`: the session isn't authenticated
|
||||
* - 403 - `error.isForbidden`: the session is authenticated but does not have
|
||||
* permission to perform the requested action
|
||||
* - 404 - `error.isNotFound`: the requested resource could not be found
|
||||
* - 500 - `error.isServer`: an internal server error occurred
|
||||
*
|
||||
* For an unknown error state, i.e error state not matching to the above defined list:
|
||||
* - unknown - `error.isUnknown`: an error occurred, but we don't know which or
|
||||
* we don't distinguish it yet
|
||||
*/
|
||||
|
||||
const statuses = ['401', '403', '404', '500'];
|
||||
|
||||
export default class ErrorMessageComponent extends Message {
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Returns an icon for error status.
|
||||
* @return {string}
|
||||
*/
|
||||
@computed('status')
|
||||
get icon() {
|
||||
switch (this.status) {
|
||||
case '401':
|
||||
case '403':
|
||||
return 'disabled';
|
||||
case '404':
|
||||
return 'help-circle-outline';
|
||||
default:
|
||||
return 'alert-circle-outline';
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Enable when help documentation can be linked in.
|
||||
/**
|
||||
* Returns an route string for help text in message.
|
||||
* @return {string}
|
||||
*/
|
||||
// get helpRoute() {
|
||||
// return 'index'
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns 'unknown' status code when provided error status
|
||||
* isn't part of predefined statuses.
|
||||
* @return {string}
|
||||
*/
|
||||
@computed('status')
|
||||
get messageCode() {
|
||||
let messageCode = this.status;
|
||||
if(!statuses.includes(messageCode)) messageCode = 'unknown';
|
||||
return messageCode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{{title (t "errors.titles.error") }}
|
||||
<Rose::Layout::Centered>
|
||||
{{#each @model.errors as |error|}}
|
||||
<Error::Message @status={{error.status}}/>
|
||||
{{/each}}
|
||||
</Rose::Layout::Centered>
|
||||
Reference in new issue
Block a user