Skip to content

Commit

Permalink
chore: udpate to ember 4.12 and make embroider optimized
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
- Ember.js v3.28 or above
- Ember CLI v3.28 or above
- Node.js v14 or above
  • Loading branch information
velrest committed Jul 4, 2023
1 parent 855a842 commit 37cdaed
Show file tree
Hide file tree
Showing 67 changed files with 2,886 additions and 2,352 deletions.
79 changes: 0 additions & 79 deletions .github/workflows/ci.yml

This file was deleted.

9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ jobs:
strategy:
matrix:
scenario:
- ember-lts-3.28
- ember-release

- ember-lts-4.8
- ember-lts-4.12
# Disable for now since ember-data@4 causes an embroider build error. See https://github.com/projectcaluma/ember-emeis/pull/625#issuecomment-1614488464
# - ember-release
- embroider-safe
- embroider-optimized
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
43 changes: 19 additions & 24 deletions addon/components/relationship-select.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,22 @@
...attributes
{{did-insert (perform this.fetchModels)}}
/>
{{#let
(component (if @multiple "power-select-multiple" "power-select"))
as |RelationPowerSelect|
}}
<RelationPowerSelect
@searchEnabled={{this.searchEnabled}}
@search={{perform this.fetchModels}}
@options={{this.models}}
@selected={{@selected}}
@placeholder={{if
this.fetchModels.isRunning
(t "emeis.loading")
@placeholder
}}
@noMatchesMessage={{t "emeis.empty"}}
@renderInPlace={{true}}
@allowClear={{true}}
@onChange={{@onChange}}
{{did-update (perform this.fetchModels) @model}}
as |model|
>
{{yield model}}
</RelationPowerSelect>
{{/let}}
<this.selectComponent
@searchEnabled={{this.searchEnabled}}
@search={{perform this.fetchModels}}
@options={{this.models}}
@selected={{@selected}}
@placeholder={{if
this.fetchModels.isRunning
(t "emeis.loading")
@placeholder
}}
@noMatchesMessage={{t "emeis.empty"}}
@renderInPlace={{true}}
@allowClear={{true}}
@onChange={{@onChange}}
{{did-update (perform this.fetchModels) @model}}
as |model|
>
{{yield model}}
</this.selectComponent>
11 changes: 10 additions & 1 deletion addon/components/relationship-select.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { inject as service } from "@ember/service";
import { isTesting, macroCondition } from "@embroider/macros";
import Component from "@glimmer/component";
import { restartableTask, lastValue, timeout } from "ember-concurrency";
import PowerSelect from "ember-power-select/components/power-select";
import PowerSelectMultiple from "ember-power-select/components/power-select-multiple";

import { handleTaskErrors } from "ember-emeis/-private/decorators";

Expand All @@ -15,14 +18,20 @@ export default class RelationshipSelectComponent extends Component {
return this.models && this.args.modelName && this.models.length > 5;
}

get selectComponent() {
return this.args.multiple ? PowerSelectMultiple : PowerSelect;
}

@restartableTask
@handleTaskErrors
*fetchModels(search) {
if (this.args.model) {
return this.args.model;
}
if (typeof search === "string") {
yield timeout(500);
if (macroCondition(!isTesting())) {
yield timeout(500);
}
return yield this.store.query(this.args.modelName, {
filter: { search },
});
Expand Down
5 changes: 4 additions & 1 deletion addon/components/tree.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isArray } from "@ember/array";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { isTesting, macroCondition } from "@embroider/macros";
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { timeout, restartableTask } from "ember-concurrency";
Expand Down Expand Up @@ -43,7 +44,9 @@ export default class TreeComponent extends Component {

@restartableTask
*filter(event) {
yield timeout(100);
if (macroCondition(!isTesting())) {
yield timeout(100);
}

const filterItems = (
items,
Expand Down
4 changes: 4 additions & 0 deletions addon/controllers/permissions/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ export default class PermissionsEditController extends Controller {

return model;
}

@action setRoles(roles) {
this.model.roles = roles;
}
}
5 changes: 4 additions & 1 deletion addon/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Route from "@ember/routing/route";
import { service } from "@ember/service";

export default class IndexRoute extends Route {
@service hostRouter;

beforeModel() {
this.transitionTo("users");
this.hostRouter.transitionTo("ember-emeis.users");
}
}
1 change: 1 addition & 0 deletions addon/routes/permissions/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { handleModelErrors } from "ember-emeis/-private/decorators";
export default class PermissionsEditRoute extends Route {
@service notification;
@service intl;
@service store;

@handleModelErrors({ routeFor404: "permissions.index" })
model({ permission_id: id }) {
Expand Down
4 changes: 4 additions & 0 deletions addon/routes/permissions/new.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { inject as service } from "@ember/service";

import CreateRoute from "ember-emeis/-private/routes/create";

export default class PermissionsNewRoute extends CreateRoute {
detailView = "permissions.edit";

@service store;

model() {
return this.store.createRecord("permission");
}
Expand Down
3 changes: 2 additions & 1 deletion addon/routes/roles/edit.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
import { service } from "@ember/service";

import { handleModelErrors } from "ember-emeis/-private/decorators";

export default class RolesEditRoute extends Route {
@service notification;
@service intl;
@service store;

@handleModelErrors({ routeFor404: "roles.index" })
model({ role_id: id }) {
Expand Down
4 changes: 4 additions & 0 deletions addon/routes/roles/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { service } from "@ember/service";

import CreateRoute from "ember-emeis/-private/routes/create";

export default class RolesNewRoute extends CreateRoute {
@service store;

detailView = "roles.edit";

model() {
Expand Down
2 changes: 1 addition & 1 deletion addon/routes/scopes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
import { service } from "@ember/service";

export default class ScopesRoute extends Route {
@service store;
Expand Down
2 changes: 1 addition & 1 deletion addon/routes/scopes/edit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
import { service } from "@ember/service";

import { handleModelErrors } from "ember-emeis/-private/decorators";

Expand Down
4 changes: 4 additions & 0 deletions addon/routes/scopes/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { service } from "@ember/service";

import CreateRoute from "ember-emeis/-private/routes/create";

export default class ScopesNewRoute extends CreateRoute {
@service store;

detailView = "scopes.edit";

model() {
Expand Down
3 changes: 2 additions & 1 deletion addon/routes/users/edit.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
import { service } from "@ember/service";

import { handleModelErrors } from "ember-emeis/-private/decorators";

export default class UsersEditRoute extends Route {
@service notification;
@service intl;
@service store;

@handleModelErrors({ routeFor404: "users.index" })
async model({ user_id: id }) {
Expand Down
4 changes: 4 additions & 0 deletions addon/routes/users/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { service } from "@ember/service";

import CreateRoute from "ember-emeis/-private/routes/create";

export default class UsersNewRoute extends CreateRoute {
@service store;

detailView = "users.edit";

model() {
Expand Down
2 changes: 1 addition & 1 deletion addon/templates/permissions/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
@modelName="role"
@selected={{@model.roles}}
@placeholder="{{t 'emeis.permissions.headings.roles'}}..."
@onChange={{set @model "roles"}}
@onChange={{this.setRoles}}
@multiple="true"
required
as |role|
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/localized-attr.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from "ember-emeis/decorators/localized-attrs";
export { default } from "ember-emeis/decorators/localized-attr";
1 change: 0 additions & 1 deletion app/routes/users/edit/acl.js

This file was deleted.

1 change: 0 additions & 1 deletion app/routes/users/edit/index.js

This file was deleted.

1 change: 0 additions & 1 deletion app/templates/scopes/index.js

This file was deleted.

1 change: 0 additions & 1 deletion app/templates/users/edit/acl.js

This file was deleted.

1 change: 0 additions & 1 deletion app/templates/users/edit/index.js

This file was deleted.

10 changes: 7 additions & 3 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ module.exports = function (defaults) {
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
*/

const { maybeEmbroider } = require("@embroider/test-setup");
return maybeEmbroider(app, {
const { Webpack } = require("@embroider/webpack");
return require("@embroider/compat").compatBuild(app, Webpack, {
staticAddonTestSupportTrees: true,
staticAddonTrees: true,
staticHelpers: true,
staticModifiers: true,
staticComponents: true,
skipBabel: [
{
package: "qunit",
Expand Down
Loading

0 comments on commit 37cdaed

Please sign in to comment.