diff --git a/ui/app/components/global-header.js b/ui/app/components/global-header.js index 6ad560d02ac..544f60cf3e4 100644 --- a/ui/app/components/global-header.js +++ b/ui/app/components/global-header.js @@ -18,17 +18,6 @@ export default class GlobalHeader extends Component { 'data-test-global-header' = true; onHamburgerClick() {} - // Show sign-in if: - // - User can't load agent config (meaning ACLs are enabled but they're not signed in) - // - User can load agent config in and ACLs are enabled (meaning ACLs are enabled and they're signed in) - // The excluded case here is if there is both an agent config and ACLs are disabled - get shouldShowProfileNav() { - return ( - !this.system.agent?.get('config') || - this.system.agent?.get('config.ACL.Enabled') === true - ); - } - get labelStyles() { return htmlSafe( ` diff --git a/ui/app/components/profile-navbar-item.hbs b/ui/app/components/profile-navbar-item.hbs index 919d4d6d463..cf63970cc33 100644 --- a/ui/app/components/profile-navbar-item.hbs +++ b/ui/app/components/profile-navbar-item.hbs @@ -15,9 +15,19 @@ {{else}} - - Sign In - + + + {{/if}} {{yield}} diff --git a/ui/app/controllers/settings.js b/ui/app/controllers/settings.js new file mode 100644 index 00000000000..d9313bcbbc0 --- /dev/null +++ b/ui/app/controllers/settings.js @@ -0,0 +1,28 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +// @ts-check +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; +import { alias } from '@ember/object/computed'; + +export default class SettingsController extends Controller { + @service keyboard; + @service token; + @service system; + + @alias('token.selfToken') tokenRecord; + + // Show sign-in if: + // - User can't load agent config (meaning ACLs are enabled but they're not signed in) + // - User can load agent config in and ACLs are enabled (meaning ACLs are enabled and they're signed in) + // The excluded case here is if there is both an agent config and ACLs are disabled + get shouldShowProfileLink() { + return ( + !this.system.agent?.get('config') || + this.system.agent?.get('config.ACL.Enabled') === true + ); + } +} diff --git a/ui/app/controllers/settings/tokens.js b/ui/app/controllers/settings/tokens.js index 7d679606e28..74e2728f3d2 100644 --- a/ui/app/controllers/settings/tokens.js +++ b/ui/app/controllers/settings/tokens.js @@ -12,7 +12,6 @@ import { action } from '@ember/object'; import classic from 'ember-classic-decorator'; import { tracked } from '@glimmer/tracking'; import Ember from 'ember'; -import localStorageProperty from 'nomad-ui/utils/properties/local-storage'; /** * @type {RegExp} @@ -280,9 +279,4 @@ export default class Tokens extends Controller { get shouldShowPolicies() { return this.tokenRecord; } - - // #region settings - @localStorageProperty('nomadShouldWrapCode', false) wordWrap; - @localStorageProperty('nomadLiveUpdateJobsIndex', true) liveUpdateJobsIndex; - // #endregion settings } diff --git a/ui/app/controllers/settings/user-settings.js b/ui/app/controllers/settings/user-settings.js new file mode 100644 index 00000000000..e829995f709 --- /dev/null +++ b/ui/app/controllers/settings/user-settings.js @@ -0,0 +1,13 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +// @ts-check +import Controller from '@ember/controller'; +import localStorageProperty from 'nomad-ui/utils/properties/local-storage'; + +export default class SettingsUserSettingsController extends Controller { + @localStorageProperty('nomadShouldWrapCode', false) wordWrap; + @localStorageProperty('nomadLiveUpdateJobsIndex', true) liveUpdateJobsIndex; +} diff --git a/ui/app/models/job.js b/ui/app/models/job.js index a566e79a1c6..6049ceaef64 100644 --- a/ui/app/models/job.js +++ b/ui/app/models/job.js @@ -209,8 +209,6 @@ export default class Job extends Model { }; } - // console.log('allocBlocks for', this.name, 'is', allocationsOfShowableType); - return allocationsOfShowableType; } diff --git a/ui/app/router.js b/ui/app/router.js index 0d78de67faf..dde28b832bb 100644 --- a/ui/app/router.js +++ b/ui/app/router.js @@ -87,6 +87,7 @@ Router.map(function () { this.route('settings', function () { this.route('tokens'); + this.route('user-settings'); }); // if we don't include function() the outlet won't render diff --git a/ui/app/routes/settings/tokens.js b/ui/app/routes/settings/tokens.js index 89740fb5f3f..9d81828c585 100644 --- a/ui/app/routes/settings/tokens.js +++ b/ui/app/routes/settings/tokens.js @@ -9,6 +9,22 @@ import { inject as service } from '@ember/service'; export default class SettingsTokensRoute extends Route { @service store; + @service system; + @service router; + + // before model hook: if there is an agent config, and ACLs are disabled, + // guard against this route. Redirect the user to the "profile settings" page instead. + async beforeModel() { + await this.system.agent; + if ( + this.system.agent?.get('config') && + !this.system.agent?.get('config.ACL.Enabled') + ) { + this.router.transitionTo('settings.user-settings'); + return; + } + } + model() { return { authMethods: this.store.findAll('auth-method'), diff --git a/ui/app/styles/core/navbar.scss b/ui/app/styles/core/navbar.scss index f2714a71cdd..b4ee4e9f092 100644 --- a/ui/app/styles/core/navbar.scss +++ b/ui/app/styles/core/navbar.scss @@ -163,15 +163,17 @@ $secondaryNavbarHeight: 4.5rem; .profile-dropdown { padding: 0.5rem 1rem 0.5rem 0.75rem; z-index: $z-gutter; - button.hds-dropdown-toggle-icon { - border-color: var(--token-color-palette-neutral-200); - background-color: transparent; - color: var(--token-color-surface-primary); - - &.hds-dropdown-toggle-icon--is-open { - background-color: var(--token-color-surface-primary); - color: var(--token-color-foreground-primary); - } + } + + .profile-dropdown button.hds-dropdown-toggle-icon, + .profile-link .hds-button { + border-color: var(--token-color-palette-neutral-200); + background-color: transparent; + color: var(--token-color-surface-primary); + + &.hds-dropdown-toggle-icon--is-open { + background-color: var(--token-color-surface-primary); + color: var(--token-color-foreground-primary); } } diff --git a/ui/app/templates/components/global-header.hbs b/ui/app/templates/components/global-header.hbs index 095ce07a1fd..8beca5f5885 100644 --- a/ui/app/templates/components/global-header.hbs +++ b/ui/app/templates/components/global-header.hbs @@ -70,9 +70,7 @@ > Documentation - {{#if this.shouldShowProfileNav}} - - {{/if}} +