From e51c18c7bc044ecf5f560a20279b6aaa8f7b8850 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Tue, 29 Oct 2024 13:58:03 +0000 Subject: [PATCH] ui: show region in header gutter when only one region exists This PR adds a plain text label of the region to the header when there is only one region present. Before, nothing was showin in this case, and a dropdown was shown on federated clusters. The use case here is for operators of multiple non-federated Nomad clusters, when all the UI's involved otherwise look identical. --- ui/app/styles/core/navbar.scss | 12 +++++++++ .../templates/components/region-switcher.hbs | 4 +++ .../unit/components/region-switcher-test.js | 25 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 ui/tests/unit/components/region-switcher-test.js diff --git a/ui/app/styles/core/navbar.scss b/ui/app/styles/core/navbar.scss index 9e9d08be16d..2906aa1ed45 100644 --- a/ui/app/styles/core/navbar.scss +++ b/ui/app/styles/core/navbar.scss @@ -142,6 +142,18 @@ $secondaryNavbarHeight: 4.5rem; display: flex; align-items: center; + &.is-region { + display: block; + padding: 0 1rem; + font-size: 1em; + color: rgba($primary-invert, 0.9); + + > span { + padding-right: 0.4em; + font-weight: 500; + } + } + &.is-gutter { width: $gutter-width; display: block; diff --git a/ui/app/templates/components/region-switcher.hbs b/ui/app/templates/components/region-switcher.hbs index 5c3eafb1e42..b7c0d9ced99 100644 --- a/ui/app/templates/components/region-switcher.hbs +++ b/ui/app/templates/components/region-switcher.hbs @@ -18,4 +18,8 @@ Region: {{region}} +{{else}} + {{/if}} diff --git a/ui/tests/unit/components/region-switcher-test.js b/ui/tests/unit/components/region-switcher-test.js new file mode 100644 index 00000000000..15a67b847ee --- /dev/null +++ b/ui/tests/unit/components/region-switcher-test.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Unit | Component | region-switcher', function (hooks) { + setupRenderingTest(hooks); + + test('displays single region', async function (assert) { + const system = { + shouldShowRegions: false, + }; + + this.set('system', system); + + await render(hbs``); + + assert.dom('.is-region').exists(); + }); +});