From 7e08d8988c7f466428a5378703c892a3e729691c Mon Sep 17 00:00:00 2001 From: Tyler Wendlandt Date: Fri, 26 Jan 2024 14:38:51 -0700 Subject: [PATCH] NET-5398: Update UI server to include if v2 is enabled (#20353) * Update ui server to include V2 Catalog flag * Fix typo --- .changelog/20353.txt | 3 ++ agent/uiserver/ui_template_data.go | 9 ++++ agent/uiserver/uiserver_test.go | 48 ++++++++++++++++--- .../consul-ui/app/utils/get-environment.js | 8 ++++ ui/packages/consul-ui/config/environment.js | 3 ++ .../lib/startup/templates/body.html.js | 2 +- .../node-tests/config/environment.js | 4 ++ 7 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 .changelog/20353.txt diff --git a/.changelog/20353.txt b/.changelog/20353.txt new file mode 100644 index 0000000000..d1d8f4ebc2 --- /dev/null +++ b/.changelog/20353.txt @@ -0,0 +1,3 @@ +```release-note:feature +ui: adds V2CatalogEnabled to config that is passed to the ui +``` diff --git a/agent/uiserver/ui_template_data.go b/agent/uiserver/ui_template_data.go index 726207b148..34d3a453b0 100644 --- a/agent/uiserver/ui_template_data.go +++ b/agent/uiserver/ui_template_data.go @@ -31,6 +31,14 @@ func uiTemplateDataFromConfig(cfg *config.RuntimeConfig) (map[string]interface{} uiCfg["metrics_provider_options"] = json.RawMessage(cfg.UIConfig.MetricsProviderOptionsJSON) } + v2CatalogEnabled := false + for _, experiment := range cfg.Experiments { + if experiment == "resource-apis" { + v2CatalogEnabled = true + break + } + } + d := map[string]interface{}{ "ContentPath": cfg.UIConfig.ContentPath, "ACLsEnabled": cfg.ACLsEnabled, @@ -39,6 +47,7 @@ func uiTemplateDataFromConfig(cfg *config.RuntimeConfig) (map[string]interface{} "LocalDatacenter": cfg.Datacenter, "PrimaryDatacenter": cfg.PrimaryDatacenter, "PeeringEnabled": cfg.PeeringEnabled, + "V2CatalogEnabled": v2CatalogEnabled, } // Also inject additional provider scripts if needed, otherwise strip the diff --git a/agent/uiserver/uiserver_test.go b/agent/uiserver/uiserver_test.go index ce64927654..d86baf1f48 100644 --- a/agent/uiserver/uiserver_test.go +++ b/agent/uiserver/uiserver_test.go @@ -51,7 +51,8 @@ func TestUIServerIndex(t *testing.T) { "metrics_provider": "", "metrics_proxy_enabled": false, "dashboard_url_templates": null - } + }, + "V2CatalogEnabled": false }`, }, { @@ -90,7 +91,8 @@ func TestUIServerIndex(t *testing.T) { }, "metrics_proxy_enabled": false, "dashboard_url_templates": null - } + }, + "V2CatalogEnabled": false }`, }, { @@ -111,7 +113,8 @@ func TestUIServerIndex(t *testing.T) { "metrics_provider": "", "metrics_proxy_enabled": false, "dashboard_url_templates": null - } + }, + "V2CatalogEnabled": false }`, }, { @@ -132,7 +135,30 @@ func TestUIServerIndex(t *testing.T) { "metrics_provider": "", "metrics_proxy_enabled": false, "dashboard_url_templates": null - } + }, + "V2CatalogEnabled": false + }`, + }, + { + name: "v2 catalog enabled", + cfg: basicUIEnabledConfig(withV2CatalogEnabled()), + path: "/", + wantStatus: http.StatusOK, + wantContains: []string{"