Skip to content

Commit c9cad29

Browse files
071824.03/revision links (#8663)
* Handle Opening on Revision Pages * Handle Revision SideBar Closing
1 parent 8db91de commit c9cad29

File tree

5 files changed

+52
-13
lines changed

5 files changed

+52
-13
lines changed

src/dotnet/APIView/ClientSPA/src/app/_components/review-page/review-page.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
</div>
6767
</div>
6868
</div>
69-
<p-sidebar [(visible)]="revisionSidePanel!" position="right" [modal]="true" styleClass="revisions-sidebar">
70-
<app-revisions-list [review]="review"></app-revisions-list>
69+
<p-sidebar [(visible)]="revisionSideBarVisible" position="right" [modal]="true" styleClass="revisions-sidebar">
70+
<app-revisions-list
71+
[review]="review"
72+
[revisionSideBarVisible]="revisionSideBarVisible"></app-revisions-list>
7173
</p-sidebar>
7274
<app-footer></app-footer>

src/dotnet/APIView/ClientSPA/src/app/_components/review-page/review-page.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class ReviewPageComponent implements OnInit {
3333
apiRevisions: APIRevision[] = [];
3434
activeAPIRevision : APIRevision | undefined = undefined;
3535
diffAPIRevision : APIRevision | undefined = undefined;
36-
revisionSidePanel : boolean | undefined = undefined;
36+
revisionSideBarVisible : boolean = false;
3737
reviewPageNavigation : TreeNode[] = [];
3838
language: string | undefined;
3939
languageSafeName: string | undefined;
@@ -103,7 +103,7 @@ export class ReviewPageComponent implements OnInit {
103103
this.sideMenu = [
104104
{
105105
icon: 'bi bi-clock-history',
106-
command: () => { this.revisionSidePanel = !this.revisionSidePanel; }
106+
command: () => { this.revisionSideBarVisible = !this.revisionSideBarVisible; }
107107
}
108108
];
109109
}
@@ -408,7 +408,7 @@ export class ReviewPageComponent implements OnInit {
408408
break;
409409
}
410410
}
411-
}
411+
}
412412

413413
ngOnDestroy() {
414414
this.workerService.terminateWorker();

src/dotnet/APIView/ClientSPA/src/app/_components/revisions-list/revisions-list.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { environment } from 'src/environments/environment';
2121
})
2222
export class RevisionsListComponent implements OnInit, OnChanges {
2323
@Input() review : Review | undefined = undefined;
24+
@Input() revisionSideBarVisible : boolean = false;
2425

2526
@ViewChild("revisionCreationFileUpload") revisionCreationFileUpload!: FileUpload;
2627

@@ -107,6 +108,11 @@ export class RevisionsListComponent implements OnInit, OnChanges {
107108
this.showSelectionActions = false;
108109
this.showDiffButton = false;
109110
}
111+
112+
if (changes['revisionSideBarVisible'] && changes['revisionSideBarVisible'].currentValue == false) {
113+
this.createRevisionSidebarVisible = false;
114+
this.optionsSidebarVisible = false;
115+
}
110116
}
111117

112118
/**
@@ -231,14 +237,14 @@ export class RevisionsListComponent implements OnInit, OnChanges {
231237
viewDiffOfSelectedAPIRevisions() {
232238
if (this.selectedRevisions.length == 2)
233239
{
234-
this.apiRevisionsService.openDiffOfAPIRevisions(this.review!.id, this.selectedRevisions[0].id, this.selectedRevisions[1].id, this.router.url);
240+
this.apiRevisionsService.openDiffOfAPIRevisions(this.selectedRevisions[0], this.selectedRevisions[1], this.router.url);
235241
}
236242
}
237243

238244
viewRevision(apiRevision: APIRevision) {
239245
if (!this.showDeletedAPIRevisions)
240246
{
241-
this.apiRevisionsService.openAPIRevisionPage(apiRevision.reviewId, apiRevision.id, this.router.url);
247+
this.apiRevisionsService.openAPIRevisionPage(apiRevision, this.router.url);
242248
}
243249
}
244250

@@ -471,7 +477,7 @@ export class RevisionsListComponent implements OnInit, OnChanges {
471477
this.createRevisionSidebarVisible = false;
472478
this.creatingRevision = false;
473479
this.crButtonText = "Create Review";
474-
this.apiRevisionsService.openAPIRevisionPage(response.reviewId, response.id, this.router.url);
480+
this.apiRevisionsService.openAPIRevisionPage(response, this.router.url);
475481
}
476482
},
477483
error: (error: any) => {

src/dotnet/APIView/ClientSPA/src/app/_models/revision.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,30 @@ export enum CodePanelRowDatatype {
1515
CommentThread = "commentThread"
1616
}
1717

18+
export enum ParserStyle {
19+
Flat = "Flat",
20+
Tree = "Tree"
21+
}
22+
23+
export interface APICodeFileModel {
24+
fileId: string;
25+
name: string;
26+
versionString: string;
27+
parserStyle: string;
28+
languageVariant: string;
29+
hasOriginal: boolean;
30+
creationDate: Date;
31+
runAnalysis: boolean;
32+
packageName: string;
33+
fileName: string;
34+
packageVersion: string;
35+
crossLanguagePackageId: string;
36+
}
37+
1838
export interface APIRevision {
1939
id: string
2040
reviewId: string
41+
files: APICodeFileModel[];
2142
packageName: string
2243
language: string
2344
apiRevisionType: string

src/dotnet/APIView/ClientSPA/src/app/_services/revisions/revisions.service.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Observable, map } from 'rxjs';
44

55

66
import { PaginatedResult } from 'src/app/_models/pagination';
7-
import { APIRevision } from 'src/app/_models/revision';
7+
import { APIRevision, ParserStyle } from 'src/app/_models/revision';
88
import { ConfigService } from '../config/config.service';
99

1010

@@ -126,14 +126,24 @@ export class RevisionsService {
126126
});
127127
}
128128

129-
openDiffOfAPIRevisions(reviewId: string, activeAPIRevisionId: string, diffAPIRevisionsId: string, currentRoute: string) {
129+
openDiffOfAPIRevisions(activeAPIRevision: APIRevision, diffAPIRevision: APIRevision, currentRoute: string) {
130130
const target = (currentRoute.includes("review")) ? '_self' : '_blank';
131-
window.open(this.configService.webAppUrl + `Assemblies/Review/${reviewId}?revisionId=${activeAPIRevisionId}&diffOnly=False&doc=False&diffRevisionId=${diffAPIRevisionsId}`, target);
131+
132+
if (activeAPIRevision.files[0].parserStyle === "tree") {
133+
window.open(`/review/${activeAPIRevision.reviewId}?activeApiRevisionId=${activeAPIRevision.id}&diffApiRevisionId=${diffAPIRevision.id}`, target);
134+
} else {
135+
window.open(this.configService.webAppUrl + `Assemblies/Review/${activeAPIRevision.reviewId}?revisionId=${activeAPIRevision.id}&diffOnly=False&doc=False&diffRevisionId=${diffAPIRevision.id}`, target);
136+
}
132137
}
133138

134-
openAPIRevisionPage(reviewId: string, activeAPIRevisionId: string, currentRoute: string) {
139+
openAPIRevisionPage(apiRevision: APIRevision, currentRoute: string) {
135140
const target = (currentRoute.includes("review")) ? '_self' : '_blank';
136-
window.open(this.configService.webAppUrl + `Assemblies/Review/${reviewId}?revisionId=${activeAPIRevisionId}`, target);
141+
142+
if (apiRevision.files[0].parserStyle === "tree") {
143+
window.open(`/review/${apiRevision.reviewId}?activeApiRevisionId=${apiRevision.id}`, target);
144+
} else {
145+
window.open(this.configService.webAppUrl + `Assemblies/Review/${apiRevision.reviewId}?revisionId=${apiRevision.id}`, target);
146+
}
137147
}
138148

139149
updateSelectedReviewers(reviewId: string, apiRevisionId: string, reviewers: Set<string>): Observable<APIRevision> {

0 commit comments

Comments
 (0)