chore: 🤖 add initial mocked projects list view
This commit is contained in:
24 files changed
+440
-20
No files matched your search
@@ -6,4 +6,10 @@ export default class Router extends EmberRouter {
|
||||
rootURL = config.rootURL;
|
||||
}
|
||||
|
||||
Router.map(function () {});
|
||||
Router.map(function () {
|
||||
this.route('orgs', function () {
|
||||
this.route('org', { path: ':org_id' }, function () {
|
||||
this.route('projects');
|
||||
});
|
||||
});
|
||||
});
|
||||
Whitespace-only changes.
@@ -0,0 +1,6 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
/**
|
||||
* Entry route for the application.
|
||||
*/
|
||||
export default class ApplicationRoute extends Route {}
|
||||
@@ -0,0 +1,3 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class OrgsRoute extends Route {}
|
||||
@@ -0,0 +1,20 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class OrgsOrgRoute extends Route {
|
||||
// =services
|
||||
|
||||
@service scope;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Sets the scope to the specified organization and returns the org.
|
||||
* @param {object} params
|
||||
* @return {object}
|
||||
*/
|
||||
model({ org_id: id }) {
|
||||
this.scope.org = { id };
|
||||
return this.scope.org;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class OrgsOrgProjectsRoute extends Route {
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Returns all projects from the store.
|
||||
* @return {Promise[ProjectModel]}
|
||||
*/
|
||||
model() {
|
||||
return this.store.findAll('project');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{{outlet}}
|
||||
@@ -0,0 +1 @@
|
||||
{{outlet}}
|
||||
@@ -0,0 +1,9 @@
|
||||
<h1>{{t 'resources.projects'}}</h1>
|
||||
|
||||
<ul>
|
||||
{{#each @model as |project|}}
|
||||
<li>{{project.name}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
{{outlet}}
|
||||
@@ -25,6 +25,10 @@ module.exports = function (environment) {
|
||||
// when it is created
|
||||
},
|
||||
|
||||
api: {
|
||||
namespace: 'api/v1',
|
||||
},
|
||||
|
||||
appName: APP_NAME,
|
||||
|
||||
contentSecurityPolicyHeader: 'Content-Security-Policy',
|
||||
@@ -38,8 +42,8 @@ module.exports = function (environment) {
|
||||
'img-src': ["'self'"],
|
||||
'style-src': ["'self'"],
|
||||
'media-src': ["'self'"],
|
||||
'manifest-src': ["'self'"]
|
||||
}
|
||||
'manifest-src': ["'self'"],
|
||||
},
|
||||
};
|
||||
|
||||
// Unsafe policy is necessary in development and test environments, but should
|
||||
@@ -60,10 +64,10 @@ module.exports = function (environment) {
|
||||
componentOptions: {
|
||||
axeOptions: {
|
||||
checks: {
|
||||
'color-contrast': { options: { noScroll: true } }
|
||||
}
|
||||
}
|
||||
}
|
||||
'color-contrast': { options: { noScroll: true } },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
enableUnsafeCSP();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import config from '../config/environment';
|
||||
|
||||
export default function() {
|
||||
|
||||
// make this `http://localhost:8080`, for example, if your API is on a different server
|
||||
// this.urlPrefix = '';
|
||||
// make this `/api`, for example, if your API is namespaced
|
||||
this.namespace = config.api.namespace;
|
||||
// delay for each request, automatically set to 0 during testing
|
||||
this.timing = 50;
|
||||
|
||||
/*
|
||||
Shorthand cheatsheet:
|
||||
|
||||
this.get('/posts');
|
||||
this.post('/posts');
|
||||
this.get('/posts/:id');
|
||||
this.put('/posts/:id'); // or this.patch
|
||||
this.del('/posts/:id');
|
||||
|
||||
https://www.ember-cli-mirage.com/docs/route-handlers/shorthands
|
||||
*/
|
||||
|
||||
this.get('/orgs/:org_id/projects');
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import factory from '../generated/factories/project';
|
||||
|
||||
export default factory.extend();
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Factory } from 'ember-cli-mirage';
|
||||
import { random, date } from 'faker';
|
||||
|
||||
/**
|
||||
* GeneratedProjectModelFactory
|
||||
* Project contains all fields related to a Project resource
|
||||
*/
|
||||
export default Factory.extend({
|
||||
|
||||
name: () => random.words(),
|
||||
description: () => random.words(),
|
||||
created_time: () => date.recent(),
|
||||
updated_time: () => date.recent(),
|
||||
disabled: () => random.boolean(),
|
||||
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
export default function(server) {
|
||||
|
||||
server.createList('project', 3);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { RestSerializer } from 'ember-cli-mirage';
|
||||
import { underscore } from '@ember/string';
|
||||
|
||||
/**
|
||||
* Manages serialization/normalization of data into and out of the mock API.
|
||||
*/
|
||||
export default RestSerializer.extend({
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* False to disable automatically rooting payloads under a key.
|
||||
* This is handled by the `serialize()` method, see below.
|
||||
* @type {boolean}
|
||||
*/
|
||||
root: false,
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
embed: true,
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Generates an underscored key for the attribute.
|
||||
* @param {string} attr
|
||||
* @return {string}
|
||||
*/
|
||||
keyForAttribute(attr) {
|
||||
return underscore(attr);
|
||||
},
|
||||
|
||||
/**
|
||||
* Serialize items into a root key `items`.
|
||||
* @return {object}
|
||||
*/
|
||||
serialize() {
|
||||
let json = RestSerializer.prototype.serialize.apply(this, arguments);
|
||||
// If array, root it under a standard `items` key
|
||||
if (json.length) json = {items: json};
|
||||
return json;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -47,6 +47,7 @@
|
||||
"ember-cli-eslint": "^5.1.0",
|
||||
"ember-cli-htmlbars": "^4.2.2",
|
||||
"ember-cli-inject-live-reload": "^2.0.2",
|
||||
"ember-cli-mirage": "^1.1.6",
|
||||
"ember-cli-sass": "^10.0.1",
|
||||
"ember-cli-sri": "^2.1.1",
|
||||
"ember-cli-template-lint": "^1.0.0-beta.3",
|
||||
@@ -67,6 +68,7 @@
|
||||
"emberx-select": "github:adopted-ember-addons/emberx-select#bc5f774",
|
||||
"eslint-plugin-ember": "^7.7.2",
|
||||
"eslint-plugin-node": "^11.0.0",
|
||||
"faker": "^4.1.0",
|
||||
"loader.js": "^4.7.0",
|
||||
"prettier": "^2.0.5",
|
||||
"qunit-dom": "^1.0.0",
|
||||
|
||||
@@ -3,10 +3,10 @@ import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Helper | app-name', function(hooks) {
|
||||
module('Integration | Helper | app-name', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function(assert) {
|
||||
test('it renders', async function (assert) {
|
||||
await render(hbs`{{app-name}}`);
|
||||
assert.equal(this.element.textContent.trim(), 'Application Name');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | application', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:application');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | orgs', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:orgs');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | orgs/org', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:orgs/org');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | orgs/org/projects', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:orgs/org/projects');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,2 @@
|
||||
app:
|
||||
name: 'Application Name'
|
||||
example:
|
||||
text: 'Example'
|
||||
resources:
|
||||
projects: Projects
|
||||
Reference in new issue
Block a user