Skip to content

Commit 679563a

Browse files
committed
remove @action decorator and type route templates
1 parent 67930e0 commit 679563a

File tree

12 files changed

+58
-55
lines changed

12 files changed

+58
-55
lines changed

app/components/forms/register.gts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { RegisterChangeset } from 'ember-boilerplate/changesets/register';
33
import TpkForm from '@triptyk/ember-input-validation/components/tpk-form';
44
import type validationsRegister from 'ember-boilerplate/validations/register';
55
import Component from '@glimmer/component';
6-
import { action } from '@ember/object';
76

87
export interface FormsRegisterSignature {
98
Args: {
@@ -19,13 +18,11 @@ export interface FormsRegisterSignature {
1918
}
2019

2120
export default class FormsRegister extends Component<FormsRegisterSignature> {
22-
@action
23-
setBirthdate(date: unknown) {
21+
setBirthdate = (date: unknown) => {
2422
this.args.changeset.set('birthDate', date as Date);
2523
}
2624

27-
@action
28-
selectCategory(category: unknown) {
25+
selectCategory = (category: unknown) => {
2926
this.args.changeset.set('category', category as string);
3027
}
3128

app/routes/404.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import Route from '@ember/routing/route';
22

3-
export default class NotFound extends Route {}
3+
export default class NotFoundRoute extends Route {}

app/routes/application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { IntlService } from 'ember-intl';
99
import type SessionService from 'ember-simple-auth/services/session';
1010
import { setupWorker } from 'msw/browser';
1111

12-
export default class Application extends Route {
12+
export default class ApplicationRoute extends Route {
1313
@service declare session: SessionService;
1414
@service declare currentUser: CurrentUserService;
1515
@service declare intl: IntlService;

app/routes/login.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { service } from '@ember/service';
33

44
import type SessionService from 'ember-simple-auth/services/session';
55

6-
export default class Login extends Route {
6+
export default class LoginRoute extends Route {
77
@service declare session: SessionService;
88

99
beforeModel() {

app/routes/register.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import Route from '@ember/routing/route';
22

3-
export interface RegisterRouteParams {}
4-
5-
export type RegisterRouteModel = Resolved<ReturnType<RegisterRoute['model']>>;
6-
73
export default class RegisterRoute extends Route {
84
model() {
95
return {};

app/templates/404.gts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import Component from '@glimmer/component';
22
import { on } from '@ember/modifier';
3-
import { action } from '@ember/object';
4-
53
import t from 'ember-intl/helpers/t';
64
import RouteTemplate from 'ember-route-template';
5+
import type { RouteTemplateSignature } from 'ember-boilerplate/utils/route-template';
6+
import type NotFoundRoute from 'ember-boilerplate/routes/404';
77

88
export interface NotFoundRouteComponentSignature {}
99

10-
class NotFoundRouteComponent extends Component<NotFoundRouteComponentSignature> {
11-
@action
12-
comeback() {
10+
class NotFoundRouteComponent extends Component<RouteTemplateSignature<NotFoundRoute>> {
11+
comeback = () => {
1312
window.history.back();
1413
}
1514

app/templates/application.gts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import HeadLayout from 'ember-cli-head/components/head-layout';
77
import RouteTemplate from 'ember-route-template';
88

99
import type FlashMessageService from 'ember-cli-flash/services/flash-messages';
10+
import type { RouteTemplateSignature } from 'ember-boilerplate/utils/route-template';
11+
import type ApplicationRoute from 'ember-boilerplate/routes/application';
1012

11-
class ApplicationRouteComponent extends Component {
13+
class ApplicationRouteComponent extends Component<RouteTemplateSignature<ApplicationRoute>> {
1214
@service declare flashMessages: FlashMessageService;
1315

1416
<template>

app/templates/forgot-password.gts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Component from '@glimmer/component';
2-
import { action } from '@ember/object';
2+
33
import { service } from '@ember/service';
44

55
import { ForgotPasswordChangeset } from 'ember-boilerplate/changesets/forgot-password';
@@ -12,26 +12,25 @@ import { tracked } from 'tracked-built-ins';
1212
import type Router from '@ember/routing/router';
1313
import type FlashMessageService from 'ember-cli-flash/services/flash-messages';
1414
import RequestManager from '@ember-data/request';
15+
import type ForgotPasswordRoute from 'ember-boilerplate/routes/forgot-password';
16+
import type { RouteTemplateSignature } from 'ember-boilerplate/utils/route-template';
1517

16-
interface PagesForgotPasswordArgs {}
17-
18-
class PagesForgotPassword extends Component<PagesForgotPasswordArgs> {
18+
class PagesForgotPassword extends Component<RouteTemplateSignature<ForgotPasswordRoute>> {
1919
@service declare router: Router;
2020
@service declare requestManager: RequestManager;
2121
@service declare flashMessages: FlashMessageService;
2222
@tracked changeset: ForgotPasswordChangeset;
2323

2424
validationSchema = forgotPasswordSchema;
2525

26-
constructor(owner: unknown, args: PagesForgotPasswordArgs) {
26+
constructor(owner: unknown, args: RouteTemplateSignature<ForgotPasswordRoute>['Args']) {
2727
super(owner, args);
2828
this.changeset = new ForgotPasswordChangeset({
2929
email: '',
3030
});
3131
}
3232

33-
@action
34-
async sendRecoveryRequest(changeset: ForgotPasswordChangeset) {
33+
sendRecoveryRequest = async (changeset: ForgotPasswordChangeset) => {
3534
try {
3635
await this.requestManager.request({
3736
url: '/auth/forgot-password',

app/templates/login.gts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Component from '@glimmer/component';
22
import { tracked } from '@glimmer/tracking';
3-
import { action } from '@ember/object';
3+
44
import { service } from '@ember/service';
55
import { waitFor } from '@ember/test-waiters';
66

@@ -15,10 +15,10 @@ import type RouterService from '@ember/routing/router-service';
1515
import type CurrentUserService from 'ember-boilerplate/services/current-user';
1616
import type FlashMessageService from 'ember-cli-flash/services/flash-messages';
1717
import type SessionService from 'ember-simple-auth/services/session';
18+
import type { RouteTemplateSignature } from 'ember-boilerplate/utils/route-template';
19+
import type LoginRoute from 'ember-boilerplate/routes/login';
1820

19-
interface PagesLoginArgs {}
20-
21-
class PagesLogin extends Component<PagesLoginArgs> {
21+
class PagesLogin extends Component<RouteTemplateSignature<LoginRoute>> {
2222
@service declare flashMessages: FlashMessageService;
2323
@service declare currentUser: CurrentUserService;
2424
@service declare router: RouterService;
@@ -28,17 +28,15 @@ class PagesLogin extends Component<PagesLoginArgs> {
2828

2929
@tracked changeset: LoginChangeset;
3030

31-
public constructor(owner: unknown, args: PagesLoginArgs) {
31+
public constructor(owner: unknown, args: RouteTemplateSignature<LoginRoute>['Args']) {
3232
super(owner, args);
3333
this.changeset = new LoginChangeset({
3434
email: '',
3535
password: '',
3636
});
3737
}
3838

39-
@action
40-
@waitFor
41-
async login(changeset: LoginChangeset) {
39+
login = waitFor(async (changeset: LoginChangeset) => {
4240
try {
4341
await this.session.authenticate('authenticator:jwt', {
4442
email: changeset.get('email'),
@@ -49,7 +47,7 @@ class PagesLogin extends Component<PagesLoginArgs> {
4947
} catch (e) {
5048
this.flashMessages.danger('Username or password incorrect');
5149
}
52-
}
50+
});
5351

5452
<template>
5553
<LoginLayout @title={{t "components.templates.login.title"}}>

app/templates/register.gts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Component from '@glimmer/component';
22
import { tracked } from '@glimmer/tracking';
3-
import { action } from '@ember/object';
43
import { service } from '@ember/service';
54

65
import { RegisterChangeset } from 'ember-boilerplate/changesets/register';
@@ -14,20 +13,18 @@ import type RegisterChangesetService from 'ember-boilerplate/services/changesets
1413
import type ErrorHandlerService from 'ember-boilerplate/services/error-handler';
1514
import type FlashMessageService from 'ember-cli-flash/services/flash-messages';
1615
import { array } from '@ember/helper';
16+
import type { RouteTemplateSignature } from 'ember-boilerplate/utils/route-template';
17+
import type RegisterRoute from 'ember-boilerplate/routes/register';
1718

18-
export interface RegisterRouteComponentSignature {
19-
Args: {};
20-
}
21-
22-
class RegisterRouteComponent extends Component<RegisterRouteComponentSignature> {
19+
class RegisterRouteComponent extends Component<RouteTemplateSignature<RegisterRoute>> {
2320
@service declare flashMessages: FlashMessageService;
2421
@service('changesets/register') declare register: RegisterChangesetService;
2522
@service declare errorHandler: ErrorHandlerService;
2623
@tracked declare changeset: RegisterChangeset;
2724

2825
validationSchema = formsRegisterSchema;
2926

30-
constructor(owner: unknown, args: RegisterRouteComponentSignature['Args']) {
27+
constructor(owner: unknown, args: RouteTemplateSignature<RegisterRoute>['Args']) {
3128
super(owner, args);
3229
this.changeset = new RegisterChangeset({
3330
email: '',
@@ -47,8 +44,7 @@ class RegisterRouteComponent extends Component<RegisterRouteComponentSignature>
4744
});
4845
}
4946

50-
@action
51-
async saveRegister(changeset: RegisterChangeset) {
47+
saveRegister = async (changeset: RegisterChangeset) => {
5248
const user = await this.register.save(changeset);
5349

5450
if (user.isErr) {

0 commit comments

Comments
 (0)