Skip to content

Commit 3d2d918

Browse files
committed
wip: PRs
1 parent 7f48ae2 commit 3d2d918

10 files changed

Lines changed: 52 additions & 33 deletions

File tree

angular-ngrx-scss/src/app/file-viewer/file-explorer/file-explorer.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
<div class="container grid grid-cols-12 subpage">
33
<section class="col-span-9 col-sm-span-12">
44
<app-file-explorer-nav
5-
[owner]="owner"
6-
[name]="repoName"
5+
[owner]="repo.ownerName"
6+
[name]="repo.repoName"
77
[branch]="repo.activeBranch"
8-
[path]="path"
9-
[showCrumbs]="!!path"
8+
[path]="repo.path"
9+
[showCrumbs]="!!repo.path"
1010
></app-file-explorer-nav>
1111

1212
<app-file-explorer-container
1313
[repoPage]="repo.tree"
1414
[branch]="repo.activeBranch"
15-
[owner]="owner"
16-
[name]="repoName"
15+
[owner]="repo.ownerName"
16+
[name]="repo.repoName"
1717
></app-file-explorer-container>
1818
</section>
1919

angular-ngrx-scss/src/app/file-viewer/file-explorer/file-explorer.component.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { map, takeWhile, tap } from 'rxjs';
1313
templateUrl: './file-explorer.component.html',
1414
styleUrls: ['./file-explorer.component.scss'],
1515
})
16-
export class FileExplorerComponent implements OnInit, OnDestroy {
16+
export class FileExplorerComponent implements OnDestroy {
1717
owner = '';
1818
repoName = '';
1919
path = '';
@@ -38,28 +38,6 @@ export class FileExplorerComponent implements OnInit, OnDestroy {
3838

3939
constructor(private route: ActivatedRoute, private store: Store) {}
4040

41-
ngOnInit() {
42-
this.route.paramMap
43-
.pipe(
44-
takeWhile(() => this.componentActive),
45-
tap((params) => {
46-
this.owner = params.get('owner') as string;
47-
this.repoName = params.get('repo') as string;
48-
this.branch = params.get('branch') as string;
49-
this.path = params.get('path') as string;
50-
this.store.dispatch(
51-
fetchRepository({
52-
owner: this.owner,
53-
repoName: this.repoName,
54-
path: this.path,
55-
branch: this.branch,
56-
}),
57-
);
58-
}),
59-
)
60-
.subscribe();
61-
}
62-
6341
ngOnDestroy(): void {
6442
this.componentActive = false;
6543
}

angular-ngrx-scss/src/app/pull-requests/components/pull-requests-header/pull-requests-header.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
name="Label"
2323
description="Select label"
2424
[isRepo]="true"
25+
[items]="(labels$ | async) ?? []"
2526
></app-filter-dropdown>
2627
<app-filter-dropdown
2728
name="Sort"

angular-ngrx-scss/src/app/repository/components/repo-header/repo-navigation/repo-navigation.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</span>
2525
</li>
2626
<li
27-
[routerLink]="[basePath, 'pull-requests']"
27+
[routerLink]="[basePath, 'pulls']"
2828
routerLinkActive="tab--active"
2929
class="tab tab--inactive"
3030
#prLink="routerLinkActive"
Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,44 @@
1-
import { Component } from '@angular/core';
1+
import { Component, OnDestroy, OnInit } from '@angular/core';
2+
import { Subject, takeUntil, takeWhile, tap } from 'rxjs';
3+
import { fetchRepository } from '../../../state/repository';
4+
import { ActivatedRoute } from '@angular/router';
5+
import { Store } from '@ngrx/store';
26

37
@Component({
48
selector: 'app-repository-details',
59
templateUrl: './repository-details.component.html',
610
styleUrls: ['./repository-details.component.scss'],
711
})
8-
export class RepositoryDetailsComponent {}
12+
export class RepositoryDetailsComponent implements OnInit, OnDestroy {
13+
private destroyed$ = new Subject<void>();
14+
15+
constructor(private route: ActivatedRoute, private store: Store) {}
16+
17+
ngOnInit() {
18+
this.route.paramMap
19+
.pipe(
20+
takeUntil(this.destroyed$),
21+
tap((params) => {
22+
const owner = params.get('owner') as string;
23+
const repoName = params.get('repo') as string;
24+
const branch = params.get('branch') as string;
25+
const path = params.get('path') as string;
26+
27+
this.store.dispatch(
28+
fetchRepository({
29+
owner: owner,
30+
repoName: repoName,
31+
path: path,
32+
branch: branch,
33+
}),
34+
);
35+
}),
36+
)
37+
.subscribe();
38+
}
39+
40+
ngOnDestroy() {
41+
this.destroyed$.next();
42+
this.destroyed$.complete();
43+
}
44+
}

angular-ngrx-scss/src/app/repository/repository-routing.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const routes: Routes = [
2525
import('../issues/issues.module').then((m) => m.IssuesModule),
2626
},
2727
{
28-
path: 'pull-requests',
28+
path: 'pulls',
2929
loadChildren: () =>
3030
import('../pull-requests/pull-requests.module').then(
3131
(m) => m.PullRequestsModule,

angular-ngrx-scss/src/app/repository/services/repository.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
IssueLabel,
99
Milestone,
1010
PullRequestAPIResponse,
11+
PullRequestLabel,
1112
ReadmeApiResponse,
1213
RepoApiResponse,
1314
RepoContentsApiResponse,

angular-ngrx-scss/src/app/state/repository/repository.effects.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class RepositoryEffects {
6666
).pipe(
6767
map(([info, prList, contents, readme, milestones, labels]) => {
6868
const allData: RepositoryState = {
69+
path: path ?? '',
6970
description: info.description,
7071
forkCount: info.forks_count,
7172
issueCount: info.open_issues_count,

angular-ngrx-scss/src/app/state/repository/repository.reducer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const initialRepositoryState: RepositoryState = {
77
forkCount: 0,
88
issueCount: 0,
99
ownerName: '',
10+
path: '',
1011
prCount: 0,
1112
readme: '',
1213
repoName: '',

angular-ngrx-scss/src/app/state/repository/repository.state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Issue } from 'src/app/repository/services/repository.interfaces';
22
import { UserApiResponse } from '../user';
33

44
export interface RepositoryState {
5+
path: string;
56
description: string;
67
forkCount: number;
78
issueCount: number;

0 commit comments

Comments
 (0)