Skip to content

Commit a5e9765

Browse files
Copilottjprescott
andauthored
Remove "Mark as Reviewed" feature from APIView (#13229)
* Initial plan * Remove Mark as Reviewed/Viewed feature from APIView Co-authored-by: tjprescott <5723682+tjprescott@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tjprescott <5723682+tjprescott@users.noreply.github.com>
1 parent 41d147f commit a5e9765

14 files changed

Lines changed: 3 additions & 127 deletions

File tree

src/dotnet/APIView/APIViewUnitTests/APIRevisionsControllerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ private static APIRevisionListItemModel CreateMockAPIRevision(
289289
Files = [new APICodeFileModel { FileId = "1" }],
290290
ChangeHistory = [],
291291
Approvers = [],
292-
ViewedBy = [],
293292
AssignedReviewers = [],
294293
HeadingsOfSectionsWithDiff = new Dictionary<string, HashSet<int>>()
295294
};

src/dotnet/APIView/APIViewUnitTests/CommentsTokenAuthControllerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ private static APIRevisionListItemModel CreateMockAPIRevision(string id)
100100
Files = [new APICodeFileModel { FileId = "file1" }],
101101
ChangeHistory = [],
102102
Approvers = [],
103-
ViewedBy = [],
104103
AssignedReviewers = [],
105104
HeadingsOfSectionsWithDiff = new Dictionary<string, HashSet<int>>()
106105
};

src/dotnet/APIView/APIViewWeb/Client/src/pages/review.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,6 @@ $(() => {
236236
$("#reviewSubscribeSwitch").on('change', function () {
237237
$("#reviewSubscribeForm").submit();
238238
});
239-
// Toggle Viewed Switch
240-
$("#reviewViewedSwitch").on('change', function () {
241-
$("#reviewViewedForm").submit();
242-
});
243239
// Toggle Close Switch
244240
$("#reviewCloseSwitch").on('change', function () {
245241
$("#reviewCloseForm").submit();

src/dotnet/APIView/APIViewWeb/LeanControllers/APIRevisionsController.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -155,31 +155,6 @@ public async Task RestoreAPIRevisionsAsync([FromBody] APIRevisionSoftDeleteParam
155155
}
156156
}
157157

158-
/// <summary>
159-
/// Endpoint used by Client SPA toggling ViewdBy property
160-
/// </summary>
161-
/// <param name="apiRevisionId"></param>
162-
/// <param name="state"></param> true = viewed, false = not viewed
163-
/// <returns></returns>
164-
[HttpPost("{apiRevisionId}/toggleViewedBy", Name = "ToggleViewedBy")]
165-
public async Task<ActionResult<APIRevisionListItemModel>> ToggleViewedByAsync(string apiRevisionId, [FromQuery] bool state)
166-
{
167-
string userName = User.GetGitHubLogin();
168-
var apiRevision = await _apiRevisionsManager.GetAPIRevisionAsync(apiRevisionId);
169-
170-
if (state)
171-
{
172-
apiRevision.ViewedBy.Add(userName);
173-
}
174-
else
175-
{
176-
apiRevision.ViewedBy.Remove(userName);
177-
}
178-
179-
await _apiRevisionsManager.UpdateAPIRevisionAsync(apiRevision);
180-
return new LeanJsonResult(apiRevision, StatusCodes.Status200OK);
181-
}
182-
183158
/// <summary>
184159
/// Endpoint used by Client SPA for Toggling APIRevision Approval
185160
/// </summary>

src/dotnet/APIView/APIViewWeb/LeanModels/ReviewListModels.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ public string PackageVersion
156156
public bool IsDeleted { get; set; }
157157
public bool IsReleased { get; set; }
158158
public DateTime ReleasedOn { get; set; }
159-
public HashSet<string> ViewedBy { get; set; } = new HashSet<string>();
160159
}
161160

162161

src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -487,24 +487,7 @@
487487
}
488488
<ul class="list-group collapse mb-3@(apiRevisionOptionsCollapseState)" id="apiRevisionOptionsCollapse">
489489
<li class="list-group-item">
490-
<div class="form-check form-switch">
491-
<form asp-resource="@Model.ReviewContent.ActiveAPIRevision" class="form-inline" id="reviewViewedForm" method="post" asp-page-handler="ToggleViewed">
492-
<input type="hidden" name="revisionId" value="@Model.ReviewContent.ActiveAPIRevision.Id" />
493-
@if (Model.ReviewContent.ActiveAPIRevision.ViewedBy.Contains(User.GetGitHubLogin()))
494-
{
495-
<input class="form-check-input" checked type="checkbox" role="switch" id="reviewViewedSwitch">
496-
}
497-
else
498-
{
499-
<input class="form-check-input" type="checkbox" role="switch" id="reviewViewedSwitch">
500-
}
501-
502-
<label class="form-check-label" for="reviewViewedSwitch">Mark as Viewed</label>
503-
</form>
504-
</div>
505-
</li>
506-
<li class="list-group-item">
507-
<div>
490+
<div>
508491
<p class="small revision-title">Change History:</p>
509492
@foreach (var change in Model.ReviewContent.ActiveAPIRevision.ChangeHistory)
510493
{

src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -285,30 +285,6 @@ public async Task<ActionResult> OnPostToggleSubscribedAsync(string id)
285285
return RedirectToPage(new { id = id });
286286
}
287287

288-
/// <summary>
289-
/// Mark a Review as Viewed
290-
/// </summary>
291-
/// <param name="id"></param>
292-
/// <param name="revisionId"></param>
293-
/// <returns></returns>
294-
public async Task<ActionResult> OnPostToggleViewedAsync(string id, string revisionId)
295-
{
296-
string userName = User.GetGitHubLogin();
297-
var revision = await _apiRevisionsManager.GetAPIRevisionAsync(revisionId);
298-
299-
if (revision.ViewedBy.Contains(userName))
300-
{
301-
revision.ViewedBy.Remove(userName);
302-
}
303-
else
304-
{
305-
revision.ViewedBy.Add(userName);
306-
}
307-
308-
await _apiRevisionsManager.UpdateAPIRevisionAsync(revision);
309-
return RedirectToPage(new { id = id, revisionId = revisionId });
310-
}
311-
312288
/// <summary>
313289
/// Approve or Revert Approval for a Review
314290
/// </summary>

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,6 @@
197197

198198
<app-page-options-section sectionName="API Revision Options">
199199
<ul class="list-group">
200-
<li class="list-group-item">
201-
<p-inputSwitch [(ngModel)]="markedAsViewSwitch"
202-
(onChange)="onMarkedAsViewedSwitchChange($event)" data-clarity-region="toggle-marked-as-viewed" />
203-
<label class="ms-2">Mark as viewed</label>
204-
</li>
205200
<li class="list-group-item">
206201
<label class="small mx-1 fw-semibold" for="diff-style-select">Reviewers :</label>
207202
<p-multiSelect

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ describe('ReviewPageOptionsComponent', () => {
104104
expect(component.showDocumentationSwitch).toEqual(true);
105105
expect(component.showHiddenAPISwitch).toEqual(false);
106106
expect(component.showLeftNavigationSwitch).toEqual(true);
107-
expect(component.markedAsViewSwitch).toEqual(false);
108107
expect(component.showLineNumbersSwitch).toEqual(true);
109108
expect(component.disableCodeLinesLazyLoading).toEqual(false);
110109
})

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
5252
@Output() showHiddenAPIEmitter : EventEmitter<boolean> = new EventEmitter<boolean>();
5353
@Output() showLeftNavigationEmitter : EventEmitter<boolean> = new EventEmitter<boolean>();
5454
@Output() disableCodeLinesLazyLoadingEmitter : EventEmitter<boolean> = new EventEmitter<boolean>();
55-
@Output() markAsViewedEmitter : EventEmitter<boolean> = new EventEmitter<boolean>();
5655
@Output() subscribeEmitter : EventEmitter<boolean> = new EventEmitter<boolean>();
5756
@Output() showLineNumbersEmitter : EventEmitter<boolean> = new EventEmitter<boolean>();
5857
@Output() apiRevisionApprovalEmitter : EventEmitter<boolean> = new EventEmitter<boolean>();
@@ -74,7 +73,6 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
7473
showDocumentationSwitch : boolean = true;
7574
showHiddenAPISwitch : boolean = false;
7675
showLeftNavigationSwitch : boolean = true;
77-
markedAsViewSwitch : boolean = false;
7876
subscribeSwitch : boolean = false;
7977
showLineNumbersSwitch : boolean = true;
8078
disableCodeLinesLazyLoading: boolean = false;
@@ -170,12 +168,10 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
170168

171169
if (changes['userProfile'] && changes['userProfile'].currentValue != undefined) {
172170
this.setSubscribeSwitch();
173-
this.setMarkedAsViewSwitch();
174171
this.setPageOptionValues();
175172
}
176173

177174
if (changes['activeAPIRevision'] && changes['activeAPIRevision'].currentValue != undefined) {
178-
this.setMarkedAsViewSwitch();
179175
this.selectedApprovers = this.activeAPIRevision!.assignedReviewers.map(reviewer => reviewer.assingedTo);
180176
this.isCopilotReviewSupported = this.isCopilotReviewSupportedForPackage();
181177
this.setAPIRevisionApprovalStates();
@@ -294,15 +290,7 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
294290
}
295291

296292
/**
297-
* Callback for markedAsViewSwitch Change
298-
* @param event the Filter event
299-
*/
300-
onMarkedAsViewedSwitchChange(event: InputSwitchChangeEvent) {
301-
this.markAsViewedEmitter.emit(event.checked);
302-
}
303-
304-
/**
305-
* Callback for markedAsViewSwitch Change
293+
* Callback for subscribeSwitch Change
306294
* @param event the Filter event
307295
*/
308296
onSubscribeSwitchChange(event: InputSwitchChangeEvent) {
@@ -465,10 +453,6 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges {
465453
this.subscribeSwitch = (this.userProfile && this.review) ? this.review!.subscribers.includes(this.userProfile?.email!) : this.subscribeSwitch;
466454
}
467455

468-
setMarkedAsViewSwitch() {
469-
this.markedAsViewSwitch = (this.activeAPIRevision && this.userProfile)? this.activeAPIRevision!.viewedBy.includes(this.userProfile?.userName!): this.markedAsViewSwitch;
470-
}
471-
472456
copyReviewText(event: Event) {
473457
const icon = (event?.target as Element).firstChild as HTMLElement;
474458

0 commit comments

Comments
 (0)