Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add accessible popovers to vulnerability alerts #8624

Merged
merged 3 commits into from
Jun 8, 2021
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
12 changes: 12 additions & 0 deletions src/NuGetGallery/Scripts/gallery/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,18 @@
}
};

nuget.setPopovers = function () {
var popoverElement = $(this);
popoverElement.popover({ trigger: 'hover focus' });
popoverElement.click(function () {
popoverElement.popover('show');
setTimeout(function () {
popoverElement.popover('destroy');
},
1000);
});
};

window.nuget = nuget;

jQuery.extend(jQuery.expr.pseudos, {
Expand Down
16 changes: 2 additions & 14 deletions src/NuGetGallery/Scripts/gallery/page-display-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,6 @@ $(function () {
});
}

// Add popover to reserved check mark
$(".reserved-indicator").each(
function () {
var checkmarkImage = $(this);
checkmarkImage.popover({ trigger: 'hover focus' });
checkmarkImage.click(function () {
checkmarkImage.popover('show');
setTimeout(function () {
checkmarkImage.popover('destroy');
},
1000);
});
}
);
$(".reserved-indicator").each(window.nuget.setPopovers);
$(".package-warning-icon").each(window.nuget.setPopovers);
});
14 changes: 1 addition & 13 deletions src/NuGetGallery/Scripts/gallery/page-list-packages.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
$(function() {
'use strict';

$(".reserved-indicator").each(
function() {
var checkmarkImage = $(this);
checkmarkImage.popover({ trigger: 'hover focus' });
checkmarkImage.click(function() {
checkmarkImage.popover('show');
setTimeout(function() {
checkmarkImage.popover('destroy');
},
1000);
});
}
);
$(".reserved-indicator").each(window.nuget.setPopovers);
});
1 change: 1 addition & 0 deletions src/NuGetGallery/Scripts/gallery/page-manage-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@

setupColumnSorting();

$(".package-warning-icon").each(window.nuget.setPopovers);
});

})();
11 changes: 7 additions & 4 deletions src/NuGetGallery/Views/Packages/DisplayPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@
rowCount++;
@VersionListDivider(rowCount, versionsExpanded)
<tr class="@(packageVersion.IsCurrent(Model) ? "bg-info" : null)">
<td tabindex="0">
<td>
<a href="@Url.Package(packageVersion)" title="@packageVersion.Version">
@packageVersion.Version.Abbreviate(30)
</a>
Expand All @@ -795,7 +795,7 @@
{
var packageStatusSummary = packageVersion.PackageStatusSummary;

<td tabindex="0">
<td>
@if (packageStatusSummary == PackageStatusSummary.Listed ||
packageStatusSummary == PackageStatusSummary.Unlisted)
{
Expand Down Expand Up @@ -828,8 +828,11 @@
}
else
{
<td tabindex="0" class="package-icon-cell">
<i class="ms-Icon ms-Icon--Warning package-icon" title="@packageVersion.PackageWarningIconTitle"></i>
<td class="package-icon-cell">
<span class="package-warning-icon" aria-label="@packageVersion.PackageWarningIconTitle"
data-content="@packageVersion.PackageWarningIconTitle" tabindex="0">
<i class="ms-Icon ms-Icon--Warning package-icon"></i>
</span>
</td>
}
</tr>
Expand Down
9 changes: 6 additions & 3 deletions src/NuGetGallery/Views/Users/Packages.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,18 @@
</td>
}
<td class="align-middle text-nowrap" data-bind="attr: { 'data-sortby': DownloadCount }">
<span data-bind="text: FormattedDownloadCount"></span>
<span data-bind="text: FormattedDownloadCount" tabindex="0"></span>
</td>
<td class="align-middle text-nowrap" data-bind="attr: { 'data-sortby': VersionSortOrder }">
<span data-bind="text: LatestVersion"></span>
<span data-bind="text: LatestVersion" tabindex="0"></span>
</td>
@if (Model.IsManagePackagesVulnerabilitiesEnabled)
{
var title = "This version has at least one known vulnerability. Click on the package name for details.";
<td class="package-icon-cell">
<i class="ms-Icon ms-Icon--Warning package-icon" data-bind="visible: IsVulnerable" title="This version has at least one known vulnerability. Click on the package name for details."></i>
<span class="package-warning-icon" aria-label="@title" data-content="@title" data-bind="visible: IsVulnerable" tabindex="0">
<i class="ms-Icon ms-Icon--Warning package-icon"></i>
</span>
</td>
}
<td class="text-right align-middle package-controls">
Expand Down