Skip to content

Commit 36cd32b

Browse files
committed
Split settings route into three dedicated routes
1 parent 085861d commit 36cd32b

File tree

18 files changed

+229
-162
lines changed

18 files changed

+229
-162
lines changed

app/components/settings-page.hbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div local-class="page" ...attributes>
2+
<SideMenu as |menu|>
3+
<menu.Item @link={{link "settings.profile"}}>Profile</menu.Item>
4+
<menu.Item @link={{link "settings.email-notifications"}}>Email Notifications</menu.Item>
5+
<menu.Item @link={{link "settings.tokens"}}>API Tokens</menu.Item>
6+
</SideMenu>
7+
8+
<div local-class="content">
9+
{{yield}}
10+
</div>
11+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.page {
2+
display: grid;
3+
gap: 16px;
4+
5+
@media only screen and (min-width: 891px) {
6+
grid-template:
7+
"menu content" auto /
8+
200px auto;
9+
}
10+
}
11+
12+
.content {
13+
h2:first-child {
14+
margin-top: 4px;
15+
}
16+
}

app/controllers/settings/index.js renamed to app/controllers/settings/email-notifications.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { alias } from 'macro-decorators';
66

77
import ajax from '../../utils/ajax';
88

9-
export default class SettingsController extends Controller {
9+
export default class EmailNotificationsSettingsController extends Controller {
1010
isResetting = false;
1111

1212
@alias('model.ownedCrates') ownedCrates;

app/router.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ Router.map(function () {
3131
this.route('following');
3232
this.route('pending-invites');
3333
});
34-
this.route('settings');
34+
this.route('settings', function () {
35+
this.route('email-notifications');
36+
this.route('profile');
37+
this.route('tokens');
38+
});
3539
this.route('user', { path: '/users/:user_id' });
3640
this.route('install');
3741
this.route('search');
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { inject as service } from '@ember/service';
2+
3+
import AuthenticatedRoute from '../-authenticated-route';
4+
5+
export default class EmailNotificationsSettingsRoute extends AuthenticatedRoute {
6+
@service store;
7+
8+
async model() {
9+
let { ownedCrates, currentUser: user } = this.session;
10+
11+
if (!ownedCrates) {
12+
await this.session.fetchUser();
13+
({ ownedCrates } = this.session);
14+
}
15+
16+
return { user, ownedCrates };
17+
}
18+
19+
setupController(controller) {
20+
super.setupController(...arguments);
21+
22+
controller.setProperties({
23+
emailNotificationsSuccess: false,
24+
emailNotificationsError: false,
25+
});
26+
}
27+
}

app/routes/settings/index.js

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
1+
import Route from '@ember/routing/route';
12
import { inject as service } from '@ember/service';
23

3-
import AuthenticatedRoute from '../-authenticated-route';
4+
export default class SettingsRoute extends Route {
5+
@service router;
46

5-
export default class SettingsRoute extends AuthenticatedRoute {
6-
@service store;
7-
8-
async model() {
9-
let { ownedCrates, currentUser: user } = this.session;
10-
11-
if (!ownedCrates) {
12-
await this.session.fetchUser();
13-
({ ownedCrates } = this.session);
14-
}
15-
16-
let apiTokens = await this.store.findAll('api-token');
17-
18-
return { user, ownedCrates, api_tokens: apiTokens.toArray() };
19-
}
20-
21-
setupController(controller) {
22-
super.setupController(...arguments);
23-
24-
controller.setProperties({
25-
emailNotificationsSuccess: false,
26-
emailNotificationsError: false,
27-
});
7+
redirect() {
8+
this.router.replaceWith('settings.profile');
289
}
2910
}

app/routes/settings/profile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { inject as service } from '@ember/service';
2+
3+
import AuthenticatedRoute from '../-authenticated-route';
4+
5+
export default class ProfileSettingsRoute extends AuthenticatedRoute {
6+
@service session;
7+
8+
async model() {
9+
return { user: this.session.currentUser };
10+
}
11+
}

app/routes/settings/tokens.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { inject as service } from '@ember/service';
2+
3+
import AuthenticatedRoute from '../-authenticated-route';
4+
5+
export default class TokenSettingsRoute extends AuthenticatedRoute {
6+
@service store;
7+
8+
async model() {
9+
let apiTokens = await this.store.findAll('api-token');
10+
return apiTokens.toArray();
11+
}
12+
}

app/styles/settings/index.module.css renamed to app/styles/settings/email-notifications.module.css

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,5 @@
1-
.me-profile {
2-
border-bottom: 5px solid var(--gray-border);
3-
padding-bottom: 20px;
4-
margin-bottom: 20px;
5-
6-
.info { display: flex; }
7-
dl {
8-
margin: 0 0 0 30px;
9-
line-height: 150%;
10-
font-size: 110%;
11-
dt {
12-
font-weight: bold;
13-
width: 150px;
14-
text-align: right;
15-
float: left;
16-
clear: both;
17-
}
18-
dd { float: left; margin-left: 10px; }
19-
}
20-
21-
@media only screen and (max-width: 550px) {
22-
.info img { display: none; }
23-
}
24-
}
25-
26-
.me-email {
27-
border-bottom: 5px solid var(--gray-border);
28-
padding-bottom: 20px;
29-
margin-bottom: 20px;
30-
display: flex;
31-
flex-direction: column;
32-
}
33-
341
.me-email-notifications {
35-
border-bottom: 5px solid var(--gray-border);
362
padding-bottom: 20px;
37-
margin-bottom: 20px;
383
display: flex;
394
flex-direction: column;
405

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.me-profile {
2+
margin-bottom: 24px;
3+
4+
.info { display: flex; }
5+
dl {
6+
margin: 0 0 0 30px;
7+
line-height: 150%;
8+
font-size: 110%;
9+
dt {
10+
font-weight: bold;
11+
width: 150px;
12+
text-align: right;
13+
float: left;
14+
clear: both;
15+
}
16+
dd { float: left; margin-left: 10px; }
17+
}
18+
19+
@media only screen and (max-width: 550px) {
20+
.info img { display: none; }
21+
}
22+
}
23+
24+
.me-email {
25+
margin-bottom: 20px;
26+
display: flex;
27+
flex-direction: column;
28+
}

0 commit comments

Comments
 (0)