Skip to content

Commit

Permalink
Resolve Minor Bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Feb 11, 2023
1 parent 85445cc commit 66f1f91
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 104 deletions.
12 changes: 12 additions & 0 deletions src/dotnet/APIView/APIViewWeb/Client/css/pages/review.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,16 @@
&.gutter-horizontal {
cursor: col-resize;
}
}

.option-approved > label, .option-pending > label {
font-size: small;
}

.option-approved > label::after {
content: "";
font-family: "FontAwesome";
margin-left: 10px;
color: var(--success-color);
font-size: medium;
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ select {
border: 1px solid var(--border-color);
}

.dropdown-header {
color: var(--base-text-color);
}

.dropdown-item:hover, .dropdown-item:focus {
color: var(--base-text-color);
background-color: var(--base-bg-color);
}

.table {
color: var(--base-text-color);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
.comment-contents {
margin-bottom: 3px;
overflow-wrap: anywhere;
overflow-x: auto;
display: inline-grid;
}

.comment-contents .fw-bold {
Expand Down
15 changes: 3 additions & 12 deletions src/dotnet/APIView/APIViewWeb/Models/ReviewRevisionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ public string Author
set => _author = value;
}

[JsonIgnore]
public string DisplayNameShort
{
get
{
return Label != null ?
$"rev {RevisionNumber} - {Label}" :
$"rev {RevisionNumber}";
}
}

[JsonIgnore]
public string DisplayName
{
Expand All @@ -72,7 +61,9 @@ public string DisplayName
// the feature to allow for editing revision names cleaner.
name = Name;
}
return $"{DisplayNameShort} - {name}";
return Label != null ?
$"rev {RevisionNumber} - {Label} - {name}" :
$"rev {RevisionNumber} - {name}";
}
}

Expand Down
140 changes: 74 additions & 66 deletions src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div id="right-offcanvas-menu" class="right-offcanvas@(offCanvasClass)">
<div class="offcanvas-menu-content" id="review-offcanvas-menu-content">
<p class="h6">
<a data-bs-toggle="collapse" href="#approveCollapse" aria-expanded="true" aria-controls="approveCollapse">Approve&nbsp;&nbsp;<i class="fa-solid fa-ellipsis"></i></a>
<a data-bs-toggle="collapse" href="#approveCollapse" aria-expanded="true" aria-controls="approveCollapse">Approval&nbsp;&nbsp;<i class="fa-solid fa-ellipsis"></i></a>
</p>
@{
var approvalCollapseState = " show";
Expand All @@ -29,9 +29,8 @@
}
}
<ul class="list-group collapse mb-3@(approvalCollapseState)" id="approveCollapse">
<li class="list-group-item">
<small>Approves the current revision of the API</small>
<form asp-resource="@Model.Review" class="form-inline pt-1" asp-page-handler="ToggleApproval" method="post" asp-requirement="@ApproverRequirement.Instance">
<li class="list-group-item text-center">
<form asp-resource="@Model.Review" class="form-inline" asp-page-handler="ToggleApproval" method="post" asp-requirement="@ApproverRequirement.Instance">
<input type="hidden" name="revisionId" value="@Model.Revision.RevisionId" />
@if (Model.DiffRevision == null || Model.DiffRevision.Approvers.Count > 0)
{
Expand All @@ -44,47 +43,27 @@
else
{
@if (Model.ActiveConversations > 0 && Model.PreferredApprovers.Contains(User.GetGitHubLogin()))
{
{
<span class="small text-muted">Approves the current revision of the API</span>
<div class="d-grid gap-2">
<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#approveModel">
Approve for GA
Approve With Modal
</button>
</div>

<div class="modal fade" id="approveModel" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Approve Review</h5>
</div>
<div class="modal-body">
<p> There are still active conversations. <br /> Would you like to review these first? </p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
<a asp-page="Conversation" asp-route-id="@Model.Review.ReviewId">
<div class="btn btn-outline-secondary">Check Conversations</div>
</a>
<button type="submit" class="btn btn-success">
Approve API Anyway
</button>
</div>
</div>
</div>
</div>
}
else
{
@if (Model.PreferredApprovers.Contains(User.GetGitHubLogin()))
{
{
<span class="small text-muted">Approves the current revision of the API</span>
<div class="d-grid gap-2">
<button type="submit" class="btn btn-success">Approve for GA</button>
<button type="submit" class="btn btn-success">Approve</button>
</div>
}
else
{
<div class="d-grid gap-2">
<button type="submit" class="btn btn-outline-secondary" disabled>Cannot Approve for GA</button>
<button type="submit" class="btn btn-outline-secondary" disabled>Cannot Approve</button>
</div>
}
}
Expand All @@ -104,15 +83,15 @@
{
<div class="d-grid gap-2">
<button type="submit" class="btn btn-outline-secondary" disabled data-bs-placement="bottom" data-bs-toggle="tooltip" title="API review cannot be approved when comparing against unapproved revision.">
<i class="far fa-thumbs-up" aria-hidden="true"></i>&nbsp;&nbsp;Approve API
Approve API
</button>
</div>
}
}
</form>
@if (Model.Revision.Approvers.Count > 0)
{
<span class="small">
<span class="small text-muted">
Approvers:
@{
int i = 0;
Expand All @@ -129,38 +108,42 @@
}
</span>
}
</li>
<li class="list-group-item">
@if (Model.Review.Revisions.LastOrDefault()?.Files.LastOrDefault()?.PackageName != null)
else
{
var approver = Model.Review.ApprovedForFirstReleaseBy ?? Model.Review.Revisions.LastOrDefault(r => r.IsApproved)?.Approvers?.FirstOrDefault();
var nameApprovalTip = approver != null ? "Package has been approved for first release by " + approver : "Package has been approved for first release";

<form asp-resource="@Model" class="form-inline py-1" asp-controller="Review" asp-action="ApprovePackageName" asp-route-id="@Model.Review.ReviewId" method="post" asp-requirement="@ApproverRequirement.Instance">
@if (!Model.Review.IsApprovedForFirstRelease)
{
<small class="my-1">Approval for First Release.</small>
<span class="small text-muted">Current Revision Approval Pending</span> }
</li>
@if (Model.Review.Revisions.LastOrDefault()?.Files.LastOrDefault()?.PackageName != null &&
Model.Review.Language != "Swagger" && Model.Review.Language != "Cadl")
{
var approver = Model.Review.ApprovedForFirstReleaseBy ?? Model.Review.Revisions.LastOrDefault(r => r.IsApproved)?.Approvers?.FirstOrDefault();
@if (!Model.Review.IsApprovedForFirstRelease)
{
<li class="list-group-item text-center">
<form asp-resource="@Model" class="form-inline" asp-controller="Review" asp-action="ApprovePackageName" asp-route-id="@Model.Review.ReviewId" method="post" asp-requirement="@ApproverRequirement.Instance">
<span class="small mb-2 text-muted">Approves First Release of the package</span>
<div class="d-grid gap-2">
<button type="submit" class="btn btn-success" title="Package name must be approved before first preview release of a new package.">
Approve First Release
</button>
</div>

</div>
</form>
<span class="small mt-2 text-muted">First Revision Approval Pending</span>
</li>
}
else
{
<li class="list-group-item text-center">
@if (approver != null)
{
<span class="small my-1 text-muted">Package has been approved for first release by <a username="@approver">@approver</a></span>
}
else
{
@if (approver != null)
{
<span class="small my-1">Package has been approved for first release by <a username="@approver">@approver</a></span>
}
else
{
<span class="small my-1">Package has been approved for first release</span>
}
}
</form>
<span class="small my-1 text-muted">Package has been approved for first release</span>
}
</li>
}
</li>
}
</ul>
<p class="h6">
<a data-bs-toggle="collapse" href="#requestReviewersCollapse" aria-expanded="true" aria-controls="requestReviewersCollapse">Request Reviewers&nbsp;&nbsp;<i class="fa-solid fa-ellipsis"></i></a>
Expand Down Expand Up @@ -312,7 +295,7 @@
<label class="form-check-label" for="show-system-comments-checkbox">Show System Comments</label>
</div>
</li>
<li class="list-group-item">
<li class="list-group-item" id="show-documentation-component">
<div class="form-check form-switch">
@if (Model.ShowDocumentation)
{
Expand All @@ -327,7 +310,7 @@
</a>
</div>
</li>
<li class="list-group-item">
<li class="list-group-item" id="show-hidden-api-component">
<div class="form-check form-switch">
@if (userPreference.ShowHiddenApis == true)
{
Expand Down Expand Up @@ -397,7 +380,7 @@
<select id="revision-select" aria-label="Revision Select">
@foreach (var revision in Model.Review.Revisions.Reverse())
{
var optionName = revision.IsApproved ? $"{@revision.DisplayNameShort} ✔" : @revision.DisplayNameShort;
var optionClass = revision.IsApproved ? "option-approved" : "option-pending";
var urlValue = @Url.ActionLink("Review", "Assemblies", new
{
id = @Model.Review.ReviewId,
Expand All @@ -406,11 +389,11 @@
});
if (@revision.DisplayName == @Model.Revision.DisplayName)
{
<option selected value="@urlValue">@optionName</option>
<option selected value="@urlValue" class="@optionClass">@revision.DisplayName</option>
}
else
{
<option value="@urlValue">@optionName</option>
<option value="@urlValue" class="@optionClass">@revision.DisplayName</option>
}
}
</select>
Expand Down Expand Up @@ -449,7 +432,7 @@
}
@foreach (var revision in Model.PreviousRevisions.Reverse())
{
var optionName = revision.IsApproved ? $"{@revision.DisplayNameShort} ✔" : @revision.DisplayNameShort;
var optionClass = revision.IsApproved ? "option-approved" : "option-pending";
var urlValue = @Url.ActionLink("Review", "Assemblies", new
{
id = @Model.Review.ReviewId,
Expand All @@ -462,18 +445,18 @@
{
if (@Model.DiffRevisionId == @revision.RevisionId)
{
<option value="@urlValue" selected>@optionName</option>
<option value="@urlValue" selected class="@optionClass">@revision.DisplayName</option>
}
else
{
<option value="@urlValue">@optionName</option>
<option value="@urlValue" class="@optionClass">@revision.DisplayName</option>
}
}
else
{
if (@Model.DiffRevisionId != @revision.RevisionId)
{
<option value="@urlValue">@optionName</option>
<option value="@urlValue" class="@optionClass">@revision.DisplayName</option>
}
}
}
Expand Down Expand Up @@ -544,6 +527,31 @@
</tbody>
</table>
</div>
</div>
</div>

<form asp-resource="@Model.Review" class="form-inline" asp-page-handler="ToggleApproval" method="post" asp-requirement="@ApproverRequirement.Instance">
<input type="hidden" name="revisionId" value="@Model.Revision.RevisionId" />
<div class="modal fade" id="approveModel" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Approve Review</h5>
</div>
<div class="modal-body">
<p> There are still active conversations. <br /> Would you like to review these first? </p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
<a asp-page="Conversation" asp-route-id="@Model.Review.ReviewId">
<div class="btn btn-outline-secondary">Check Conversations</div>
</a>
<button type="submit" class="btn btn-success">
Approve API Anyway
</button>
</div>
</div>
</div>
</div>
</form>
<partial name="_CommentFormPartial" model="@Model.TaggableUsers" />
</div>
Expand Down
Loading

0 comments on commit 66f1f91

Please sign in to comment.