Skip to content

Commit

Permalink
ui: show region in header gutter when only one region exists
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shoenig committed Oct 29, 2024
1 parent 2df473c commit e51c18c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ui/app/styles/core/navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions ui/app/templates/components/region-switcher.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@
<span class="ember-power-select-prefix">Region: </span>{{region}}
</PowerSelect>
</span>
{{else}}
<div class="navbar-item is-region">
<span>Region: </span>{{this.system.activeRegion}}
</div>
{{/if}}
25 changes: 25 additions & 0 deletions ui/tests/unit/components/region-switcher-test.js
Original file line number Diff line number Diff line change
@@ -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`<RegionSwitcher/>`);

assert.dom('.is-region').exists();
});
});

0 comments on commit e51c18c

Please sign in to comment.