From ddb730ce565634e3765787f464460f778c564ac8 Mon Sep 17 00:00:00 2001 From: wenincode Date: Thu, 25 Jan 2024 15:45:55 -0700 Subject: [PATCH] Update ui server to include V2 Catalog flag --- .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 0000000000000..d1d8f4ebc2070 --- /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 726207b148f0c..34d3a453b0fd6 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 ce649276546be..d86baf1f48f56 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{"