Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable nested navigation templating. #240

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions api/v1alpha1/frontend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type WidgetEntry struct {
Defaults WidgetDefaults `json:"defaults" yaml:"defaults"`
}

type NavigationSegment struct {
type BundleSegment struct {
SegmentID string `json:"segmentId" yaml:"segmentId"`
// Id of the bundle to which the segment should be injected
BundleID string `json:"bundleId" yaml:"bundleId"`
Expand All @@ -103,6 +103,11 @@ type NavigationSegment struct {
NavItems *[]ChromeNavItem `json:"navItems" yaml:"navItems"`
}

type NavigationSegment struct {
SegmentID string `json:"segmentId" yaml:"segmentId"`
NavItems *[]ChromeNavItem `json:"navItems" yaml:"navItems"`
}

// FrontendSpec defines the desired state of Frontend
type FrontendSpec struct {
Disabled bool `json:"disabled,omitempty" yaml:"disabled,omitempty"`
Expand All @@ -117,6 +122,7 @@ type FrontendSpec struct {
Module *FedModule `json:"module,omitempty" yaml:"module,omitempty"`
NavItems []*BundleNavItem `json:"navItems,omitempty" yaml:"navItems,omitempty"`
// navigation segments for the frontend
BundleSegments []*BundleSegment `json:"bundleSegments,omitempty" yaml:"bundleSegments,omitempty"`
NavigationSegments []*NavigationSegment `json:"navigationSegments,omitempty" yaml:"navigationSegments,omitempty"`
AssetsPrefix string `json:"assetsPrefix,omitempty" yaml:"assetsPrefix,omitempty"`
// Akamai cache bust opt-out
Expand Down Expand Up @@ -201,13 +207,18 @@ type Permission struct {
Args *apiextensions.JSON `json:"args,omitempty" yaml:"args,omitempty"` // TODO validate array item type (string?)
}

type SegmentRef struct {
FrontendName string `json:"frontendName" yaml:"frontendName"`
SegmentID string `json:"segmentId" yaml:"segmentId"`
}

type ChromeNavItem struct {
IsHidden bool `json:"isHidden,omitempty" yaml:"isHidden,omitempty"`
Expandable bool `json:"expandable,omitempty" yaml:"expandable,omitempty"`
Href string `json:"href,omitempty" yaml:"href,omitempty"`
AppID string `json:"appId,omitempty" yaml:"appId,omitempty"`
IsExternal bool `json:"isExternal,omitempty" yaml:"isExternal,omitempty"`
Title string `json:"title" yaml:"title"`
Title string `json:"title,omitempty" yaml:"title,omitempty"`
GroupID string `json:"groupId,omitempty" yaml:"groupId,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Product string `json:"product,omitempty" yaml:"product,omitempty"`
Expand All @@ -222,6 +233,23 @@ type ChromeNavItem struct {
// +kubebuilder:validation:Schemaless
Routes []ChromeNavItem `json:"routes,omitempty" yaml:"routes,omitempty"`
Permissions []Permission `json:"permissions,omitempty" yaml:"permissions,omitempty"`
SegmentRef *SegmentRef `json:"segmentRef,omitempty" yaml:"segmentRef,omitempty"`
}

func (navItem ChromeNavItem) HasSegmentRef() bool {
return navItem.SegmentRef != nil
}

func (navItem ChromeNavItem) IsValidNavItem() bool {
return navItem.Title != "" && navItem.Href != ""
}

func (navItem ChromeNavItem) IsExpandable() bool {
return navItem.Expandable && navItem.Routes != nil
}

func (navItem ChromeNavItem) IsGroup() bool {
return navItem.GroupID != "" && navItem.NavItems != nil
}

// +kubebuilder:object:root=true
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/frontendenvironment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ type FrontendBundles struct {

// The frontend bundles but with the nav items filled with chrome nav items
type FrontendBundlesGenerated struct {
ID string `json:"id" yaml:"id"`
Title string `json:"title" yaml:"title"`
NavItems *[]ChromeNavItem `json:"navItems" yaml:"navItems"`
ID string `json:"id" yaml:"id"`
Title string `json:"title" yaml:"title"`
NavItems []ChromeNavItem `json:"navItems" yaml:"navItems"`
}

type FrontendServiceCategoryGroup struct {
Expand Down
67 changes: 60 additions & 7 deletions api/v1alpha1/zz_generated.deepcopy.go

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

24 changes: 20 additions & 4 deletions config/crd/bases/cloud.redhat.com_bundles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,18 @@ spec:
type: string
routes:
x-kubernetes-preserve-unknown-fields: true
segmentRef:
properties:
frontendName:
type: string
segmentId:
type: string
required:
- frontendName
- segmentId
type: object
title:
type: string
required:
- title
type: object
type: array
envName:
Expand Down Expand Up @@ -147,10 +155,18 @@ spec:
type: string
routes:
x-kubernetes-preserve-unknown-fields: true
segmentRef:
properties:
frontendName:
type: string
segmentId:
type: string
required:
- frontendName
- segmentId
type: object
title:
type: string
required:
- title
type: object
required:
- name
Expand Down
108 changes: 93 additions & 15 deletions config/crd/bases/cloud.redhat.com_frontends.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,89 @@ spec:
type: array
assetsPrefix:
type: string
bundleSegments:
description: navigation segments for the frontend
items:
properties:
bundleId:
description: Id of the bundle to which the segment should be
injected
type: string
navItems:
items:
properties:
appId:
type: string
expandable:
type: boolean
groupId:
type: string
href:
type: string
icon:
type: string
id:
type: string
isBeta:
type: boolean
isExternal:
type: boolean
isHidden:
type: boolean
navItems:
description: kubebuilder struggles validating recursive
fields, it has to be helped a bit
x-kubernetes-preserve-unknown-fields: true
notifier:
type: string
permissions:
items:
properties:
apps:
items:
type: string
type: array
args:
x-kubernetes-preserve-unknown-fields: true
method:
type: string
required:
- method
type: object
type: array
product:
type: string
routes:
x-kubernetes-preserve-unknown-fields: true
segmentRef:
properties:
frontendName:
type: string
segmentId:
type: string
required:
- frontendName
- segmentId
type: object
title:
type: string
type: object
type: array
position:
description: |-
A position of the segment within the bundle
0 is the first position
The position "steps" should be at least 100 to make sure there is enough space in case some segments should be injected between existing ones
type: integer
segmentId:
type: string
required:
- bundleId
- navItems
- position
- segmentId
type: object
type: array
deploymentRepo:
type: string
disabled:
Expand Down Expand Up @@ -311,13 +394,8 @@ spec:
type: object
type: array
navigationSegments:
description: navigation segments for the frontend
items:
properties:
bundleId:
description: Id of the bundle to which the segment should be
injected
type: string
navItems:
items:
properties:
Expand Down Expand Up @@ -364,24 +442,24 @@ spec:
type: string
routes:
x-kubernetes-preserve-unknown-fields: true
segmentRef:
properties:
frontendName:
type: string
segmentId:
type: string
required:
- frontendName
- segmentId
type: object
title:
type: string
required:
- title
type: object
type: array
position:
description: |-
A position of the segment within the bundle
0 is the first position
The position "steps" should be at least 100 to make sure there is enough space in case some segments should be injected between existing ones
type: integer
segmentId:
type: string
required:
- bundleId
- navItems
- position
- segmentId
type: object
type: array
Expand Down
Loading
Loading