content,internal/frotend: remove CanShowDetails logic

CanShowDetails is always true, except for licenses. In that case,
redirect users to the main page, instead of showing them an empty
licenses tab.

CanShowDetails and TabSettings.AlwaysShowDetails are longer needed.

Change-Id: I6a3630c38dcaa36c8f5105e410ba5ea70ec8d4c5
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/262099
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/content/static/html/helpers/_unit_header.tmpl b/content/static/html/helpers/_unit_header.tmpl
index cd09a81..c35c23b 100644
--- a/content/static/html/helpers/_unit_header.tmpl
+++ b/content/static/html/helpers/_unit_header.tmpl
@@ -62,11 +62,20 @@
           <span class="UnitHeader-detailItem">
             <img height="16px" width="16px" src="/static/img/pkg-icon-scale_16x16.svg" alt="">
             {{if .Details.Licenses}}
-              <a href="{{$.URLPath}}?tab=licenses">
-                {{range $i, $e := .Details.Licenses}}
-                {{if $i}}, {{end}} {{$e.Type}}
-                {{end}}
-              </a>
+              {{if .Unit.IsRedistributable}}
+                <a href="{{$.URLPath}}?tab=licenses">
+                  {{range $i, $e := .Details.Licenses}}
+                    {{if $i}}, {{end}} {{$e.Type}}
+                  {{end}}
+                </a>
+              {{else}}
+                <span>
+                  {{range $i, $e := .Details.Licenses}}
+                    {{if $i}}, {{end}} {{$e.Type}}
+                  {{end}}
+                </span>
+                <a href="/license-policy" class="Disclaimer-link"><em>not legal advice</em></a>
+              {{end}}
             {{else}}
               <span>None detected</span>
               <a href="/license-policy" class="Disclaimer-link"><em>not legal advice</em></a>
diff --git a/content/static/html/pages/unit_details.tmpl b/content/static/html/pages/unit_details.tmpl
index 92fdfed..4d9f4bb 100644
--- a/content/static/html/pages/unit_details.tmpl
+++ b/content/static/html/pages/unit_details.tmpl
@@ -17,7 +17,7 @@
       {{block "unit_outline" .Details}}{{end}}
     </div>
     <div class="UnitDetails-content" role="main">
-      {{if .CanShowDetails}}
+      {{if .Unit.IsRedistributable}}
         {{if .Details.Readme.String}}
           {{block "unit_readme" .Details}}{{end}}
         {{end}}
diff --git a/internal/frontend/unit.go b/internal/frontend/unit.go
index 220a22f..42a79c7 100644
--- a/internal/frontend/unit.go
+++ b/internal/frontend/unit.go
@@ -77,8 +77,9 @@
 		tab = tabMain
 	}
 	tabSettings, ok := unitTabLookup[tab]
-	if !ok {
+	if !ok || tab == tabLicenses && !um.IsRedistributable {
 		// Redirect to clean URL path when tab param is invalid.
+		// If the path is not redistributable, licenses is an invalid tab.
 		http.Redirect(w, r, r.URL.Path, http.StatusFound)
 		return nil
 	}
@@ -86,7 +87,6 @@
 	title := pageTitle(um)
 	basePage := s.newBasePage(r, title)
 	basePage.AllowWideContent = true
-	canShowDetails := um.IsRedistributable || tabSettings.AlwaysShowDetails
 	page := UnitPage{
 		basePage:    basePage,
 		Unit:        um,
@@ -109,7 +109,6 @@
 		LatestURL:      constructPackageURL(um.Path, um.ModulePath, middleware.LatestMinorVersionPlaceholder),
 		PageLabels:     pageLabels(um),
 		PageType:       pageType(um),
-		CanShowDetails: canShowDetails,
 	}
 	d, err := fetchDetailsForUnit(r, tab, ds, um)
 	if err != nil {
diff --git a/internal/frontend/unit_tabs.go b/internal/frontend/unit_tabs.go
index 49a6a31..e7de0b9 100644
--- a/internal/frontend/unit_tabs.go
+++ b/internal/frontend/unit_tabs.go
@@ -28,22 +28,19 @@
 			TemplateName: "unit_details.tmpl",
 		},
 		{
-			Name:              tabVersions,
-			AlwaysShowDetails: true,
-			DisplayName:       "Versions",
-			TemplateName:      "unit_versions.tmpl",
+			Name:         tabVersions,
+			DisplayName:  "Versions",
+			TemplateName: "unit_versions.tmpl",
 		},
 		{
-			Name:              tabImports,
-			AlwaysShowDetails: true,
-			DisplayName:       "Imports",
-			TemplateName:      "unit_imports.tmpl",
+			Name:         tabImports,
+			DisplayName:  "Imports",
+			TemplateName: "unit_imports.tmpl",
 		},
 		{
-			Name:              tabImportedBy,
-			AlwaysShowDetails: true,
-			DisplayName:       "Imported By",
-			TemplateName:      "unit_importedby.tmpl",
+			Name:         tabImportedBy,
+			DisplayName:  "Imported By",
+			TemplateName: "unit_importedby.tmpl",
 		},
 		{
 			Name:         tabLicenses,