Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix(header): hide MyProjects btn when 0 projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Christine Yu committed Aug 28, 2015
1 parent f91a9d7 commit b74c7b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/scripts/components/header/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<span class="hidden-md hidden-sm" data-translate>Login</span>
</a>
</li>
<li class="MyProjects" data-ng-if="hc.UserService.currentUser">
<li class="MyProjects" data-ng-if="hc.UserService.currentUser && hc.UserService.hasProjects()">
<label class="MyProjects__label navbar-text">
<input type="checkbox"
data-ng-change="hc.UserService.toggleFilter()"
Expand Down
9 changes: 9 additions & 0 deletions app/scripts/components/user/user.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module ngApp.components.user.services {
currentUser: IUser;
userCanDownloadFiles(files: IFile[]): boolean;
getToken(): void;
hasProjects(): boolean;
}

class UserService implements IUserService {
Expand Down Expand Up @@ -96,6 +97,14 @@ module ngApp.components.user.services {
this.$rootScope.$broadcast("gdc-user-reset");
}

hasProjects(): boolean {
if(!this.currentUser) {
return false;
}
var projects = _.get(this.currentUser.projects, 'gdc_ids', []);
return projects.length > 0;
}

isUserProject(file: IFile): boolean {
if (!this.currentUser) {
return false;
Expand Down

0 comments on commit b74c7b9

Please sign in to comment.