chore: 🤖 add placeholder template for errors
This commit is contained in:
4 files changed
+47
-7
No files matched your search
@@ -7,11 +7,7 @@ export default class OrgsOrgProjectsRoute extends Route {
|
||||
* Returns all projects from the store.
|
||||
* @return {Promise[ProjectModel]}
|
||||
*/
|
||||
async model() {
|
||||
try {
|
||||
return await this.store.findAll('project');
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
model() {
|
||||
return this.store.findAll('project');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{{!--
|
||||
In an error route, the error instance is `@model`. Error instances contain
|
||||
a list of errors, each of which has one convenience boolean set on it:
|
||||
|
||||
* Error booleans are attached based on the error status code:
|
||||
*
|
||||
* - `error.isUnauthenticated`: the session isn't authenticated
|
||||
* - `error.isForbidden`: the session is authenticated but does not have
|
||||
* permission to perform the requested action
|
||||
* - `error.isNotFound`: the requested resource could not be found
|
||||
* - `error.isServer`: an internal server error occurred
|
||||
* - `error.isUnknown`: an error occurred, but we don't know which or
|
||||
* we don't distinguish it yet
|
||||
|
||||
--}}
|
||||
|
||||
{{#each @model.errors as |error|}}
|
||||
|
||||
{{#if error.isUnauthenticated}}
|
||||
{{!-- error.status === 401 --}}
|
||||
{{/if}}
|
||||
|
||||
{{#if error.isForbidden}}
|
||||
{{!-- error.status === 403 --}}
|
||||
{{/if}}
|
||||
|
||||
{{#if error.isNotFound}}
|
||||
{{!-- error.status === 404 --}}
|
||||
{{/if}}
|
||||
|
||||
{{#if error.isServer}}
|
||||
{{!-- error.status === 500 --}}
|
||||
{{/if}}
|
||||
|
||||
{{#if error.isUnknown}}
|
||||
{{!-- error.status === 🤷 --}}
|
||||
{{/if}}
|
||||
|
||||
{{/each}}
|
||||
@@ -28,4 +28,8 @@ export default function() {
|
||||
this.get('/orgs/:org_id/projects/:project_id/host-catalogs/:id');
|
||||
this.patch('/orgs/:org_id/projects/:project_id/host-catalogs/:id');
|
||||
this.del('/orgs/:org_id/projects/:project_id/host-catalogs/:id');
|
||||
|
||||
// Uncomment the following line and the Response import above
|
||||
// Then change the response code to simulate error responses
|
||||
//this.get('/orgs/:org_id/projects', () => new Response(401));
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { RestSerializer } from 'ember-cli-mirage';
|
||||
import { underscore } from '@ember/string';
|
||||
import { isArray } from '@ember/array';
|
||||
|
||||
/**
|
||||
* Manages serialization/normalization of data into and out of the mock API.
|
||||
@@ -38,7 +39,7 @@ export default RestSerializer.extend({
|
||||
serialize() {
|
||||
let json = RestSerializer.prototype.serialize.apply(this, arguments);
|
||||
// If array, root it under a standard `items` key
|
||||
if (json.length) json = {items: json};
|
||||
if (isArray(json)) json = {items: json};
|
||||
return json;
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user