Skip to content

Commit f08d586

Browse files
committed
fix(): show private repositories on permissions tab
1 parent d865532 commit f08d586

File tree

6 files changed

+53
-8
lines changed

6 files changed

+53
-8
lines changed

src/api/db/repository.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ export function getRepositories(keyword: string, userId?: string): Promise<any[]
152152
.andWhere(function() {
153153
this.where('permissions.permission', true).orWhere('public', true);
154154
});
155-
} else {
156-
q.where('repositories.public', true);
157155
}
158156
}).fetchAll({ withRelated: [{'permissions': (query) => {
159157
if (userId) {

src/app/components/app-repositories/app-repositories.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ describe('Repositories Component', () => {
8181
expect(de.nativeElement.textContent).toContain('Repositories');
8282
});
8383

84-
it('should see two repositories', () => {
84+
it('should see three repositories', () => {
8585
fixture.detectChanges();
86-
expect(fixture.componentInstance.repositories.length).toBe(2);
86+
expect(fixture.componentInstance.repositories.length).toBe(3);
8787
});
8888

8989
it('first repository should be bterm', () => {

src/app/components/app-repository/app-repository.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ <h1 class="mr15 repository-h1">{{ repo?.full_name }}</h1>
4545
{{ repo?.default_branch }}
4646
</span>
4747
<span *ngIf="repo?.private">
48-
<i class="ion ion-ios-unlocked-outline"></i>
48+
<i class="ion ion-ios-locked-outline"></i>
4949
Private Repository
5050
</span>
5151
<span *ngIf="!repo?.private">
52-
<i class="ion ion-ios-locked-outline"></i>
52+
<i class="ion ion-ios-unlocked-outline"></i>
5353
Public Repository
5454
</span>
5555
</div>

src/app/components/app-user/app-user.component.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('User Component', () => {
9999
it('should get Repositories', () => {
100100
return apiService.getRepositories('', '1').toPromise().then(repositories => {
101101
if (repositories) {
102-
expect(repositories.length).toEqual(2);
102+
expect(repositories.length).toEqual(3);
103103
} else {
104104
Promise.reject(false);
105105
}
@@ -132,6 +132,16 @@ describe('User Component', () => {
132132
const de = fixture.debugElement.query(By.css('h1'));
133133
expect(de.nativeElement.textContent).toBe('Permissions');
134134
});
135+
136+
it('should show repositories on permission tab', () => {
137+
fixture.detectChanges();
138+
fixture.debugElement.query(By.css('[name="tab-permissions"]')).nativeElement.click();
139+
fixture.detectChanges();
140+
const de = fixture.debugElement.query(By.css('h1'));
141+
expect(de.nativeElement.textContent).toBe('Permissions');
142+
expect(fixture.componentInstance.restrictedRepositories.length).toBe(1);
143+
expect(fixture.componentInstance.repositories.length).toBe(2);
144+
});
135145
});
136146

137147
});

src/app/components/app-user/app-user.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class AppUserComponent implements OnInit {
7070
});
7171

7272
this.route.params
73-
.switchMap((params: Params) => this.api.getRepositories('', params.id))
73+
.switchMap((params: Params) => this.api.getRepositories(''))
7474
.subscribe(repositories => {
7575
this.repositories =
7676
repositories.filter(r => r.permissions.findIndex(p => p.permission) !== -1);

src/app/testing/xhr-data/repositories.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,43 @@
7373
"updated_at": 1507286468433
7474
}
7575
]
76+
},
77+
{
78+
"id": 3,
79+
"github_id": 71424198,
80+
"bitbucket_id": null,
81+
"gitlab_id": null,
82+
"gogs_id": null,
83+
"clone_url": "https://github.com/jkuri/d3-bundle.git",
84+
"html_url": "https://github.com/jkuri/d3-bundle",
85+
"default_branch": "master",
86+
"name": "d3-bundle",
87+
"full_name": "jkuri/d3-bundle",
88+
"description": null,
89+
"api_url": "https://api.github.com",
90+
"repository_provider": "github",
91+
"private": 1,
92+
"fork": 0,
93+
"user_login": "jkuri",
94+
"user_id": "1796022",
95+
"user_avatar_url": "https://avatars1.githubusercontent.com/u/1796022?v=4",
96+
"user_url": "https://api.github.com/users/jkuri",
97+
"user_html_url": "https://github.com/jkuri",
98+
"access_tokens_id": null,
99+
"public": 0,
100+
"data": null,
101+
"created_at": 1507286468355,
102+
"updated_at": 1507286468355,
103+
"permissions": [
104+
{
105+
"id": 3,
106+
"repositories_id": 3,
107+
"users_id": 1,
108+
"permission": 0,
109+
"created_at": 1507286468433,
110+
"updated_at": 1507286468433
111+
}
112+
]
76113
}
77114
]
78115
}

0 commit comments

Comments
 (0)