Skip to content

Commit

Permalink
HAWNG-752: Adds default text for console launcher
Browse files Browse the repository at this point in the history
* Should the console launcher not have custom text specified in the CR
  populate it with default text.
  • Loading branch information
phantomjinx committed Oct 31, 2024
1 parent 9e196d9 commit e936b10
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/openshift/console_links.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
hawtiov1 "github.com/hawtio/hawtio-operator/pkg/apis/hawtio/v1"
)

// defaultConsoleLinkText Default text for console launcher link
const defaultConsoleLinkText = "HawtIO Console"

// NewApplicationMenuLink creates an ApplicationMenu ConsoleLink instance
func NewApplicationMenuLink(name string, route *routev1.Route, config *hawtiov1.HawtioConfig) *consolev1.ConsoleLink {
consoleLink := &consolev1.ConsoleLink{
Expand All @@ -31,7 +34,13 @@ func NewApplicationMenuLink(name string, route *routev1.Route, config *hawtiov1.
func UpdateApplicationMenuLink(consoleLink *consolev1.ConsoleLink, route *routev1.Route, config *hawtiov1.HawtioConfig) {
consoleLink.Spec.Location = consolev1.ApplicationMenu
consoleLink.Spec.Link.Text = config.Online.ConsoleLink.Text

if len(consoleLink.Spec.Link.Text) == 0 {
consoleLink.Spec.Link.Text = defaultConsoleLinkText
}

consoleLink.Spec.Link.Href = "https://" + route.Spec.Host

if consoleLink.Spec.ApplicationMenu == nil {
consoleLink.Spec.ApplicationMenu = &consolev1.ApplicationMenuSpec{}
}
Expand Down Expand Up @@ -63,6 +72,11 @@ func NewNamespaceDashboardLink(name string, namespace string, route *routev1.Rou
func UpdateNamespaceDashboardLink(consoleLink *consolev1.ConsoleLink, route *routev1.Route, config *hawtiov1.HawtioConfig) {
consoleLink.Spec.Location = consolev1.NamespaceDashboard
consoleLink.Spec.Link.Text = config.Online.ConsoleLink.Text

if len(consoleLink.Spec.Link.Text) == 0 {
consoleLink.Spec.Link.Text = defaultConsoleLinkText
}

consoleLink.Spec.Link.Href = "https://" + route.Spec.Host
// ApplicationMenu can be set when the Hawtio type changes from 'cluster' to 'namespace'
consoleLink.Spec.ApplicationMenu = nil
Expand Down

0 comments on commit e936b10

Please sign in to comment.