diff --git a/ui/core/app/controllers/scopes/scope/authenticate.js b/ui/core/app/controllers/scopes/scope/authenticate.js new file mode 100644 index 000000000..b982a3c1c --- /dev/null +++ b/ui/core/app/controllers/scopes/scope/authenticate.js @@ -0,0 +1,21 @@ +import Controller from '@ember/controller'; +import { sort } from '@ember/object/computed'; + +export default class ScopesScopeAuthenticateController extends Controller { + + // =attributes + + /** + * @type {Array} + */ + @sort('model.scopes', (a, b) => { + if (a.isGlobal) { + return -1; + } else if (b.isGlobal) { + return 1; + } + return 0; + }) + sortedScopes; + +} diff --git a/ui/core/app/templates/scopes/scope/authenticate.hbs b/ui/core/app/templates/scopes/scope/authenticate.hbs index 43b329188..75a60893f 100644 --- a/ui/core/app/templates/scopes/scope/authenticate.hbs +++ b/ui/core/app/templates/scopes/scope/authenticate.hbs @@ -14,7 +14,7 @@ @text={{t "actions.choose-different-org"}} @icon="user-organization" as |dropdown|> - {{#each @model.scopes as |scope|}} + {{#each this.sortedScopes as |scope|}} {{scope.displayName}} diff --git a/ui/core/tests/unit/controllers/scopes/scope/authenticate-test.js b/ui/core/tests/unit/controllers/scopes/scope/authenticate-test.js new file mode 100644 index 000000000..41bd58b67 --- /dev/null +++ b/ui/core/tests/unit/controllers/scopes/scope/authenticate-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | scopes/scope/authenticate', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:scopes/scope/authenticate'); + assert.ok(controller); + }); +});