diff --git a/addons/api/addon/models/base.js b/addons/api/addon/models/base.js index 5ce5d3a8c..ee99bcaf0 100644 --- a/addons/api/addon/models/base.js +++ b/addons/api/addon/models/base.js @@ -47,6 +47,10 @@ export default class BaseModel extends Model { }) authorized_collection_actions; + get scopeModel() { + const id = this.scopeID; + return this.store.peekRecord('scope', id); + } set scopeModel(model) { if (model) { const json = model.serialize(); diff --git a/addons/api/tests/unit/models/base-test.js b/addons/api/tests/unit/models/base-test.js index 8e320cfdf..8073aae39 100644 --- a/addons/api/tests/unit/models/base-test.js +++ b/addons/api/tests/unit/models/base-test.js @@ -13,8 +13,8 @@ module('Unit | Model | base', function (hooks) { assert.ok(model); }); - test('it may have a scope fragment', function (assert) { - assert.expect(1); + test('it may have a scope fragment (and thus a scopeModel)', function (assert) { + assert.expect(2); const store = this.owner.lookup('service:store'); store.push({ data: { @@ -37,6 +37,7 @@ module('Unit | Model | base', function (hooks) { const scope = store.peekRecord('scope', 'o_1'); const model = store.peekRecord('user', '123abc'); assert.equal(model.scope.scope_id, scope.id); + assert.equal(model.scopeModel.id, scope.id); }); test('it may accept a `scopeModel` for convenience, instead of a fragment', function (assert) { diff --git a/ui/desktop/app/helpers/group-by.js b/ui/desktop/app/helpers/group-by.js new file mode 100644 index 000000000..d747eaacd --- /dev/null +++ b/ui/desktop/app/helpers/group-by.js @@ -0,0 +1,17 @@ +import { helper } from '@ember/component/helper'; + +const groupByReducer = (items, key) => { + const obj = items.reduce((result, item) => { + if (!result[item[key]]) result[item[key]] = { key: item[key], items: [] }; + result[item[key]].items.push(item); + return result; + }, {}); + // Convert object group to an array for iteration + const arr = Object.keys(obj).map((key) => obj[key]); + return arr; +}; + +export default helper(function groupBy([items, key]) { + const result = groupByReducer(items, key); + return result; +}); diff --git a/ui/desktop/app/routes/scopes/scope/projects/sessions.js b/ui/desktop/app/routes/scopes/scope/projects/sessions.js index 506af23c0..24b32931c 100644 --- a/ui/desktop/app/routes/scopes/scope/projects/sessions.js +++ b/ui/desktop/app/routes/scopes/scope/projects/sessions.js @@ -81,7 +81,7 @@ export default class ScopesScopeProjectsSessionsRoute extends Route { * When this route is activated (entered), begin polling for changes. */ activate() { - this.poller.perform(); + // this.poller.perform(); } /** diff --git a/ui/desktop/app/styles/app.scss b/ui/desktop/app/styles/app.scss index d4dcdb408..112756757 100644 --- a/ui/desktop/app/styles/app.scss +++ b/ui/desktop/app/styles/app.scss @@ -95,15 +95,22 @@ } } + .rose-icon { + margin-right: sizing.rems(xxs); + margin-left: sizing.rems(xxs); + } + .indent-label-1 { - .rose-form-radio-label { + .rose-form-radio-label, + .rose-form-checkbox-label { padding-left: $indent; } } .indent-label-2 { - .rose-form-radio-label { - padding-left: $indent + $icon-width; + .rose-form-radio-label, + .rose-form-checkbox-label { + padding-left: $indent * 1.5; } } diff --git a/ui/desktop/app/templates/scopes/scope/projects/sessions/index.hbs b/ui/desktop/app/templates/scopes/scope/projects/sessions/index.hbs index cd89ff073..8433a922d 100644 --- a/ui/desktop/app/templates/scopes/scope/projects/sessions/index.hbs +++ b/ui/desktop/app/templates/scopes/scope/projects/sessions/index.hbs @@ -59,20 +59,44 @@ @ignoreClickInside={{true}} as |dropdown| > - - - - - + + + {{! }} {{/with}} diff --git a/ui/desktop/tests/integration/helpers/group-by-test.js b/ui/desktop/tests/integration/helpers/group-by-test.js new file mode 100644 index 000000000..88b90ad02 --- /dev/null +++ b/ui/desktop/tests/integration/helpers/group-by-test.js @@ -0,0 +1,30 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, findAll } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Helper | group-by', function (hooks) { + setupRenderingTest(hooks); + + // TODO: Replace this with your real tests. + test('it renders', async function (assert) { + this.set('inputValue', [ + { group: 'a', id: '1' }, + { group: 'a', id: '2' }, + { group: 'b', id: '3' }, + { group: 'b', id: '4' }, + { group: 'c', id: '5' }, + { group: 'c', id: '6' }, + ]); + + await render(hbs` + + `); + + assert.equal(findAll('li').length, 3); + }); +});