Skip to content

Commit 771f330

Browse files
helen229Copilot
andauthored
Hide Request Review button if no related APIs (#12745)
* hide the request button if no associated prs Updated namespace review state logic to include additional conditions for approval and associated API revisions. * fix format * Update src/dotnet/APIView/ClientSPA/src/app/_components/review-page-options/review-page-options.component.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 42c3f48 commit 771f330

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
181181
this.isCopilotReviewSupported = this.isCopilotReviewSupportedForPackage();
182182
this.setAPIRevisionApprovalStates();
183183
this.setPullRequestsInfo();
184+
this.setNamespaceReviewStates();
184185
if (this.activeAPIRevision?.copilotReviewInProgress) {
185186
this.aiReviewGenerationState = 'InProgress';
186187
this.generateAIReviewButtonText = 'Generating review...';
@@ -197,7 +198,6 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
197198
if (changes['review'] && changes['review'].currentValue != undefined) {
198199
this.setSubscribeSwitch();
199200
this.setReviewApprovalStatus();
200-
this.setNamespaceReviewStates();
201201
this.updateDiffStyle();
202202

203203
// Reset loading state when review data is updated (indicating the request completed)
@@ -421,9 +421,12 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
421421
}
422422

423423
setNamespaceReviewStates() {
424-
// Only show namespace review request for TypeSpec language AND if feature is enabled
425-
this.canRequestNamespaceReview = this.review?.language === 'TypeSpec' && this.namespaceReviewEnabled;
426-
console.log("Namespace review request can be made:", this.namespaceReviewEnabled);
424+
// Show namespace review section for TypeSpec language when feature is enabled
425+
// and there are associated API revisions (SDK language reviews)
426+
// Display different states: approved, requested, or available to request
427+
this.canRequestNamespaceReview = this.review?.language === 'TypeSpec' &&
428+
this.namespaceReviewEnabled &&
429+
this.pullRequestsOfAssociatedAPIRevisions.length > 0;
427430
// Always keep the button available for requesting namespace review
428431
this.isNamespaceReviewRequested = false;
429432

@@ -445,11 +448,15 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
445448

446449
this.pullRequestService.getPullRequestsOfAssociatedAPIRevisions(this.activeAPIRevision.reviewId, this.activeAPIRevision.id).pipe(take(1)).subscribe({
447450
next: (response: PullRequestModel[]) => {
451+
// Clear the array first to avoid duplicates
452+
this.pullRequestsOfAssociatedAPIRevisions = [];
448453
for (const pr of response) {
449454
if (pr.reviewId != this.activeAPIRevision?.reviewId) {
450455
this.pullRequestsOfAssociatedAPIRevisions.push(pr);
451456
}
452457
}
458+
// Re-evaluate namespace review states after associated reviews are loaded
459+
this.setNamespaceReviewStates();
453460
}
454461
});
455462
}
@@ -704,7 +711,7 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
704711
const isJavaScript = this.review.language == "JavaScript";
705712

706713
const isTypeSpec = this.review.language === "TypeSpec";
707-
714+
708715
return !(isAzureRestPackage && isJavaScript) && !isTypeSpec;
709716
}
710717
}

0 commit comments

Comments
 (0)