From 76da554a63fead6e4bd2aec9455ae9fa3868bfaa Mon Sep 17 00:00:00 2001 From: Yan Zhan Date: Wed, 25 Sep 2024 15:42:17 -0500 Subject: [PATCH] add support for navbar customization --- manifests/init.pp | 3 +++ manifests/navbar.pp | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 manifests/navbar.pp diff --git a/manifests/init.pp b/manifests/init.pp index e23c4eb..348d6b3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -27,6 +27,9 @@ include apache::mod::authz_user include letsencrypt include openondemand + include stdlib + + include profile_ondemand::navbar if $enable_xdmod_export { include profile_ondemand::xdmod_export diff --git a/manifests/navbar.pp b/manifests/navbar.pp new file mode 100644 index 0000000..4cdc16b --- /dev/null +++ b/manifests/navbar.pp @@ -0,0 +1,56 @@ +# @summary Configure the navigation bar for OOD +# +# @param include_default +# Whether to include the default navbar items. Defaults to true +# +# @param navbar_items +# Array of items to put in the navbar (left side) +# +# @param helpbar_items +# Array of items to put in the helpbar (right side) +# +class profile_ondemand::navbar ( + Boolean $include_default = true, + Optional[Array[Hash]] $navbar_items = undef, + Optional[Array[Hash]] $helpbar_items = undef, +) { + if $include_default { + $_content = { + nav_bar => [ + 'apps', + 'files', + 'jobs', + 'clusters', + 'interactive apps', + ] + + pick($navbar_items, []) + + [ + 'sessions', + ], + help_bar => pick($helpbar_items, []) + [ + 'develop', + 'help', + 'user', + 'logout', + ], + } + } else { + if ! $navbar_items and ! $helpbar_items { + err('Open OnDemand has an empty navigation bar!') + } + $_content = { + nav_bar => pick($navbar_items, []), + help_bar => pick($helpbar_items, []), + } + } + + file { '/etc/ood/config/ondemand.d/custom-navbar.yml': + ensure => 'file', + mode => '0644', + content => join([ + '# File managed by Puppet - DO NOT EDIT', + to_yaml($_content), + '', + ], "\n"), + } +}