-
Notifications
You must be signed in to change notification settings - Fork 644
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
Polish upload UI for license html file #8735
Conversation
20ffb00
to
681c64b
Compare
There is at least one warning that can be produced by the Markdown: disallowed image host. Are these warnings surfaced similarly for license Markdown? I think there may be other warnings too... perhaps HTTP images or other things? Let's make sure there is parity in these edge cases. |
@@ -4,7 +4,14 @@ | |||
word-break: normal; | |||
} | |||
|
|||
.custom-license-container { | |||
.custom-license-container, .license-file-html-container{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you verified plaintext licenses? This looks like this might be a change in UI for the custom-license-container
class (which I am assuming is related to the existing plain text embedded license file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Html.Raw(Model.LicenseFileContentsHtml) | ||
} | ||
else | ||
if (Model.LicenseFileContentsHtml.ImageSourceDisallowed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For readmes, I think we only show the warning message to the package owner. For licenses, will it show this to everyone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added logic to show warning to author only
@Html.Raw(Model.LicenseFileContentsHtml) | ||
} | ||
else | ||
if (Model.LicenseFileContentsHtml.ImageSourceDisallowed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any other cases of warning messages? such as "ImagesRewritten"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included "ImagesRewritten" warning now
@@ -135,7 +135,10 @@ | |||
<div class="verify-package-field common-licenses"> | |||
<label class="verify-package-field-heading">License file</label> | |||
<!-- ko if: $data.LicenseFileContentsHtml --> | |||
<span data-bind="html: $data.LicenseFileContentsHtml"></span> | |||
<!-- ko if: $data.LicenseFileContentsHtml.ImageSourceDisallowed--> | |||
@ViewHelpers.AlertWarning(@<text>Some images are not displayed as they are not from <a href='https://aka.ms/nuget-org-readme#allowed-domains-for-images-and-badges'>trusted domains</a>.</text>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we reuse the message for multiple times, it will be better that we put it in a shared place: src/NuGetGallery/Strings.resx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created function in viewHelpers since we use this alertWarning multiple times
@@ -68,7 +68,7 @@ public DisplayLicenseViewModelFactory(IIconUrlProvider iconUrlProvider, IMarkdow | |||
package.EmbeddedLicenseType == EmbeddedLicenseFileType.Markdown && | |||
licenseFileContents != null) | |||
{ | |||
viewModel.LicenseFileContentsHtml = _markdownService.GetHtmlFromMarkdown(licenseFileContents)?.Content; | |||
viewModel.LicenseFileContentsHtml = _markdownService.GetHtmlFromMarkdown(licenseFileContents); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be possible to add some tests here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test was added
<!-- ko if: $data.LicenseFileContentsHtml.ImageSourceDisallowed--> | ||
@ViewHelpers.AlertWarning(@<text>Some images are not displayed as they are not from <a href='https://aka.ms/nuget-org-readme#allowed-domains-for-images-and-badges'>trusted domains</a>.</text>) | ||
<!-- /ko --> | ||
<span class="license-file-html-container" data-bind="html: $data.LicenseFileContentsHtml.Content"></span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little curious about why using span
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was span before, I just follow the original code adding class to it <span data-bind="html: $data.LicenseFileContentsHtml"></span>
display: block; | ||
padding: 10.5px; | ||
background-color: @pre-bg; | ||
border: 1px solid #ccc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies that I didn't check the css structure at Verify page. I see some properties such as "border". Should they share with other containers like embedded readmes or inherit from the parent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license container is sharing the embedded readme css setting on verify page. One thing we could do is to make common-licenses.less and common-readme.less to one file, it will make less duplicate. Include in the base.less probably those two are not general enough. Please let me know your thoughts. thanks
@ViewHelpers.AlertWarning(@<text>Some images are not displayed as they are not from <a href='https://aka.ms/nuget-org-readme#allowed-domains-for-images-and-badges'>trusted domains</a>.</text>) | ||
|
||
} | ||
@Html.Raw(Model.LicenseFileContentsHtml.Content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to check the rendering/css with Verify page to ensure that they will share the same appearance as much as possible. This is critical to understand what it will look like before the package is pushed.
Besides, I can see that the text license file has the background color, will the markdown one share the similar appearance?
https://www.nuget.org/packages/license-file-lucene-1/0.0.2/License
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address comments then
{ | ||
@AlertWarning( | ||
@<text> | ||
This documentation had some images automatically rewritten to use secure links and may be broken. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This documentation had some image URLs automatically rewritten ..." maybe? We don't change images themselves, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't change the images, but we changes the images source to https if it comes from http
Summary of the changes (in less than 80 characters):
Upload page:
Display page:
Addresses #8277