Skip to content

Commit

Permalink
Begin updating syntax
Browse files Browse the repository at this point in the history
I know we can update to angle bracket components.
Can we also update to the {{fn}} helper?
  • Loading branch information
paulcwatts committed Aug 19, 2020
1 parent b2b96c8 commit 28d69b6
Show file tree
Hide file tree
Showing 27 changed files with 195 additions and 184 deletions.
40 changes: 20 additions & 20 deletions tests/dummy/app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { set } from '@ember/object';
import { action, set } from '@ember/object';
import { alias } from '@ember/object/computed';

export default Controller.extend({
cognito: service(),
currentUser: service(),
session: service(),
poolId: alias('cognito.poolId'),
clientId: alias('cognito.clientId'),
export default class ApplicationController extends Controller {
@service cognito;
@service currentUser;
@service session;
@alias('cognito.poolId') poolId;
@alias('cognito.clientId') clientId;

init() {
this._super(...arguments);
constructor() {
super(...arguments);
let poolId = localStorage.getItem('ember-cognito/dummy/poolId');
let clientId = localStorage.getItem('ember-cognito/dummy/clientId');
// Ignore the defaults, which are used to test the configuration in unit tests
Expand All @@ -22,17 +22,17 @@ export default Controller.extend({
}
set(this, 'poolId', poolId);
set(this, 'clientId', clientId);
},
}

actions: {
saveIds(e) {
e.preventDefault();
localStorage.setItem('ember-cognito/dummy/poolId', this.poolId);
localStorage.setItem('ember-cognito/dummy/clientId', this.clientId);
},
@action
saveIds(e) {
e.preventDefault();
localStorage.setItem('ember-cognito/dummy/poolId', this.poolId);
localStorage.setItem('ember-cognito/dummy/clientId', this.clientId);
}

logout() {
this.session.invalidate();
}
@action
logout() {
this.session.invalidate();
}
});
}
8 changes: 4 additions & 4 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<nav class="navbar navbar-light navbar-expand bg-light">
{{#link-to "index" class="navbar-brand"}}ember-cognito{{/link-to}}
<LinkTo @route="index" class="navbar-brand">ember-cognito</LinkTo>

<div class="collapse navbar-collapse">
<form class="form-inline ml-auto" onsubmit={{action "saveIds"}}>
<form class="form-inline ml-auto" {{on "submit" (fn this.saveIds)}}>
<label for="pool_id" class="sr-only">Cognito Pool ID</label>
<input
id="pool_id"
Expand All @@ -27,8 +27,8 @@
{{#if this.session.isAuthenticated}}
<li class="nav-item"><a href="#" class="logout-link" onclick={{action "logout"}}>Logout</a></li>
{{else}}
<li class="nav-item">{{#link-to "login" class="nav-link login-link"}}Login{{/link-to}}</li>
<li class="nav-item">{{#link-to "register" class="nav-link register-link"}}Register{{/link-to}}</li>
<li class="nav-item"><LinkTo @route="login" class="nav-link login-link">Login</LinkTo></li>
<li class="nav-item"><LinkTo @route="register" class="nav-link register-link">Register</LinkTo></li>
{{/if}}
</ul>
</div>
Expand Down
7 changes: 4 additions & 3 deletions tests/dummy/app/templates/attribute-verify.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{attribute-verify-route
name=this.name
onComplete=(action (transition-to-route this "index"))}}
<AttributeVerifyRoute
@name={{this.name}}
@onComplete={{fn (transition-to-route this "index")}}
/>
9 changes: 5 additions & 4 deletions tests/dummy/app/templates/attribute.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{attribute-route
model=this.model
onSave=(action (transition-to-route this "index"))
onDelete=(action (transition-to-route this "index"))}}
<AttributeRoute
@model={{this.model}}
@onSave={{fn (transition-to-route this "index")}}
@onDelete={{fn (transition-to-route this "index")}}
/>
5 changes: 3 additions & 2 deletions tests/dummy/app/templates/change-password.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{{change-password-route
onComplete=(action (transition-to-route this "index"))}}
<ChangePasswordRoute
@onComplete={{fn (transition-to-route this "index")}}
/>
24 changes: 12 additions & 12 deletions tests/dummy/app/templates/components/attribute-route.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
{{/if}}
<div class="form-group">
<label for="name">Name</label>
{{input
value=this.model.name
<Input
@value={{this.model.name}}
class="form-control"
id="name"
autofocus=true
required=true
}}
@id="name"
autofocus
required
/>
</div>
<div class="form-group">
<label for="value">Value</label>
{{input
value=this.model.value
<Input
@value={{this.model.value}}
class="form-control"
id="value"
required=true
}}
@id="value"
required
/>
</div>
<button type="submit" class="btn btn-primary">Save</button>
<button class="btn btn-danger" onclick={{action "deleteAttr"}}>Delete</button>
<button class="btn btn-danger" onclick={{action "deleteAttr"}} type="button">Delete</button>
</form>
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions tests/dummy/app/templates/components/attribute-verify-route.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div class="container">
<div class="row">
<div class="col-4">
<h1>Verify {{name}}</h1>
<h1>Verify {{@name}}</h1>
<form class="verify-attribute-form" onsubmit={{action "verifyAttribute"}}>
{{#if this.errorMessage}}
<div class="alert alert-danger">{{this.errorMessage}}</div>
{{/if}}
<div class="form-group">
<label for="code">Verification Code</label>
{{input
value=this.code
<Input
@value={{this.code}}
class="form-control"
id="code"
@id="code"
placeholder="123456"
required=true
}}
required
/>
</div>
<button type="submit" class="btn btn-primary">Verify</button>
</form>
Expand Down
26 changes: 13 additions & 13 deletions tests/dummy/app/templates/components/change-password-route.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
{{/if}}
<div class="form-group">
<label for="username">Old Password</label>
{{input
value=this.oldPassword
type="password"
<Input
@value={{this.oldPassword}}
@type="password"
class="form-control"
id="username"
autofocus=true
required=true
}}
@id="username"
autofocus
required
/>
</div>
<div class="form-group">
<label for="code">New Password</label>
{{input
value=this.newPassword
type="password"
<Input
@value={{this.newPassword}}
@type="password"
class="form-control"
id="code"
required=true
}}
@id="code"
required
/>
</div>
<button type="submit" class="btn btn-primary">Reset Password</button>
</form>
Expand Down
14 changes: 7 additions & 7 deletions tests/dummy/app/templates/components/delete-user-route.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
{{/if}}
<div class="form-group">
<label for="delete">Delete</label>
{{input
value=this.deleteVal
<Input
@value={{this.deleteVal}}
class="form-control"
id="delete"
autofocus=true
required=true
}}
@id="delete"
autofocus
required
/>
</div>
<button type="submit" class="btn btn-danger">Delete User</button>
{{#link-to "index" class="btn btn-info ml-auto"}}Go back{{/link-to}}
<LinkTo @route="index" class="btn btn-info ml-auto">Go back</LinkTo>
</form>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@
{{/if}}
<div class="form-group">
<label for="username">Username</label>
{{input
value=this.username
<Input
@value={{this.username}}
class="form-control"
id="username"
@id="username"
placeholder="Username"
autofocus=true
required=true
}}
autofocus
required
/>
</div>
<div class="form-group">
<label for="code">Code</label>
{{input
value=this.code
<Input
@value={{this.code}}
class="form-control"
id="code"
@id="code"
placeholder="123456"
required=true
}}
required
/>
</div>
<div class="form-group">
<label for="password">New Password</label>
{{input
value=this.password
type="password"
<Input
@value={{this.password}}
@type="password"
class="form-control"
id="password"
@id="password"
placeholder="Password"
required=true
}}
required
/>
</div>
<button type="submit" class="btn btn-primary">Reset Password</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
{{/if}}
<div class="form-group">
<label for="username">Username</label>
{{input
value=this.username
<Input
@value={{this.username}}
class="form-control"
id="username"
@id="username"
placeholder="Username"
autofocus=true
required=true
}}
autofocus
required
/>
</div>
<button type="submit" class="btn btn-primary">Send code</button>
</form>
Expand Down
24 changes: 12 additions & 12 deletions tests/dummy/app/templates/components/index-auth.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,40 @@
</tr>
</thead>
<tbody>
{{#each model.attributes as |attr|}}
{{#each @model.attributes as |attr|}}
<tr>
<td>{{attr.name}}</td>
<td>{{attr.value}}</td>
<td>
{{#link-to "attribute" (query-params name=attr.name)}}
<LinkTo @route="attribute" @query={{hash name=attr.name}}>
Edit
{{/link-to}}
</LinkTo>
</td>
</tr>
{{/each}}
</tbody>
</table>
{{#link-to "attribute" (query-params name=undefined) class="btn btn-light btn-block"}}
<LinkTo @route="attribute" @query={{hash name=undefined}} class="btn btn-light btn-block">
Add attribute
{{/link-to}}
</LinkTo>
{{#unless this.emailVerified}}
<button class="btn btn-light btn-block" onclick={{action "verifyAttribute" "email"}}>
<button class="btn btn-light btn-block" onclick={{action "verifyAttribute" "email"}} type="button">
Verify email
</button>
{{/unless}}
{{#unless this.phonenNumberVerified}}
<button class="btn btn-light btn-block" onclick={{action "verifyAttribute" "phone_number"}}>
{{#unless this.phoneNumberVerified}}
<button class="btn btn-light btn-block" onclick={{action "verifyAttribute" "phone_number"}} type="button">
Verify phone number
</button>
{{/unless}}

<h2 class="mt-4">Actions</h2>
{{#link-to "change-password" class="btn btn-light btn-block"}}
<LinkTo @route="change-password" class="btn btn-light btn-block">
Change password
{{/link-to}}
{{#link-to "delete-user" class="btn btn-outline-danger btn-block mt-3"}}
</LinkTo>
<LinkTo @route="delete-user" class="btn btn-outline-danger btn-block mt-3">
Delete user
{{/link-to}}
</LinkTo>
</div>

<div class="col-6">
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/components/index-unauth.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<li>Add your Cognito Pool ID and Client ID in the header above.</li>
<li>Click <b>Save</b> to save this to local storage.</li>
<li>
Click {{#link-to "login"}}Login{{/link-to}} to login with an existing user or
{{#link-to "register"}}Register{{/link-to}} to create a new user.
Click <LinkTo @route="login">Login</LinkTo> to login with an existing user or
<LinkTo @route="register">Register</LinkTo> to create a new user.
</li>
</ol>
</div>
Expand Down
Loading

0 comments on commit 28d69b6

Please sign in to comment.