diff --git a/api/v1alpha1/frontend_types.go b/api/v1alpha1/frontend_types.go index b63f6466..7a729dd9 100644 --- a/api/v1alpha1/frontend_types.go +++ b/api/v1alpha1/frontend_types.go @@ -222,7 +222,7 @@ type ChromeNavItem struct { // +kubebuilder:validation:Schemaless Routes []ChromeNavItem `json:"routes,omitempty" yaml:"routes,omitempty"` Permissions []Permission `json:"permissions,omitempty" yaml:"permissions,omitempty"` - // Position argument inherited from the segment, needed for sooth transition between old a new system and for proper developer experience + // Position argument inherited from the segment, needed for smooth transition between old a new system and for proper developer experience Position *uint `json:"position,omitempty" yaml:"position,omitempty"` } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index ebb66322..bae993db 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -247,6 +247,11 @@ func (in *ChromeNavItem) DeepCopyInto(out *ChromeNavItem) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.Position != nil { + in, out := &in.Position, &out.Position + *out = new(uint) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChromeNavItem. diff --git a/config/crd/bases/cloud.redhat.com_bundles.yaml b/config/crd/bases/cloud.redhat.com_bundles.yaml index ed6e103a..17b69b4a 100644 --- a/config/crd/bases/cloud.redhat.com_bundles.yaml +++ b/config/crd/bases/cloud.redhat.com_bundles.yaml @@ -85,6 +85,11 @@ spec: - method type: object type: array + position: + description: Position argument inherited from the segment, needed + for smooth transition between old a new system and for proper + developer experience + type: integer product: type: string routes: @@ -143,6 +148,11 @@ spec: - method type: object type: array + position: + description: Position argument inherited from the segment, + needed for smooth transition between old a new system + and for proper developer experience + type: integer product: type: string routes: diff --git a/config/crd/bases/cloud.redhat.com_frontends.yaml b/config/crd/bases/cloud.redhat.com_frontends.yaml index 5dc591c4..45e30a51 100644 --- a/config/crd/bases/cloud.redhat.com_frontends.yaml +++ b/config/crd/bases/cloud.redhat.com_frontends.yaml @@ -360,6 +360,11 @@ spec: - method type: object type: array + position: + description: Position argument inherited from the segment, + needed for smooth transition between old a new system + and for proper developer experience + type: integer product: type: string routes: diff --git a/controllers/reconcile.go b/controllers/reconcile.go index 565ca579..cdc84d54 100644 --- a/controllers/reconcile.go +++ b/controllers/reconcile.go @@ -1020,7 +1020,13 @@ func setupBundlesData(feList *crd.FrontendList, feEnvironment crd.FrontendEnviro }) navItems := []crd.ChromeNavItem{} for _, navSegment := range bundleNavSegmentMap[bundle.ID] { - navItems = append(navItems, *navSegment.NavItems...) + for _, navItem := range *navSegment.NavItems { + // duplicate position for further consumption on the frontend + // need a new variable for position to avoid pointer reference issues + pos := navSegment.Position + navItem.Position = &pos + navItems = append(navItems, navItem) + } } newBundle := crd.FrontendBundlesGenerated{ ID: bundle.ID, diff --git a/deploy.yml b/deploy.yml index 92b678ad..32f8d477 100644 --- a/deploy.yml +++ b/deploy.yml @@ -104,6 +104,11 @@ objects: - method type: object type: array + position: + description: Position argument inherited from the segment, + needed for smooth transition between old a new system and + for proper developer experience + type: integer product: type: string routes: @@ -162,6 +167,11 @@ objects: - method type: object type: array + position: + description: Position argument inherited from the segment, + needed for smooth transition between old a new system + and for proper developer experience + type: integer product: type: string routes: @@ -778,6 +788,11 @@ objects: - method type: object type: array + position: + description: Position argument inherited from the segment, + needed for smooth transition between old a new system + and for proper developer experience + type: integer product: type: string routes: diff --git a/tests/e2e/generate-bundles/02-assert.yaml b/tests/e2e/generate-bundles/02-assert.yaml index 498b9d2a..b1cc2d34 100644 --- a/tests/e2e/generate-bundles/02-assert.yaml +++ b/tests/e2e/generate-bundles/02-assert.yaml @@ -50,8 +50,8 @@ data: {"landing-page":{"manifestLocation":"/apps/landing-page/fed-mods.json","moduleID":"landing-page","fullProfile":false}} bundles.json: >- [{"id":"rhel","title":"Red Hat Enterprise Linux","navItems":[{"href":"/apps/landing","title":"Landing - section A","id":"landing"},{"href":"/apps/landing","title":"Landing section B","id":"landing"},{"href":"/apps/landing","title":"Landing - section c","id":"landing"},{"expandable":true,"title":"Some new link","id":"bar","routes":[{"href":"/nested/bar","title":"Foo","id":"foo"}]},{"href":"/baz","title":"Some - new link","id":"baz"},{"href":"/apps/landing","title":"Landing section D","id":"landing"},{"href":"/apps/landing","title":"Landing - section last","id":"landing2"},{"expandable":true,"title":"Some new link","id":"bar2","routes":[{"href":"/nested/bar","title":"Foo","id":"foo"}]},{"href":"/baz","title":"Some - new link","id":"baz2"}]},{"id":"ansible","title":"Ansible","navItems":[]},{"id":"settings","title":"Settings","navItems":[]}] + section A","id":"landing","position":100},{"href":"/apps/landing","title":"Landing section B","id":"landing","position":100},{"href":"/apps/landing","title":"Landing + section c","id":"landing","position":100},{"expandable":true,"title":"Some new link","id":"bar","routes":[{"href":"/nested/bar","title":"Foo","id":"foo"}],"position":100},{"href":"/baz","title":"Some + new link","id":"baz","position":100},{"href":"/apps/landing","title":"Landing section D","id":"landing","position":100},{"href":"/apps/landing","title":"Landing + section last","id":"landing2","position":200},{"expandable":true,"title":"Some new link","id":"bar2","routes":[{"href":"/nested/bar","title":"Foo","id":"foo"}],"position":200},{"href":"/baz","title":"Some + new link","id":"baz2","position":200}]},{"id":"ansible","title":"Ansible","navItems":[]},{"id":"settings","title":"Settings","navItems":[]}]