Skip to content

Implement new /settings route #4309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<dd.Menu local-class="current-user-links" as |menu|>
<menu.Item><LinkTo @route="dashboard">Dashboard</LinkTo></menu.Item>
<menu.Item><LinkTo @route="me">Account Settings</LinkTo></menu.Item>
<menu.Item><LinkTo @route="settings">Account Settings</LinkTo></menu.Item>
<menu.Item><LinkTo @route="me.pending-invites">Owner Invites</LinkTo></menu.Item>
<menu.Item local-class="menu-item-with-separator">
<button
Expand Down Expand Up @@ -95,7 +95,7 @@
<menu.Item><LinkTo @route="crates">Browse All Crates</LinkTo></menu.Item>
{{#if this.session.currentUser}}
<menu.Item><LinkTo @route="dashboard">Dashboard</LinkTo></menu.Item>
<menu.Item><LinkTo @route="me" data-test-me-link>Account Settings</LinkTo></menu.Item>
<menu.Item><LinkTo @route="settings" data-test-me-link>Account Settings</LinkTo></menu.Item>
<menu.Item><LinkTo @route="me.pending-invites">Owner Invites</LinkTo></menu.Item>
<menu.Item local-class="menu-item-with-separator">
<button
Expand Down
11 changes: 11 additions & 0 deletions app/components/settings-page.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div local-class="page" ...attributes>
<SideMenu as |menu|>
<menu.Item @link={{link "settings.profile"}}>Profile</menu.Item>
<menu.Item @link={{link "settings.email-notifications"}}>Email Notifications</menu.Item>
<menu.Item @link={{link "settings.tokens"}}>API Tokens</menu.Item>
</SideMenu>

<div local-class="content">
{{yield}}
</div>
</div>
16 changes: 16 additions & 0 deletions app/components/settings-page.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.page {
display: grid;
gap: 16px;

@media only screen and (min-width: 891px) {
grid-template:
"menu content" auto /
200px auto;
}
}

.content {
h2:first-child {
margin-top: 4px;
}
}
3 changes: 3 additions & 0 deletions app/components/side-menu.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ul role="list" local-class="list" ...attributes>
{{yield (hash Item=(component "side-menu/item"))}}
</ul>
9 changes: 9 additions & 0 deletions app/components/side-menu.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.list {
list-style: none;
margin: 0;
padding: 0;

> * + * {
margin-top: 8px;
}
}
3 changes: 3 additions & 0 deletions app/components/side-menu/item.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li>
<a href={{@link.url}} local-class="link {{if @link.isActive "active"}}" {{on "click" @link.transitionTo}}>{{yield}}</a>
</li>
22 changes: 22 additions & 0 deletions app/components/side-menu/item.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.link {
display: block;
padding: 10px 12px;
border-radius: 6px;
color: var(--main-color-light);
transition: all 300ms ease-in;

&:hover {
background-color: var(--main-bg-dark);
color: var(--main-color);
transition: none;
}
}

.active {
background-color: var(--main-bg-dark);
color: var(--main-color);

&:hover {
background-color: #e5e1cd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { alias } from 'macro-decorators';

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

export default class MeIndexController extends Controller {
export default class EmailNotificationsSettingsController extends Controller {
isResetting = false;

@alias('model.ownedCrates') ownedCrates;
Expand Down
5 changes: 5 additions & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Router.map(function () {
this.route('following');
this.route('pending-invites');
});
this.route('settings', function () {
this.route('email-notifications');
this.route('profile');
this.route('tokens');
});
this.route('user', { path: '/users/:user_id' });
this.route('install');
this.route('search');
Expand Down
29 changes: 5 additions & 24 deletions app/routes/me/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

import AuthenticatedRoute from '../-authenticated-route';
export default class MeIndexRoute extends Route {
@service router;

export default class MeIndexRoute extends AuthenticatedRoute {
@service store;

async model() {
let { ownedCrates, currentUser: user } = this.session;

if (!ownedCrates) {
await this.session.fetchUser();
({ ownedCrates } = this.session);
}

let apiTokens = await this.store.findAll('api-token');

return { user, ownedCrates, api_tokens: apiTokens.toArray() };
}

setupController(controller) {
super.setupController(...arguments);

controller.setProperties({
emailNotificationsSuccess: false,
emailNotificationsError: false,
});
redirect() {
this.router.replaceWith('settings');
}
}
27 changes: 27 additions & 0 deletions app/routes/settings/email-notifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { inject as service } from '@ember/service';

import AuthenticatedRoute from '../-authenticated-route';

export default class EmailNotificationsSettingsRoute extends AuthenticatedRoute {
@service store;

async model() {
let { ownedCrates, currentUser: user } = this.session;

if (!ownedCrates) {
await this.session.fetchUser();
({ ownedCrates } = this.session);
}

return { user, ownedCrates };
}

setupController(controller) {
super.setupController(...arguments);

controller.setProperties({
emailNotificationsSuccess: false,
emailNotificationsError: false,
});
}
}
10 changes: 10 additions & 0 deletions app/routes/settings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class SettingsRoute extends Route {
@service router;

redirect() {
this.router.replaceWith('settings.profile');
}
}
11 changes: 11 additions & 0 deletions app/routes/settings/profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { inject as service } from '@ember/service';

import AuthenticatedRoute from '../-authenticated-route';

export default class ProfileSettingsRoute extends AuthenticatedRoute {
@service session;

async model() {
return { user: this.session.currentUser };
}
}
12 changes: 12 additions & 0 deletions app/routes/settings/tokens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { inject as service } from '@ember/service';

import AuthenticatedRoute from '../-authenticated-route';

export default class TokenSettingsRoute extends AuthenticatedRoute {
@service store;

async model() {
let apiTokens = await this.store.findAll('api-token');
return apiTokens.toArray();
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
.me-profile {
border-bottom: 5px solid var(--gray-border);
padding-bottom: 20px;
margin-bottom: 20px;

.info { display: flex; }
dl {
margin: 0 0 0 30px;
line-height: 150%;
font-size: 110%;
dt {
font-weight: bold;
width: 150px;
text-align: right;
float: left;
clear: both;
}
dd { float: left; margin-left: 10px; }
}

@media only screen and (max-width: 550px) {
.info img { display: none; }
}
}

.me-email {
border-bottom: 5px solid var(--gray-border);
padding-bottom: 20px;
margin-bottom: 20px;
display: flex;
flex-direction: column;
}

.me-email-notifications {
border-bottom: 5px solid var(--gray-border);
padding-bottom: 20px;
margin-bottom: 20px;
display: flex;
flex-direction: column;

Expand Down
28 changes: 28 additions & 0 deletions app/styles/settings/profile.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.me-profile {
margin-bottom: 24px;

.info { display: flex; }
dl {
margin: 0 0 0 30px;
line-height: 150%;
font-size: 110%;
dt {
font-weight: bold;
width: 150px;
text-align: right;
float: left;
clear: both;
}
dd { float: left; margin-left: 10px; }
}

@media only screen and (max-width: 550px) {
.info img { display: none; }
}
}

.me-email {
margin-bottom: 20px;
display: flex;
flex-direction: column;
}
Empty file.
81 changes: 0 additions & 81 deletions app/templates/me/index.hbs

This file was deleted.

Loading