Skip to content

Commit a33aa20

Browse files
authored
Merge pull request #1589 from code-corps/add-project-menu-switching
Add project menu switching
2 parents deb3fee + d67f5bc commit a33aa20

File tree

20 files changed

+432
-6
lines changed

20 files changed

+432
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Component from '@ember/component';
2+
3+
export default Component.extend({
4+
classNames: ['project-switcher-menu']
5+
});

app/components/project-switcher.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Component from '@ember/component';
2+
import { set } from '@ember/object';
3+
4+
export default Component.extend({
5+
classNames: ['project-switcher', 'dropdown'],
6+
classNameBindings: ['hidden:menu-hidden:menu-visible'],
7+
hidden: true,
8+
9+
actions: {
10+
hide() {
11+
document.body.setAttribute('style', null);
12+
set(this, 'hidden', true);
13+
},
14+
15+
show() {
16+
document.body.setAttribute('style', 'overflow: hidden;');
17+
set(this, 'hidden', false);
18+
}
19+
}
20+
});

app/models/user.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default Model.extend({
2929

3030
categories: hasMany('category', { async: true }),
3131
githubAppInstallations: hasMany('github-app-installation', { async: true }),
32+
organizations: hasMany('organization', { async: true }),
3233
projectUsers: hasMany('project-user', { async: true }),
3334
stripeConnectSubscriptions: hasMany('stripe-connect-subscription', { async: true }),
3435
stripePlatformCard: belongsTo('stripe-platform-card', { async: true }),

app/styles/app.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@
149149
@import "components/project-join-modal";
150150
@import "components/project-list";
151151
@import "components/project-long-description";
152-
@import "components/project-users";
153152
@import "components/project-menu";
153+
@import "components/project-switcher-menu";
154+
@import "components/project-users";
154155

155156
//
156157
// COMPONENTS - PROJECT CARDS
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
.sheet {
2+
background: none;
3+
border-radius: none;
4+
box-shadow: none;
5+
padding: 0;
6+
}
7+
8+
.project-menu {
9+
animation: slide 0.25s forwards;
10+
position: fixed;
11+
top: 0;
12+
right: -1000px;
13+
bottom: 0;
14+
left: 0;
15+
z-index: 999999;
16+
right: -1000px;
17+
}
18+
19+
.project-menu-wrapper {
20+
background: white;
21+
position: absolute;
22+
top: 0; right: 0; bottom: 0;
23+
}
24+
25+
.project-menu-content {
26+
height: 100%;
27+
overflow: scroll;
28+
width: 280px;
29+
}
30+
31+
.project-switcher-menu {
32+
padding: 5px 0;
33+
text-align: left;
34+
35+
ul {
36+
border-bottom: 1px solid $border-gray;
37+
padding-bottom: 5px;
38+
margin-bottom: 3px;
39+
40+
&:last-child {
41+
border-bottom: none;
42+
padding-bottom: 0;
43+
margin-bottom: 0;
44+
}
45+
}
46+
47+
li {
48+
display: block;
49+
float: none;
50+
padding: 1px 5px;
51+
}
52+
53+
a {
54+
align-items: center;
55+
border: none;
56+
color: $gray;
57+
display: flex;
58+
font-weight: 500;
59+
padding: 2px;
60+
61+
&:hover, &.active {
62+
background: $blue--background;
63+
color: $blue;
64+
65+
.project-switcher-menu__new__icon {
66+
border-color: $blue;
67+
color: $blue;
68+
}
69+
}
70+
}
71+
72+
img {
73+
margin-right: 5px;
74+
}
75+
76+
&__new {
77+
&__icon {
78+
align-items: center;
79+
border: 1px dashed $gray--lighter;
80+
border-radius: 2px;
81+
color: $gray--lighter;
82+
display: inline-flex;
83+
height: 25px;
84+
justify-content: center;
85+
margin-right: 5px;
86+
width: 25px;
87+
}
88+
}
89+
}
90+
91+
li.project-switcher-menu__option--title {
92+
color: $text--lighter;
93+
font-size: $body-font-size-small;
94+
font-weight: 600;
95+
padding: 5px;
96+
}
97+
98+
@keyframes slide {
99+
100% { right: 0; }
100+
}

app/styles/components/user-menu.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525

2626
.user-menu a {
27-
padding: 5px 0 2px 0;
27+
padding: 5px 10px 2px 10px;
2828
}
2929

3030
.user-menu__avatar {

app/styles/layout/_header.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
&.header-navigation__icon-link {
8181
color: $gray;
8282
font-size: 24px;
83-
margin: 0 5px;
8483
padding: 4px 10px;
8584
}
8685

app/templates/application.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
{{svg/sprite-map}}
66

7+
<div id="project-menu"></div>
8+
79
{{! do we have to wrap the whole app with #drag-zone?
810
isn't this here mainly for updating a user's image? }}
911
{{#drag-zone}}

app/templates/components/navigation-menu.hbs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,19 @@
2626
{{#if session.isAuthenticated}}
2727
<nav class="header-navigation--right">
2828
<ul class="header-navigation__options">
29+
{{#if currentUser.user.organizations}}
30+
<li>
31+
{{project-switcher
32+
user=currentUser.user
33+
}}
34+
</li>
35+
{{/if}}
2936
<li>{{#link-to "conversations" data-test-conversations-link class="header-navigation__icon-link"}}{{fa-icon "comments"}}{{/link-to}}</li>
3037
</ul>
31-
{{user-menu user=currentUser.user class="header-navigation__options" }}
38+
{{user-menu
39+
user=currentUser.user
40+
class="header-navigation__options"
41+
}}
3242
</nav>
3343
{{else}}
3444
<nav class="header-navigation--right">
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{#modal-dialog
2+
containerClassNames="sheet"
3+
targetAttachment="none"
4+
translucentOverlay=true
5+
}}
6+
<div data-test-project-menu class="project-menu">
7+
<div class="project-menu-wrapper">
8+
<div class="project-menu-content">
9+
<div class="project-switcher-menu">
10+
{{#each user.organizations as |organization|}}
11+
<ul>
12+
<li data-test-organization class="project-switcher-menu__option--title">{{organization.name}}</li>
13+
{{#each organization.projects as |project|}}
14+
{{#unless project.isNew}}
15+
<li data-test-project>
16+
{{#link-to 'project' project.organization.slug project.slug}}
17+
<img data-test-icon class="icon icon--tiny" width="25" height="25" src="{{project.iconThumbUrl}}" /> {{project.title}}
18+
{{/link-to}}
19+
</li>
20+
{{/unless}}
21+
{{/each}}
22+
{{#if (can 'manage organization' organization)}}
23+
<li data-test-new-project class="project-switcher-menu__new">
24+
{{#link-to 'projects.new' organization.slug}}<span class="project-switcher-menu__new__icon">{{fa-icon "plus"}}</span> New project{{/link-to}}
25+
</li>
26+
{{/if}}
27+
</ul>
28+
{{/each}}
29+
</div>
30+
</div>
31+
</div>
32+
</div>
33+
{{/modal-dialog}}

0 commit comments

Comments
 (0)