Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package frontend

import (
	
	
	

	
	
)
TabSettings defines tab-specific metadata.
Name is the tab name used in the URL.
DisplayName is the formatted tab name.
AlwaysShowDetails defines whether the tab content can be shown even if the package is not determined to be redistributable.
TemplateName is the name of the template used to render the corresponding tab, as defined in Server.templates.
Disabled indicates whether a tab should be displayed as disabled.
	Disabled bool
}

const (
	tabMain       = ""
	tabVersions   = "versions"
	tabImports    = "imports"
	tabImportedBy = "importedby"
	tabLicenses   = "licenses"
)

var (
	unitTabs = []TabSettings{
		{
			Name:         tabMain,
			TemplateName: "unit_details.tmpl",
		},
		{
			Name:         tabVersions,
			TemplateName: "unit_versions.tmpl",
		},
		{
			Name:         tabImports,
			TemplateName: "unit_imports.tmpl",
		},
		{
			Name:         tabImportedBy,
			TemplateName: "unit_importedby.tmpl",
		},
		{
			Name:         tabLicenses,
			TemplateName: "unit_licenses.tmpl",
		},
	}
	unitTabLookup = make(map[string]TabSettings, len(unitTabs))
)

func () {
	for ,  := range unitTabs {
		unitTabLookup[.Name] = 
	}
}
fetchDetailsForPackage returns tab details by delegating to the correct detail handler.
func ( context.Context,  *http.Request,  string,  internal.DataSource,  *internal.UnitMeta,  internal.BuildContext) ( interface{},  error) {
	defer derrors.Wrap(&, "fetchDetailsForUnit(r, %q, ds, um=%q,%q,%q)", , .Path, .ModulePath, .Version)
	switch  {
	case tabMain:
		,  := .URL.Query()["readme"]
		return fetchMainDetails(, , , , )
	case tabVersions:
		return fetchVersionsDetails(, , .Path, .ModulePath)
	case tabImports:
		return fetchImportsDetails(, , .Path, .ModulePath, .Version)
	case tabImportedBy:
		return fetchImportedByDetails(, , .Path, .ModulePath)
	case tabLicenses:
		return fetchLicensesDetails(, , )
	}
	return nil, fmt.Errorf("BUG: unable to fetch details: unknown tab %q", )