Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert dummy app to glimmer components #806

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"@fortawesome/free-brands-svg-icons": "^5.15.2",
"@fortawesome/free-regular-svg-icons": "^5.15.2",
"@fortawesome/free-solid-svg-icons": "^5.15.2",
"@glimmer/component": "^1.0.4",
"@glimmer/tracking": "^1.0.4",
"@html-next/vertical-collection": "^3.0.0",
"ember-classic-decorator": "^3.0.0",
"ember-cli-babel": "^7.26.6",
Expand All @@ -55,8 +57,6 @@
"@ember/test-helpers": "^2.4.2",
"@embroider/test-setup": "^1.8.3",
"@faker-js/faker": "^7.3.0",
"@glimmer/component": "^1.0.4",
"@glimmer/tracking": "^1.0.4",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"ember-auto-import": "^2.4.2",
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import classic from 'ember-classic-decorator';
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import ENV from '../config/environment';

@classic
export default class Application extends JSONAPIAdapter {
namespace = `${ENV.rootURL}api`;
}
18 changes: 6 additions & 12 deletions tests/dummy/app/components/base-table.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
// BEGIN-SNIPPET base-table
import classic from 'ember-classic-decorator';
import Component from '@ember/component';
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { isEmpty } from '@ember/utils';
import { inject as service } from '@ember/service';
import Table from 'ember-light-table';
import { restartableTask } from 'ember-concurrency';
import { tracked } from '@glimmer/tracking';

@classic
export default class BaseTable extends Component {
@service store;

model = null;

@tracked canLoadMore = true;
@tracked dir = 'asc';
@tracked limit = 10;
@tracked meta = null;
@tracked page = 0;
@tracked sort = 'firstName';

table = null;

init() {
super.init(...arguments);
constructor() {
super(...arguments);

const table = Table.create({
columns: this.columns,
rows: this.model,
rows: this.args.model,
});
const sortColumn = table.get('allColumns').findBy('valuePath', this.sort);

Expand All @@ -52,7 +46,7 @@ export default class BaseTable extends Component {
dir: this.dir,
});
const recordsArray = records.toArray();
this.model.pushObjects(recordsArray);
this.args.model.pushObjects(recordsArray);
this.table.addRows(recordsArray);
this.meta = records.meta;
this.canLoadMore = !isEmpty(records);
Expand All @@ -73,7 +67,7 @@ export default class BaseTable extends Component {
this.sort = column.get('valuePath');
this.canLoadMore = true;
this.page = 0;
this.model.clear();
this.args.model.clear();
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions tests/dummy/app/components/code-panel.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import classic from 'ember-classic-decorator';
import Component from '@ember/component';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { guidFor } from '@ember/object/internals';

@classic
export default class CodePanel extends Component {
collapse = true;
title = '';
snippets = null;
@tracked collapse = true;
elementId = guidFor(this);
}
2 changes: 0 additions & 2 deletions tests/dummy/app/components/columns/draggable-table.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// BEGIN-SNIPPET draggable-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';

@classic
export default class DraggableTable extends BaseTable {
get columns() {
return [
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/components/columns/grouped-table.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// BEGIN-SNIPPET grouped-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';

@classic
export default class GroupedTable extends BaseTable {
get columns() {
return [
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/components/columns/resizable-table.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// BEGIN-SNIPPET resizable-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';

@classic
export default class ResizableTable extends BaseTable {
get columns() {
return [
Expand Down
6 changes: 2 additions & 4 deletions tests/dummy/app/components/cookbook/client-side-table.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// BEGIN-SNIPPET client-side-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';
import { action } from '@ember/object';
import { restartableTask, timeout } from 'ember-concurrency';
import { tracked } from '@glimmer/tracking';

@classic
export default class PaginatedTable extends BaseTable {
query = '';

Expand Down Expand Up @@ -61,8 +59,8 @@ export default class PaginatedTable extends BaseTable {
];
}

init() {
super.init(...arguments);
constructor() {
super(...arguments);
this.fetchRecords.perform();
}

Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/components/cookbook/custom-row-table.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// BEGIN-SNIPPET custom-row-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';

@classic
export default class CustomRowTable extends BaseTable {
get columns() {
return [
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/components/cookbook/custom-sort-icon-table.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// BEGIN-SNIPPET custom-sort-icon-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';

@classic
export default class CustomSortIconTable extends BaseTable {
get columns() {
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// BEGIN-SNIPPET horizontal-scrolling-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';

@classic
export default class HorizontalScrollingTable extends BaseTable {
get columns() {
return [
Expand Down
8 changes: 3 additions & 5 deletions tests/dummy/app/components/cookbook/occluded-table.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// BEGIN-SNIPPET occluded-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';

@classic
export default class OccludedTable extends BaseTable {
limit = 100;

Expand Down Expand Up @@ -40,9 +38,9 @@ export default class OccludedTable extends BaseTable {
];
}

init() {
super.init(...arguments);
this.set('page', 1);
constructor() {
super(...arguments);
this.page = 1;
this.fetchRecords.perform();
}
}
Expand Down
8 changes: 3 additions & 5 deletions tests/dummy/app/components/cookbook/paginated-table.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// BEGIN-SNIPPET paginated-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';
import { action } from '@ember/object';

@classic
export default class PaginatedTable extends BaseTable {
limit = 12;

Expand Down Expand Up @@ -41,9 +39,9 @@ export default class PaginatedTable extends BaseTable {
];
}

init() {
super.init(...arguments);
this.send('setPage', 1);
constructor() {
super(...arguments);
this.setPage(1);
}

@action
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/components/cookbook/table-actions-table.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// BEGIN-SNIPPET table-actions-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';
import { action } from '@ember/object';

@classic
export default class TableActionsTable extends BaseTable {
get columns() {
return [
Expand Down
7 changes: 0 additions & 7 deletions tests/dummy/app/components/materialize-icon.js

This file was deleted.

2 changes: 0 additions & 2 deletions tests/dummy/app/components/responsive-table.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// BEGIN-SNIPPET responsive-table
import classic from 'ember-classic-decorator';
import BaseTable from './base-table';
import { action } from '@ember/object';

@classic
export default class ResponsiveTable extends BaseTable {
get columns() {
return [
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/components/rows/expandable-table.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// BEGIN-SNIPPET expandable-table
import classic from 'ember-classic-decorator';
import BaseTable from '../base-table';

@classic
export default class ExpandableTable extends BaseTable {
get columns() {
return [
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/components/rows/selectable-table.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// BEGIN-SNIPPET selectable-table
import BaseTable from '../base-table';
import { action } from '@ember/object';
import classic from 'ember-classic-decorator';

@classic
export default class ExpandableTable extends BaseTable {
get hasSelection() {
return this.table.selectedRows;
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/components/scrolling-table.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// BEGIN-SNIPPET scrolling-table
import classic from 'ember-classic-decorator';
import BaseTable from './base-table';
import { action } from '@ember/object';

@classic
export default class ScrollingTable extends BaseTable {
currentScrollOffset = 0;
scrollTo = 0;
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/components/simple-table.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// BEGIN-SNIPPET simple-table
import classic from 'ember-classic-decorator';
import BaseTable from './base-table';

@classic
export default class SimpleTable extends BaseTable {
get columns() {
return [
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/models/user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import classic from 'ember-classic-decorator';
import Model, { attr } from '@ember-data/model';

@classic
export default class User extends Model {
@attr('string')
firstName;
Expand Down
2 changes: 0 additions & 2 deletions tests/dummy/app/routes/table-route.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import classic from 'ember-classic-decorator';
import { A } from '@ember/array';
import Route from '@ember/routing/route';

@classic
export default class TableRouteRoute extends Route {
model() {
return A([]);
Expand Down