Skip to content

Commit 889c86d

Browse files
committed
Auto merge of #4309 - Turbo87:settings, r=locks
Implement new `/settings` route This is basically similar to the `/me` route, but split into multiple subroutes to make the settings more scaleable. <img width="1001" alt="Bildschirmfoto 2021-12-21 um 13 54 58" src="https://user-images.githubusercontent.com/141300/146974376-bfd3e759-5843-4940-b784-0966e3ded9fd.png"> <img width="1005" alt="Bildschirmfoto 2021-12-21 um 13 55 14" src="https://user-images.githubusercontent.com/141300/146974382-5abfe305-fe1a-424e-95f7-fbf971dedb13.png">
2 parents b06e521 + 36cd32b commit 889c86d

24 files changed

+278
-163
lines changed

app/components/header.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
<dd.Menu local-class="current-user-links" as |menu|>
5252
<menu.Item><LinkTo @route="dashboard">Dashboard</LinkTo></menu.Item>
53-
<menu.Item><LinkTo @route="me">Account Settings</LinkTo></menu.Item>
53+
<menu.Item><LinkTo @route="settings">Account Settings</LinkTo></menu.Item>
5454
<menu.Item><LinkTo @route="me.pending-invites">Owner Invites</LinkTo></menu.Item>
5555
<menu.Item local-class="menu-item-with-separator">
5656
<button
@@ -95,7 +95,7 @@
9595
<menu.Item><LinkTo @route="crates">Browse All Crates</LinkTo></menu.Item>
9696
{{#if this.session.currentUser}}
9797
<menu.Item><LinkTo @route="dashboard">Dashboard</LinkTo></menu.Item>
98-
<menu.Item><LinkTo @route="me" data-test-me-link>Account Settings</LinkTo></menu.Item>
98+
<menu.Item><LinkTo @route="settings" data-test-me-link>Account Settings</LinkTo></menu.Item>
9999
<menu.Item><LinkTo @route="me.pending-invites">Owner Invites</LinkTo></menu.Item>
100100
<menu.Item local-class="menu-item-with-separator">
101101
<button

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/components/side-menu.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<ul role="list" local-class="list" ...attributes>
2+
{{yield (hash Item=(component "side-menu/item"))}}
3+
</ul>

app/components/side-menu.module.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.list {
2+
list-style: none;
3+
margin: 0;
4+
padding: 0;
5+
6+
> * + * {
7+
margin-top: 8px;
8+
}
9+
}

app/components/side-menu/item.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<li>
2+
<a href={{@link.url}} local-class="link {{if @link.isActive "active"}}" {{on "click" @link.transitionTo}}>{{yield}}</a>
3+
</li>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.link {
2+
display: block;
3+
padding: 10px 12px;
4+
border-radius: 6px;
5+
color: var(--main-color-light);
6+
transition: all 300ms ease-in;
7+
8+
&:hover {
9+
background-color: var(--main-bg-dark);
10+
color: var(--main-color);
11+
transition: none;
12+
}
13+
}
14+
15+
.active {
16+
background-color: var(--main-bg-dark);
17+
color: var(--main-color);
18+
19+
&:hover {
20+
background-color: #e5e1cd;
21+
}
22+
}

app/controllers/me/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 MeIndexController 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ Router.map(function () {
3131
this.route('following');
3232
this.route('pending-invites');
3333
});
34+
this.route('settings', function () {
35+
this.route('email-notifications');
36+
this.route('profile');
37+
this.route('tokens');
38+
});
3439
this.route('user', { path: '/users/:user_id' });
3540
this.route('install');
3641
this.route('search');

app/routes/me/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 MeIndexRoute extends Route {
5+
@service router;
46

5-
export default class MeIndexRoute 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');
289
}
2910
}
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
4+
export default class SettingsRoute extends Route {
5+
@service router;
6+
7+
redirect() {
8+
this.router.replaceWith('settings.profile');
9+
}
10+
}

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/me/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+
}

app/styles/settings/tokens.module.css

Whitespace-only changes.

app/templates/me/index.hbs

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)