Repository: vmware-tanzu/octant
Pull request #869 (2020-04-22 21:20:10)

Fixed merge issues with breadcrumbs
Signed-off-by: Milan Klanjsek <mklanjsek@pivotal.io>




Patch:
diff --git a/changelogs/unreleased/868-GuessWhoSamFoo b/changelogs/unreleased/868-GuessWhoSamFoo
deleted file mode 100644
index 3c1d2518..00000000
--- a/changelogs/unreleased/868-GuessWhoSamFoo
+++ /dev/null
@@ -1,2 +0,0 @@
-Fixed initial active tab to use first tab if url fragment is missing
-
diff --git a/internal/describer/object.go b/internal/describer/object.go
index 597ce6ee..0ee67da6 100644
--- a/internal/describer/object.go
+++ b/internal/describer/object.go
@@ -8,6 +8,7 @@ package describer
 import (
 	"context"
 	"fmt"
+	"path/filepath"
 
 	"k8s.io/apimachinery/pkg/api/meta"
 	"k8s.io/apimachinery/pkg/runtime"
@@ -40,6 +41,7 @@ type ObjectConfig struct {
 	StoreKey       store.Key
 	IconName       string
 	IconSource     string
+	RootPath       ResourceLink
 	TabsGenerator  TabsGenerator
 	TabDescriptors []Tab
 }
@@ -56,6 +58,7 @@ type Object struct {
 	tabFuncDescriptors    []Tab
 	iconName              string
 	iconSource            string
+	rootPath              ResourceLink
 	tabsGenerator         TabsGenerator
 }
 
@@ -79,6 +82,7 @@ func NewObject(c ObjectConfig) *Object {
 		objectType:         c.ObjectType,
 		iconName:           c.IconName,
 		iconSource:         c.IconSource,
+		rootPath:           c.RootPath,
 		tabsGenerator:      tg,
 		tabFuncDescriptors: td,
 	}
@@ -122,7 +126,16 @@ func (d *Object) Describe(ctx context.Context, namespace string, options Options
 	accessor := meta.NewAccessor()
 	objectName, _ := accessor.Name(object)
 
-	title := append([]component.TitleComponent{}, component.NewText(d.baseTitle))
+	kind, _ := accessor.Kind(object)
+
+	nameLink, err := options.Link.ForObject(object, kind)
+
+	if err != nil {
+		return component.EmptyContentResponse, err
+	}
+
+	title := getBreadcrumb(d.rootPath, d.baseTitle, filepath.Dir(nameLink.Ref()), namespace)
+
 	if objectName != "" {
 		title = append(title, component.NewText(objectName))
 	}
diff --git a/internal/describer/objects.go b/internal/describer/objects.go
index 775a8c67..8a76744d 100644
--- a/internal/describer/objects.go
+++ b/internal/describer/objects.go
@@ -182,7 +182,8 @@ func initNamespacedOverview() *Section {
 		ObjectStoreKey: store.Key{APIVersion: "networking.k8s.io/v1", Kind: "NetworkPolicy"},
 		ListType:       &networkingv1.NetworkPolicyList{},
 		ObjectType:     &networkingv1.NetworkPolicy{},
-		Titles:         ResourceTitle{List: "Discovery & Load Balancing / Network Policies", Object: "Network Policy"},
+		Titles:         ResourceTitle{List: "Network Policies", Object: "Network Policy"},
+		RootPath:       ResourceLink{Title: "Discovery and Load Balancing", Url: "/overview/namespace/($NAMESPACE)/discovery-and-load-balancing"},
 		IconName:       icon.OverviewNetworkPolicy,
 	})
 
diff --git a/internal/describer/resource.go b/internal/describer/resource.go
index 7f4568a8..34b2c5d8 100644
--- a/internal/describer/resource.go
+++ b/internal/describer/resource.go
@@ -95,6 +95,7 @@ func (r *Resource) Object() *Object {
 			},
 			IconName:   iconName,
 			IconSource: iconSource,
+			RootPath:   r.RootPath,
 		},
 	)
 }
diff --git a/web/src/app/modules/shared/components/presentation/tabs/tabs.component.ts b/web/src/app/modules/shared/components/presentation/tabs/tabs.component.ts
index 52c92dd5..5592bb4f 100644
--- a/web/src/app/modules/shared/components/presentation/tabs/tabs.component.ts
+++ b/web/src/app/modules/shared/components/presentation/tabs/tabs.component.ts
@@ -56,8 +56,6 @@ export class TabsComponent implements OnChanges, OnInit {
     const { fragment } = this.activatedRoute.snapshot;
     if (fragment) {
       this.activeTab = fragment;
-    } else {
-      this.activeTab = this.tabs[0]?.accessor;
     }
   }
 


Test patch:
diff --git a/internal/describer/object_test.go b/internal/describer/object_test.go
index a1df1f25..7d1825d0 100644
--- a/internal/describer/object_test.go
+++ b/internal/describer/object_test.go
@@ -110,7 +110,7 @@ func TestObjectDescriber(t *testing.T) {
 			)))
 
 	expected := component.ContentResponse{
-		Title:      component.Title(component.NewText("object"), component.NewText("pod")),
+		Title:      component.Title(component.NewLink("", "object", "."), component.NewText("pod")),
 		IconName:   "icon-name",
 		IconSource: "icon-source",
 		Components: []component.Component{