From 685f38098b55198f6a6bb982f6299deca1671bdc Mon Sep 17 00:00:00 2001 From: Stanislav Romanov Date: Mon, 21 Mar 2022 14:45:47 +0300 Subject: [PATCH] Moved indexes routes to admin subroute --- app/index.html | 2 +- app/initializers/custom-inflector-rules.js | 2 +- app/router.js | 6 ++++-- app/routes/admin.js | 3 +++ app/routes/{ => admin}/indexes.js | 2 +- app/routes/admin/indexes/item.js | 7 +++++++ app/routes/index.js | 2 +- app/routes/indexes/element.js | 10 ---------- app/templates/{ => admin}/indexes.hbs | 2 +- app/templates/admin/indexes/item.hbs | 5 +++++ app/templates/application.hbs | 3 --- app/templates/indexes/element.hbs | 2 -- config/tailwind.config.js | 2 +- ember-cli-build.js | 12 ++++++------ tests/unit/adapters/application-test.js | 4 ++-- .../initializers/custom-inflector-rules-test.js | 17 ++++++++++------- tests/unit/models/index-test.js | 4 ++-- tests/unit/routes/admin-test.js | 11 +++++++++++ tests/unit/routes/admin/indexes-test.js | 11 +++++++++++ tests/unit/routes/admin/indexes/item-test.js | 11 +++++++++++ tests/unit/routes/application-test.js | 11 ----------- tests/unit/routes/index-test.js | 4 ++-- tests/unit/routes/indexes-test.js | 11 ----------- tests/unit/routes/indexes/element-test.js | 11 ----------- tests/unit/serializers/application-test.js | 6 +++--- 25 files changed, 83 insertions(+), 78 deletions(-) create mode 100644 app/routes/admin.js rename app/routes/{ => admin}/indexes.js (76%) create mode 100644 app/routes/admin/indexes/item.js delete mode 100644 app/routes/indexes/element.js rename app/templates/{ => admin}/indexes.hbs (92%) create mode 100644 app/templates/admin/indexes/item.hbs delete mode 100644 app/templates/application.hbs delete mode 100644 app/templates/indexes/element.hbs create mode 100644 tests/unit/routes/admin-test.js create mode 100644 tests/unit/routes/admin/indexes-test.js create mode 100644 tests/unit/routes/admin/indexes/item-test.js delete mode 100644 tests/unit/routes/application-test.js delete mode 100644 tests/unit/routes/indexes-test.js delete mode 100644 tests/unit/routes/indexes/element-test.js diff --git a/app/index.html b/app/index.html index 031e5c9..1ed9789 100644 --- a/app/index.html +++ b/app/index.html @@ -3,7 +3,7 @@ - MeilisearchAdmin + MeiliSearch Admin diff --git a/app/initializers/custom-inflector-rules.js b/app/initializers/custom-inflector-rules.js index 351a500..4bbf1a8 100644 --- a/app/initializers/custom-inflector-rules.js +++ b/app/initializers/custom-inflector-rules.js @@ -7,5 +7,5 @@ export function initialize(/* application */) { } export default { - initialize + initialize, }; diff --git a/app/router.js b/app/router.js index 7868fb3..c546d83 100644 --- a/app/router.js +++ b/app/router.js @@ -7,7 +7,9 @@ export default class Router extends EmberRouter { } Router.map(function () { - this.route('indexes', function () { - this.route('element', { path: '/:index_id' }); + this.route('admin', function () { + this.route('indexes', function () { + this.route('item', { path: '/:index_id' }); + }); }); }); diff --git a/app/routes/admin.js b/app/routes/admin.js new file mode 100644 index 0000000..cb12e52 --- /dev/null +++ b/app/routes/admin.js @@ -0,0 +1,3 @@ +import Route from '@ember/routing/route'; + +export default class AdminRoute extends Route {} diff --git a/app/routes/indexes.js b/app/routes/admin/indexes.js similarity index 76% rename from app/routes/indexes.js rename to app/routes/admin/indexes.js index 4132ef1..255df8d 100644 --- a/app/routes/indexes.js +++ b/app/routes/admin/indexes.js @@ -1,7 +1,7 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; -export default class IndexesRoute extends Route { +export default class AdminIndexesRoute extends Route { @service store; async model() { diff --git a/app/routes/admin/indexes/item.js b/app/routes/admin/indexes/item.js new file mode 100644 index 0000000..bdbda7f --- /dev/null +++ b/app/routes/admin/indexes/item.js @@ -0,0 +1,7 @@ +import Route from '@ember/routing/route'; + +export default class AdminIndexesItemRoute extends Route { + model({ index_id }) { + return this.modelFor('admin.indexes').find((item) => item.id === index_id); + } +} diff --git a/app/routes/index.js b/app/routes/index.js index e52844e..cba3815 100644 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -5,6 +5,6 @@ export default class IndexRoute extends Route { @service router; beforeModel() { - this.router.transitionTo('indexes'); + this.router.transitionTo('admin.indexes'); } } diff --git a/app/routes/indexes/element.js b/app/routes/indexes/element.js deleted file mode 100644 index af16c44..0000000 --- a/app/routes/indexes/element.js +++ /dev/null @@ -1,10 +0,0 @@ -import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; - -export default class IndexesElementRoute extends Route { - @service store; - - async model({ index_id }) { - return this.store.find('index', index_id); - } -} diff --git a/app/templates/indexes.hbs b/app/templates/admin/indexes.hbs similarity index 92% rename from app/templates/indexes.hbs rename to app/templates/admin/indexes.hbs index 27d1239..5f91aeb 100644 --- a/app/templates/indexes.hbs +++ b/app/templates/admin/indexes.hbs @@ -7,7 +7,7 @@ {{#each @model as |item|}}
  • diff --git a/app/templates/admin/indexes/item.hbs b/app/templates/admin/indexes/item.hbs new file mode 100644 index 0000000..4d2d953 --- /dev/null +++ b/app/templates/admin/indexes/item.hbs @@ -0,0 +1,5 @@ +{{page-title "Item"}} + +

    {{@model.name}}

    + +{{outlet}} diff --git a/app/templates/application.hbs b/app/templates/application.hbs deleted file mode 100644 index c4cb938..0000000 --- a/app/templates/application.hbs +++ /dev/null @@ -1,3 +0,0 @@ -{{page-title "MeiliSearch Admin"}} - -{{outlet}} diff --git a/app/templates/indexes/element.hbs b/app/templates/indexes/element.hbs deleted file mode 100644 index 97bf730..0000000 --- a/app/templates/indexes/element.hbs +++ /dev/null @@ -1,2 +0,0 @@ -{{page-title "Element"}} -{{outlet}} \ No newline at end of file diff --git a/config/tailwind.config.js b/config/tailwind.config.js index 2aacddf..30d8614 100644 --- a/config/tailwind.config.js +++ b/config/tailwind.config.js @@ -15,4 +15,4 @@ module.exports = { extend: {}, }, plugins: [], -} +}; diff --git a/ember-cli-build.js b/ember-cli-build.js index 6c838fe..d1c2054 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -11,17 +11,17 @@ module.exports = function (defaults) { plugins: [ { module: autoprefixer, - options: {} + options: {}, }, { module: tailwind, options: { - config: './config/tailwind.config.js' - } - } + config: './config/tailwind.config.js', + }, + }, ], - } - } + }, + }, }); return app.toTree(); diff --git a/tests/unit/adapters/application-test.js b/tests/unit/adapters/application-test.js index eff23bb..1eee469 100644 --- a/tests/unit/adapters/application-test.js +++ b/tests/unit/adapters/application-test.js @@ -1,11 +1,11 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -module('Unit | Adapter | application', function(hooks) { +module('Unit | Adapter | application', function (hooks) { setupTest(hooks); // Replace this with your real tests. - test('it exists', function(assert) { + test('it exists', function (assert) { let adapter = this.owner.lookup('adapter:application'); assert.ok(adapter); }); diff --git a/tests/unit/initializers/custom-inflector-rules-test.js b/tests/unit/initializers/custom-inflector-rules-test.js index b90e410..99d8df7 100644 --- a/tests/unit/initializers/custom-inflector-rules-test.js +++ b/tests/unit/initializers/custom-inflector-rules-test.js @@ -5,23 +5,26 @@ import { module, test } from 'qunit'; import Resolver from 'ember-resolver'; import { run } from '@ember/runloop'; -module('Unit | Initializer | custom-inflector-rules', function(hooks) { - hooks.beforeEach(function() { - this.TestApplication = class TestApplication extends Application {} +module('Unit | Initializer | custom-inflector-rules', function (hooks) { + hooks.beforeEach(function () { + this.TestApplication = class TestApplication extends Application {}; this.TestApplication.initializer({ name: 'initializer under test', - initialize + initialize, }); - this.application = this.TestApplication.create({ autoboot: false, Resolver }); + this.application = this.TestApplication.create({ + autoboot: false, + Resolver, + }); }); - hooks.afterEach(function() { + hooks.afterEach(function () { run(this.application, 'destroy'); }); // TODO: Replace this with your real tests. - test('it works', async function(assert) { + test('it works', async function (assert) { await this.application.boot(); assert.ok(true); diff --git a/tests/unit/models/index-test.js b/tests/unit/models/index-test.js index cfc9cf3..788a6d3 100644 --- a/tests/unit/models/index-test.js +++ b/tests/unit/models/index-test.js @@ -1,11 +1,11 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -module('Unit | Model | index', function(hooks) { +module('Unit | Model | index', function (hooks) { setupTest(hooks); // Replace this with your real tests. - test('it exists', function(assert) { + test('it exists', function (assert) { let store = this.owner.lookup('service:store'); let model = store.createRecord('index', {}); assert.ok(model); diff --git a/tests/unit/routes/admin-test.js b/tests/unit/routes/admin-test.js new file mode 100644 index 0000000..82f7e2a --- /dev/null +++ b/tests/unit/routes/admin-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | admin', function (hooks) { + setupTest(hooks); + + test('it exists', function (assert) { + let route = this.owner.lookup('route:admin'); + assert.ok(route); + }); +}); diff --git a/tests/unit/routes/admin/indexes-test.js b/tests/unit/routes/admin/indexes-test.js new file mode 100644 index 0000000..8b64c35 --- /dev/null +++ b/tests/unit/routes/admin/indexes-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | admin/indexes', function (hooks) { + setupTest(hooks); + + test('it exists', function (assert) { + let route = this.owner.lookup('route:admin/indexes'); + assert.ok(route); + }); +}); diff --git a/tests/unit/routes/admin/indexes/item-test.js b/tests/unit/routes/admin/indexes/item-test.js new file mode 100644 index 0000000..c102c3c --- /dev/null +++ b/tests/unit/routes/admin/indexes/item-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | admin/indexes/item', function (hooks) { + setupTest(hooks); + + test('it exists', function (assert) { + let route = this.owner.lookup('route:admin/indexes/item'); + assert.ok(route); + }); +}); diff --git a/tests/unit/routes/application-test.js b/tests/unit/routes/application-test.js deleted file mode 100644 index 21e9fb3..0000000 --- a/tests/unit/routes/application-test.js +++ /dev/null @@ -1,11 +0,0 @@ -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); - }); -}); diff --git a/tests/unit/routes/index-test.js b/tests/unit/routes/index-test.js index eaaac17..01131fb 100644 --- a/tests/unit/routes/index-test.js +++ b/tests/unit/routes/index-test.js @@ -1,10 +1,10 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -module('Unit | Route | index', function(hooks) { +module('Unit | Route | index', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { + test('it exists', function (assert) { let route = this.owner.lookup('route:index'); assert.ok(route); }); diff --git a/tests/unit/routes/indexes-test.js b/tests/unit/routes/indexes-test.js deleted file mode 100644 index dee0187..0000000 --- a/tests/unit/routes/indexes-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Route | indexes', function(hooks) { - setupTest(hooks); - - test('it exists', function(assert) { - let route = this.owner.lookup('route:indexes'); - assert.ok(route); - }); -}); diff --git a/tests/unit/routes/indexes/element-test.js b/tests/unit/routes/indexes/element-test.js deleted file mode 100644 index 5fc902f..0000000 --- a/tests/unit/routes/indexes/element-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Route | indexes/element', function(hooks) { - setupTest(hooks); - - test('it exists', function(assert) { - let route = this.owner.lookup('route:indexes/element'); - assert.ok(route); - }); -}); diff --git a/tests/unit/serializers/application-test.js b/tests/unit/serializers/application-test.js index d197afe..11df6bb 100644 --- a/tests/unit/serializers/application-test.js +++ b/tests/unit/serializers/application-test.js @@ -1,18 +1,18 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -module('Unit | Serializer | application', function(hooks) { +module('Unit | Serializer | application', function (hooks) { setupTest(hooks); // Replace this with your real tests. - test('it exists', function(assert) { + test('it exists', function (assert) { let store = this.owner.lookup('service:store'); let serializer = store.serializerFor('application'); assert.ok(serializer); }); - test('it serializes records', function(assert) { + test('it serializes records', function (assert) { let store = this.owner.lookup('service:store'); let record = store.createRecord('application', {});