Skip to content

Commit

Permalink
Duplicate position to nav items from nav segments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Dec 3, 2024
1 parent 32ffd08 commit e56da3a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions config/crd/bases/cloud.redhat.com_bundles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ spec:
- method
type: object
type: array
position:
description: Position argument inherited from the segment, needed
for sooth transition between old a new system and for proper
developer experience
type: integer
product:
type: string
routes:
Expand Down Expand Up @@ -143,6 +148,11 @@ spec:
- method
type: object
type: array
position:
description: Position argument inherited from the segment,
needed for sooth transition between old a new system and
for proper developer experience
type: integer
product:
type: string
routes:
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/cloud.redhat.com_frontends.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ spec:
- method
type: object
type: array
position:
description: Position argument inherited from the segment,
needed for sooth transition between old a new system
and for proper developer experience
type: integer
product:
type: string
routes:
Expand Down
8 changes: 7 additions & 1 deletion controllers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/generate-bundles/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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":[]}]

0 comments on commit e56da3a

Please sign in to comment.