Skip to content

Commit

Permalink
Merge pull request #9876 from hashicorp/b-ui/default-namespace-casing
Browse files Browse the repository at this point in the history
UI: Use the same prefix pattern for both the region switcher and the namespace switcher
  • Loading branch information
DingoEatingFuzz committed Jan 22, 2021
2 parents cf3f8eb + ee58aea commit 6e6a162
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions ui/app/styles/components/dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
.ember-power-select-selected-item,
.dropdown-item {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}

Expand Down
7 changes: 2 additions & 5 deletions ui/app/templates/components/gutter-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,9 @@
@onChange={{action this.gotoJobsForNamespace}}
@tagName="div"
@class="namespace-switcher"
title={{this.system.activeNamespace.name}}
as |namespace|>
{{#if (eq namespace.name "default")}}
Default Namespace
{{else}}
{{namespace.name}}
{{/if}}
<span class="ember-power-select-prefix">Namespace: </span>{{namespace.name}}
</PowerSelect>
</div>
</li>
Expand Down
3 changes: 1 addition & 2 deletions ui/tests/acceptance/job-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,11 @@ module('Acceptance | job detail (with namespaces)', function(hooks) {
test('when switching namespaces, the app redirects to /jobs with the new namespace', async function(assert) {
const namespace = server.db.namespaces.find(job.namespaceId);
const otherNamespace = server.db.namespaces.toArray().find(ns => ns !== namespace).name;
const label = otherNamespace === 'default' ? 'Default Namespace' : otherNamespace;

await JobDetail.visit({ id: job.id, namespace: namespace.name });

// TODO: Migrate to Page Objects
await selectChoose('[data-test-namespace-switcher]', label);
await selectChoose('[data-test-namespace-switcher]', otherNamespace);
assert.equal(currentURL().split('?')[0], '/jobs', 'Navigated to /jobs');

const jobs = server.db.jobs
Expand Down
8 changes: 6 additions & 2 deletions ui/tests/acceptance/namespaces-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module('Acceptance | namespaces (enabled)', function(hooks) {
);
assert.equal(
JobsList.namespaceSwitcher.options.objectAt(0).label,
'Default Namespace',
'Namespace: default',
'The first namespace is always the default one'
);

Expand All @@ -79,7 +79,11 @@ module('Acceptance | namespaces (enabled)', function(hooks) {
if (index === 0) return;

const namespace = sortedNamespaces[index - 1];
assert.equal(option.label, namespace.name, `index ${index}: ${namespace.name}`);
assert.equal(
option.label,
`Namespace: ${namespace.name}`,
`index ${index}: ${namespace.name}`
);
});
});

Expand Down

0 comments on commit 6e6a162

Please sign in to comment.