Skip to content

Commit

Permalink
Fix minor bugs in Deprecation UI found in bug bash (NuGet#6994)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Bommarito authored Mar 13, 2019
1 parent cac9cc3 commit 5972daf
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/Bootstrap/dist/css/bootstrap-theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Bootstrap/less/theme/common-multi-select-dropdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
border-top: 0px;

.dropdown-selector {
height: 300px;
max-height: 300px;
overflow: auto;

.dropdown-filter {
Expand Down
6 changes: 6 additions & 0 deletions src/NuGetGallery/Scripts/gallery/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@
return false;
}

// Elements with tabindex set to a value besides -1 are focusable.
var tabIndex = element.attr('tabindex');
if (!!tabIndex && tabIndex >= 0) {
return true;
}

// See https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Interactive_content
var alwaysInteractiveElements = ['a', 'button', 'details', 'embed', 'iframe', 'keygen', 'label', 'select', 'textarea'];
var i;
Expand Down
9 changes: 7 additions & 2 deletions src/NuGetGallery/Scripts/gallery/page-manage-deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function ManageDeprecationViewModel(id, versionDeprecationStateDictionary, defau
// Show a warning if multiple versions are selected and at least one has an existing deprecation
// The user should be aware they are replacing existing deprecations
// Don't show an alert if a single version is selected because it is clear that the deprecation is being replaced
warningMessage = "Some of the package versions you selected have already been deprecated. These versions will have their deprecation information overriden or removed based on your actions.";
warningMessage = "Some of the package versions you selected have already been deprecated. All selected versions will have their deprecation information overridden or removed when you submit this form.";
}
} else if (hasVersionsWithExistingDeprecationState) {
// Show a warning if no reasons are selected and at least one selected version has an existing deprecation
Expand Down Expand Up @@ -572,5 +572,10 @@ function ManageDeprecationViewModel(id, versionDeprecationStateDictionary, defau
// Load the state for the default version.
loadDeprecationFormState(defaultVersion);

ko.applyBindings(this, $(".page-manage-deprecation")[0]);
var section = $(".page-manage-deprecation")[0];
// Only apply bindings if the form exists.
// In certain situations (the package is locked, user doesn't have permissions, etc) we do not render the form.
if (section) {
ko.applyBindings(this, section);
}
}
13 changes: 12 additions & 1 deletion src/NuGetGallery/Views/Packages/Manage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
ViewBag.MdPageColumns = GalleryConstants.ColumnsFormMd;
}

@Html.Partial("_MultiSelectDropdown")

<section role="main" class="container main-container">
@ViewHelpers.AjaxAntiForgeryToken(Html)
<div class="row">
Expand All @@ -16,6 +18,15 @@
"Manage",
linkIdOnly: true))

@if (Model.IsLocked)
{
@ViewHelpers.AlertDanger(
@<text>
Package '@Model.Id' has been locked. Please contact
<a href="mailto:[email protected][email protected](string.Format("Requesting support for a locked package - '{0}'", Model.Id))">support@nuget.org</a>
</text>)
}

@ViewHelpers.Section(
this,
"Owners",
Expand Down Expand Up @@ -103,7 +114,7 @@
var state = versionListedState[version];
// Update the listed checkbox to match the state of the package.
var listed = state.Listed;
$(".page-delete-package input#Listed")[0].checked = listed;
$(".page-delete-package input#Listed").prop('checked', listed);
// Update the text stating the download count on the delete form.
var downloadCount = state.DownloadCount;
$(".page-delete-package #downloadCount").text(downloadCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="deprecation-container">
<div class="icon-text alert alert-warning">
<div id="show-deprecation-content-container" class="deprecation-expander" tabindex="0" data-toggle="collapse" data-target="#deprecation-content-container" aria-expanded="false" aria-controls="deprecation-content-container" aria-labelledby="deprecation-container-label">
<div class="deprecation-expander">
<div class="deprecation-expander" role="button">
<div class="deprecation-expander-container">
<i class="deprecation-expander-icon ms-Icon ms-Icon--Warning" aria-hidden="true"></i>

Expand Down Expand Up @@ -93,14 +93,12 @@
}

<b>Suggested Alternatives</b>
<p>
Consider using <a href="@alternateUrl">@alternateText</a> instead of this package.
</p>
<p><a href="@alternateUrl">@alternateText</a></p>
}

@if (!string.IsNullOrEmpty(Model.CustomMessage))
{
<b>Package owner message</b>
<b>Additional Details</b>
<p>@Model.CustomMessage</p>
}
</div>
Expand Down
19 changes: 9 additions & 10 deletions src/NuGetGallery/Views/Packages/_ManageDeprecation.cshtml
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
@model ManagePackageViewModel

<div class="page-manage-deprecation">
<span>Deprecating a package will warn all consumers of the package who use it in their projects.</span>

@if (!Model.VersionSelectList.Any())
{
@ViewHelpers.AlertInfo(
@<text>
<span>There are no versions that can be deprecated.</span>
</text>)
@ViewHelpers.AlertInfo(@<text>There are no versions that can be deprecated.</text>)
}
else if (!Model.CanDeprecate)
{
@ViewHelpers.AlertWarning(@<text>You do not have permission to deprecate this package.</text>)
@ViewHelpers.AlertDanger(@<text>You do not have permission to deprecate this package.</text>)
}
else if (Model.IsLocked)
{
@ViewHelpers.AlertDanger(@<text>Locked packages cannot be deprecated.</text>)
}
else
{
<span>Deprecating a package will warn all consumers of the package who use it in their projects.</span>

<div data-bind="template: { name: 'add-deprecation-template' }"></div>
}
</div>

@Html.Partial("_MultiSelectDropdown")

<script type="text/html" id="add-deprecation-template">
<div class="deprecation-section form-group">
<label id="dropdown-label" class="deprecation-section-header">Select version(s)</label>
Expand Down Expand Up @@ -150,7 +149,7 @@
<div class="security-detail-list-item alert-info">
<div class="security-detail-list-item-header">
<div>
<a data-bind="text: id, attr: { href: $parent.getUrlFromId(id) }, css: { 'security-detail-list-item-existing': fromAutocomplete, 'security-detail-list-item-missing': !fromAutocomplete }"></a>
<a data-bind="text: id, attr: { href: $parent.getUrlFromId(id) }, css: { 'security-detail-list-item-existing': fromAutocomplete, 'security-detail-list-item-missing': !fromAutocomplete }" target="_blank"></a>
<span data-bind="visible: name || !fromAutocomplete">
&nbsp;-&nbsp;
<span data-bind="visible: name, text: name"></span>
Expand Down
3 changes: 1 addition & 2 deletions src/NuGetGallery/Views/Packages/_ManageDocumentation.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
@ViewHelpers.AlertDanger(
@<text>
<span>
Package '@Model.Id' has been locked. This means you cannot publish a new version or change the listing status of a published package version. Please contact
<a href="mailto:[email protected][email protected](string.Format("Requesting support for a locked package - '{0}'", Model.Id))">support@nuget.org</a>.
You cannot update the documentation of a locked package.
</span>
</text>)
</div>
Expand Down
23 changes: 2 additions & 21 deletions src/NuGetGallery/Views/Packages/_ManageListing.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,16 @@

@if (!Model.VersionSelectList.Any())
{
@ViewHelpers.AlertInfo(
@<text>
<span>There are no versions that can have their listing state changed.</span>
</text>)
@ViewHelpers.AlertInfo(@<text>There are no versions that can have their listing state changed.</text>)
}
else if (Model.IsLocked && !User.IsAdministrator())
{
<div class="validation-error-message-list">
@ViewHelpers.AlertDanger(
@<text>
<span>
Package '@Model.Id' has been locked. This means you cannot publish a new version or change the listing status of a published package version. Please contact
<a href="mailto:[email protected][email protected](string.Format("Requesting support for a locked package - '{0}'", Model.Id))">support@nuget.org</a>.
</span>
</text>)
@ViewHelpers.AlertDanger(@<text>You cannot change the listing state of a locked package.</text>)
</div>
}
else
{
if (Model.IsLocked && User.IsAdministrator())
{
<div class="validation-error-message-list">
@ViewHelpers.AlertDanger(
@<text>
<span>Package '@Model.Id' has been locked.</span>
</text>)
</div>
}

<label for="input-select-version" id="package-version-label">Select version</label>

@Html.DropDownList("version-selection", Model.VersionSelectList,
Expand Down

0 comments on commit 5972daf

Please sign in to comment.