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

Polish upload UI for license html file #8735

Merged
merged 4 commits into from
Aug 31, 2021
Merged

Polish upload UI for license html file #8735

merged 4 commits into from
Aug 31, 2021

Conversation

lyndaidaii
Copy link
Contributor

@lyndaidaii lyndaidaii commented Aug 4, 2021

Summary of the changes (in less than 80 characters):
Upload page:
LicenseFileDisplay

Display page:
licenseFile

Addresses #8277

@lyndaidaii lyndaidaii requested a review from a team as a code owner August 4, 2021 18:36
@joelverhagen
Copy link
Member

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{
Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it will be plaintext with block display to match with html display.
licensetxt

@zhhyu
Copy link
Contributor

zhhyu commented Aug 7, 2021

                <label>License text</label>

Should we show "License text" for licenses in Markdown?


Refers to: src/NuGetGallery/Views/Packages/License.cshtml:67 in 1deecfd. [](commit_id = 1deecfd, deletion_comment = False)

@Html.Raw(Model.LicenseFileContentsHtml)
}
else
if (Model.LicenseFileContentsHtml.ImageSourceDisallowed)
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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"?

Copy link
Contributor Author

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>)
Copy link
Contributor

@zhhyu zhhyu Aug 7, 2021

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

Copy link
Contributor Author

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);
Copy link
Contributor

@zhhyu zhhyu Aug 7, 2021

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?

Copy link
Contributor Author

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>
Copy link
Contributor

@zhhyu zhhyu Aug 7, 2021

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

@zhhyu zhhyu Aug 7, 2021

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No background color, here is what it will looks like
LicenseView

Copy link
Member

@joelverhagen joelverhagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address comments then :shipit:

@lyndaidaii
Copy link
Contributor Author

                <label>License text</label>

Should we show "License text" for licenses in Markdown?

Refers to: src/NuGetGallery/Views/Packages/License.cshtml:67 in 1deecfd. [](commit_id = 1deecfd, deletion_comment = False)

I changed to License file instead of License text

{
@AlertWarning(
@<text>
This documentation had some images automatically rewritten to use secure links and may be broken.
Copy link
Contributor

@agr agr Aug 31, 2021

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?

Copy link
Contributor Author

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

@lyndaidaii lyndaidaii merged commit 9dd5b06 into dev Aug 31, 2021
@dannyjdev dannyjdev mentioned this pull request Sep 1, 2021
6 tasks
@joelverhagen joelverhagen deleted the license-lynn branch August 22, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants