Moved indexes routes to admin subroute

This commit is contained in:
Stanislav Romanov 2022-03-21 14:45:47 +03:00
parent 0cf17ddbc3
commit 685f38098b
25 changed files with 83 additions and 78 deletions

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>MeilisearchAdmin</title>
<title>MeiliSearch Admin</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

View file

@ -7,5 +7,5 @@ export function initialize(/* application */) {
}
export default {
initialize
initialize,
};

View file

@ -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' });
});
});
});

3
app/routes/admin.js Normal file
View file

@ -0,0 +1,3 @@
import Route from '@ember/routing/route';
export default class AdminRoute extends Route {}

View file

@ -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() {

View file

@ -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);
}
}

View file

@ -5,6 +5,6 @@ export default class IndexRoute extends Route {
@service router;
beforeModel() {
this.router.transitionTo('indexes');
this.router.transitionTo('admin.indexes');
}
}

View file

@ -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);
}
}

View file

@ -7,7 +7,7 @@
{{#each @model as |item|}}
<li>
<LinkTo
@route="indexes.element"
@route="admin.indexes.item"
@model={{item}}
class="flex flex-row items-center h-12 px-base"
>

View file

@ -0,0 +1,5 @@
{{page-title "Item"}}
<h1>{{@model.name}}</h1>
{{outlet}}

View file

@ -1,3 +0,0 @@
{{page-title "MeiliSearch Admin"}}
{{outlet}}

View file

@ -1,2 +0,0 @@
{{page-title "Element"}}
{{outlet}}

View file

@ -15,4 +15,4 @@ module.exports = {
extend: {},
},
plugins: [],
}
};

View file

@ -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();

View file

@ -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);
});

View file

@ -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);

View file

@ -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);

View file

@ -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);
});
});

View file

@ -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);
});
});

View file

@ -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);
});
});

View file

@ -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);
});
});

View file

@ -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);
});

View file

@ -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);
});
});

View file

@ -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);
});
});

View file

@ -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', {});