Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/dotnet/APIView/APIViewWeb/Client/src/pages/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,18 @@ $(() => {
$("#reviewSubscribeSwitch").on('change', function () {
$("#reviewSubscribeForm").submit();
});
// Toggle Viewed Switch
$("#reviewViewedSwitch").on('change', function () {
$("#reviewViewedForm").submit();
});
// Toggle Close Switch
$("#reviewCloseSwitch").on('change', function () {
$("#reviewCloseForm").submit();
});

// Manage Expand / Collapse State of options
[$("#approveCollapse"), $("#requestReviewersCollapse"), $("#reviewOptionsCollapse"), $("#pageSettingsCollapse"),
$("#associatedPRCollapse"), $("#associatedReviewsCollapse"), $("#generateAIReviewCollapse")].forEach(function (value, index) {
$("#associatedPRCollapse"), $("#associatedReviewsCollapse"), $("#generateAIReviewCollapse"), $("#apiRevisionOptionsCollapse")].forEach(function (value, index) {
const id = value.attr("id");
value.on('hidden.bs.collapse', function () {
document.cookie = `${id}=hidden; max-age=${7 * 24 * 60 * 60}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public class APIRevisionListItemModel : BaseListitemModel
public bool IsDeleted { get; set; }
public bool IsReleased { get; set; }
public DateTime ReleasedOn { get; set; }
public HashSet<string> ViewedBy { get; set; } = new HashSet<string>();
}

public class SamplesRevisionModel
Expand Down
36 changes: 33 additions & 3 deletions src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
}
}
<p class="h6">
<a data-bs-toggle="collapse" href="#reviewOptionsCollapse" aria-expanded="true" aria-controls="approvalCollapse">Review Options&nbsp;&nbsp;<i class="fa-solid fa-ellipsis"></i></a>
<a data-bs-toggle="collapse" href="#reviewOptionsCollapse" aria-expanded="true" aria-controls="reviewOptionsCollapse">Review Options&nbsp;&nbsp;<i class="fa-solid fa-ellipsis"></i></a>
</p>
@{
var reviewOptionsCollapseState = " show";
Expand Down Expand Up @@ -366,7 +366,7 @@
</li>
</ul>
<p class="h6">
<a data-bs-toggle="collapse" href="#pageSettingsCollapse" aria-expanded="true" aria-controls="approvalCollapse">Page Settings&nbsp;&nbsp;<i class="fa-solid fa-ellipsis"></i></a>
<a data-bs-toggle="collapse" href="#pageSettingsCollapse" aria-expanded="true" aria-controls="pageSettingsCollapse">Page Settings&nbsp;&nbsp;<i class="fa-solid fa-ellipsis"></i></a>
</p>
@{
var pageSettingsCollapseState = String.Empty;
Expand Down Expand Up @@ -475,7 +475,37 @@
</div>
</li>
}
</ul>
</ul>
<p class="h6">
<a data-bs-toggle="collapse" href="#apiRevisionOptionsCollapse" aria-expanded="true" aria-controls="apiRevisionOptionsCollapse">API Revision Options&nbsp;&nbsp;<i class="fa-solid fa-ellipsis"></i></a>
</p>
@{
var apiRevisionOptionsCollapseState = " show";
if (Request.Cookies.ContainsKey("apiRevisionOptionsCollapse"))
{
if (!Request.Cookies["apiRevisionOptionsCollapse"].Equals("shown"))
apiRevisionOptionsCollapseState = String.Empty;
}
}
<ul class="list-group collapse mb-3@(apiRevisionOptionsCollapseState)" id="apiRevisionOptionsCollapse">
<li class="list-group-item">
<div class="form-check form-switch">
<form asp-resource="@Model.ReviewContent.ActiveAPIRevision" class="form-inline" id="reviewViewedForm" method="post" asp-page-handler="ToggleViewed">
<input type="hidden" name="revisionId" value="@Model.ReviewContent.ActiveAPIRevision.Id" />
@if (Model.ReviewContent.ActiveAPIRevision.ViewedBy.Contains(User.GetGitHubLogin()))
{
<input class="form-check-input" checked type="checkbox" role="switch" id="reviewViewedSwitch">
}
else
{
<input class="form-check-input" type="checkbox" role="switch" id="reviewViewedSwitch">
}

<label class="form-check-label" for="reviewViewedSwitch">Mark as Viewed</label>
</form>
</div>
</li>
</ul>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,30 @@ public async Task<ActionResult> OnPostToggleSubscribedAsync(string id)
return RedirectToPage(new { id = id });
}

/// <summary>
/// Mark a Review as Viewed
/// </summary>
/// <param name="id"></param>
/// <param name="revisionId"></param>
/// <returns></returns>
public async Task<ActionResult> OnPostToggleViewedAsync(string id, string revisionId)
{
string userName = User.GetGitHubLogin();
var revision = await _apiRevisionsManager.GetAPIRevisionAsync(revisionId);

if (revision.ViewedBy.Contains(userName))
{
revision.ViewedBy.Remove(userName);
}
else
{
revision.ViewedBy.Add(userName);
}

await _apiRevisionsManager.UpdateAPIRevisionAsync(revision);
return RedirectToPage(new { id = id, revisionId = revisionId });
}

/// <summary>
/// Approve or Revert Approval for a Review
/// </summary>
Expand Down Expand Up @@ -274,7 +298,6 @@ public async Task<IActionResult> OnPostUploadAsync(string id, [FromForm] IFormFi
return RedirectToPage(new { id = id, revisionId = apiRevision.Id });
}


/// <summary>
/// Get Routing Data for a Review
/// </summary>
Expand All @@ -292,6 +315,7 @@ public Dictionary<string, string> GetRoutingData(string diffRevisionId = null, b
routingData["diffOnly"] = (showDiffOnly ?? false).ToString();
return routingData;
}

/// <summary>
/// Get Pull Requests for a Review
/// </summary>
Expand Down