diff --git a/wherehows-web/app/components/dataset-author.ts b/wherehows-web/app/components/dataset-author.ts index 6c26b71503..ff20d5da09 100644 --- a/wherehows-web/app/components/dataset-author.ts +++ b/wherehows-web/app/components/dataset-author.ts @@ -6,6 +6,7 @@ import { assert } from '@ember/debug'; import { IOwner } from 'wherehows-web/typings/api/datasets/owners'; import { OwnerSource, OwnerType } from 'wherehows-web/utils/api/datasets/owners'; import { action } from '@ember-decorators/object'; +import { OwnerWithAvatarRecord } from 'wherehows-web/typings/app/datasets/owners'; /** * This component renders a single owner record and also provides functionality for interacting with the component @@ -26,10 +27,10 @@ export default class DatasetAuthor extends Component { /** * The owner record being rendered - * @type {IOwner} + * @type {OwnerWithAvatarRecord} * @memberof DatasetAuthor */ - owner: IOwner; + owner: OwnerWithAvatarRecord; /** * List of suggested owners that have been confirmed by a user @@ -73,14 +74,14 @@ export default class DatasetAuthor extends Component { * @type {ComputedProperty} * @memberof DatasetAuthor */ - isOwnerMutable: ComputedProperty = equal('owner.source', OwnerSource.Ui); + isOwnerMutable: ComputedProperty = equal('owner.owner.source', OwnerSource.Ui); /** * Negates the owner attribute flag `isActive`, indicating owner record is considered inactive * @type {ComputedProperty} * @memberOf DatasetAuthor */ - isOwnerInActive: ComputedProperty = not('owner.isActive'); + isOwnerInActive: ComputedProperty = not('owner.owner.isActive'); /** * Determines if the owner record is a system suggested owner and if this record is confirmed by a user @@ -93,7 +94,9 @@ export default class DatasetAuthor extends Component { const { commonOwners, isOwnerMutable, - owner: { userName } + owner: { + owner: { userName } + } } = getProperties(this, ['commonOwners', 'isOwnerMutable', 'owner']); return isOwnerMutable ? false : !!commonOwners.findBy('userName', userName); @@ -123,7 +126,7 @@ export default class DatasetAuthor extends Component { @action onRemoveOwner(): boolean | void | IOwner { const { owner, isOwnerMutable, removeOwner } = getProperties(this, ['owner', 'isOwnerMutable', 'removeOwner']); - return isOwnerMutable && removeOwner(owner); + return isOwnerMutable && removeOwner(owner.owner); } /** @@ -133,7 +136,7 @@ export default class DatasetAuthor extends Component { @action confirmOwner(): Array | void { const { owner, confirmSuggestedOwner } = getProperties(this, ['owner', 'confirmSuggestedOwner']); - return confirmSuggestedOwner(owner); + return confirmSuggestedOwner(owner.owner); } /** @@ -149,6 +152,6 @@ export default class DatasetAuthor extends Component { 'updateOwnerType' ]); - return isOwnerMutable && updateOwnerType(owner, type); + return isOwnerMutable && updateOwnerType(owner.owner, type); } } diff --git a/wherehows-web/app/components/dataset-authors.ts b/wherehows-web/app/components/dataset-authors.ts index a14e49d802..c045de4bfa 100644 --- a/wherehows-web/app/components/dataset-authors.ts +++ b/wherehows-web/app/components/dataset-authors.ts @@ -175,7 +175,7 @@ export default class DatasetAuthors extends Component { const { avatarProperties } = this; return { - ...owner, + owner, avatar: avatarProperties ? getAvatarProps(avatarProperties)({ userName: owner.userName }) : { imageUrl: '', imageUrlFallback: '/assets/assets/images/default_avatar.png' } @@ -266,8 +266,10 @@ export default class DatasetAuthors extends Component { */ @action addOwner(this: DatasetAuthors, newOwner: IOwner): Array | void { - const owners = get(this, 'owners') || []; - const { notify } = get(this, 'notifications'); + const { + owners = [], + notifications: { notify } + } = this; if (ownerAlreadyExists(owners, { userName: newOwner.userName, source: newOwner.source })) { return void notify(NotificationEvent.info, { content: 'Owner has already been added to "confirmed" list' }); diff --git a/wherehows-web/app/templates/components/dataset-author.hbs b/wherehows-web/app/templates/components/dataset-author.hbs index 672294b6e7..c317c791ac 100644 --- a/wherehows-web/app/templates/components/dataset-author.hbs +++ b/wherehows-web/app/templates/components/dataset-author.hbs @@ -1,75 +1,76 @@ - - {{#unless isOwnerInActive}} - {{avatars/avatar-image avatar=@owner.avatar}} - {{/unless}} - - {{@owner.userName}} - - {{#if isOwnerInActive}} - - - Inactive - - - {{/if}} - - - - {{@owner.name}} - - - - {{@owner.idType}} - - -{{!-- hides source column for confirmed owners--}} -{{#unless isOwnerMutable}} - +{{#let @owner.owner as |ownerRecord|}} - {{@owner.source}} + {{#unless isOwnerInActive}} + {{avatars/avatar-image avatar=@owner.avatar}} + {{/unless}} + + {{ownerRecord.userName}} + + {{#if isOwnerInActive}} + + + Inactive + + + {{/if}} -{{/unless}} + + {{ownerRecord.name}} + - - {{ember-selector - class=(unless isOwnerMutable "nacho-select--hidden-state") - values=ownerTypes - selected=@owner.type - disabled=(not isOwnerMutable) - selectionDidChange=(action "changeOwnerType") - }} - + + {{ownerRecord.idType}} + - - {{#if isOwnerMutable}} + {{!-- hides source column for confirmed owners--}} + {{#unless isOwnerMutable}} - + + {{ownerRecord.source}} + - {{else}} + {{/unless}} - {{#if isConfirmedSuggestedOwner}} + + {{ember-selector + class=(unless isOwnerMutable "nacho-select--hidden-state") + values=ownerTypes + selected=ownerRecord.type + disabled=(not isOwnerMutable) + selectionDidChange=(action "changeOwnerType") + }} + - - Added - + + {{#if isOwnerMutable}} + + {{else}} - + {{#if isConfirmedSuggestedOwner}} + + + Added + + + {{else}} + + + + {{/if}} {{/if}} - - {{/if}} - - + +{{/let}} diff --git a/wherehows-web/app/templates/components/dataset-authors.hbs b/wherehows-web/app/templates/components/dataset-authors.hbs index 0987575b59..6df0c5c9eb 100644 --- a/wherehows-web/app/templates/components/dataset-authors.hbs +++ b/wherehows-web/app/templates/components/dataset-authors.hbs @@ -35,8 +35,8 @@ - {{#each confirmedOwnersWithAvatars as |confirmedOwnerWithAvatar|}} - + + {{#each confirmedOwnersWithAvatars as |confirmedOwnerWithAvatar|}} {{dataset-author owner=confirmedOwnerWithAvatar ownerTypes=ownerTypes @@ -44,8 +44,8 @@ confirmSuggestedOwner=(action "confirmSuggestedOwner") updateOwnerType=(action "updateOwnerType") }} - - {{/each}} + {{/each}} + diff --git a/wherehows-web/app/templates/components/datasets/owners/suggested-owner-card.hbs b/wherehows-web/app/templates/components/datasets/owners/suggested-owner-card.hbs index 3ddaa2c3cf..a0a8eff080 100644 --- a/wherehows-web/app/templates/components/datasets/owners/suggested-owner-card.hbs +++ b/wherehows-web/app/templates/components/datasets/owners/suggested-owner-card.hbs @@ -1,28 +1,30 @@ -
-
- {{avatars/avatar-image avatar=@owner.avatar class="suggested-owner-card__owner-info__profile__pic"}} +{{#let @owner.owner as |ownerRecord|}} +
+
+ {{avatars/avatar-image avatar=@owner.avatar class="suggested-owner-card__owner-info__profile__pic"}} -
-
- {{@owner.name}} -
-

- {{@owner.userName}} -

+
+
+ {{ownerRecord.name}} +
+

+ {{ownerRecord.userName}} +

+
-
-
- {{#if isConfirmedSuggestedOwner}} - {{fa-icon "check-circle-o" title="Added Owner" size="2"}} - Added - {{else}} - - {{/if}} -
-
-
- Source: {{@owner.source}} -
\ No newline at end of file +
+ {{#if isConfirmedSuggestedOwner}} + {{fa-icon "check-circle-o" title="Added Owner" size="2"}} + Added + {{else}} + + {{/if}} +
+
+
+ Source: {{ownerRecord.source}} +
+{{/let}} \ No newline at end of file diff --git a/wherehows-web/app/typings/app/datasets/owners.d.ts b/wherehows-web/app/typings/app/datasets/owners.d.ts index dd249585d9..d1159088d3 100644 --- a/wherehows-web/app/typings/app/datasets/owners.d.ts +++ b/wherehows-web/app/typings/app/datasets/owners.d.ts @@ -6,6 +6,6 @@ import { IAvatar } from 'wherehows-web/typings/app/avatars'; * @type OwnerWithAvatarRecord * @alias */ -type OwnerWithAvatarRecord = IOwner & Record<'avatar', IAvatar>; +type OwnerWithAvatarRecord = Record<'owner', IOwner> & Record<'avatar', IAvatar>; export { OwnerWithAvatarRecord }; diff --git a/wherehows-web/tests/integration/components/dataset-author-test.js b/wherehows-web/tests/integration/components/dataset-author-test.js index ea28f46231..ff9fb55e40 100644 --- a/wherehows-web/tests/integration/components/dataset-author-test.js +++ b/wherehows-web/tests/integration/components/dataset-author-test.js @@ -17,7 +17,7 @@ module('Integration | Component | dataset author', function(hooks) { test('it renders', async function(assert) { this.set('removeOwner', noop); this.set('confirmSuggestedOwner', noop); - this.set('author', confirmedOwner); + this.set('author', { owner: confirmedOwner }); this.set('commonOwners', commonOwners); await render( @@ -36,7 +36,7 @@ module('Integration | Component | dataset author', function(hooks) { assert.equal(removeActionCallCount, 1, 'action is called once'); }); this.set('confirmSuggestedOwner', noop); - this.set('author', confirmedOwner); + this.set('author', { owner: confirmedOwner }); this.set('commonOwners', commonOwners); await render( @@ -57,7 +57,7 @@ module('Integration | Component | dataset author', function(hooks) { confirmSuggestedOwnerActionCallCount++; assert.equal(confirmSuggestedOwnerActionCallCount, 1, 'action is called once'); }); - this.set('author', suggestedOwner); + this.set('author', { owner: suggestedOwner }); this.set('commonOwners', commonOwners); await render( @@ -78,7 +78,7 @@ module('Integration | Component | dataset author', function(hooks) { assert.ok(confirmedOwner === owner, 'updateOwnerType action is invoked correct owner reference'); assert.equal(type, confirmedOwner.type, 'updateOwnerType action is invoked with selected type'); }); - this.set('author', confirmedOwner); + this.set('author', { owner: confirmedOwner }); this.set('commonOwners', commonOwners); this.set('ownerTypes', ownerTypes); diff --git a/wherehows-web/tests/integration/components/datasets/owners/suggested-owner-card-test.js b/wherehows-web/tests/integration/components/datasets/owners/suggested-owner-card-test.js index 82b66d2d20..3aba92f2a6 100644 --- a/wherehows-web/tests/integration/components/datasets/owners/suggested-owner-card-test.js +++ b/wherehows-web/tests/integration/components/datasets/owners/suggested-owner-card-test.js @@ -23,7 +23,7 @@ module('Integration | Component | datasets/owners/suggested owner card', functio test('it renders for base and empty cases', async function(assert) { this.setProperties({ commonOwners, - author: {}, + author: { owner: {} }, ownerTypes: [], removeOwner: noop, confirmSuggestedOwner: noop @@ -49,7 +49,7 @@ module('Integration | Component | datasets/owners/suggested owner card', functio this.setProperties({ ownerTypes, commonOwners, - author: model, + author: { owner: model }, removeOwner: noop, confirmSuggestedOwner: noop }); @@ -79,7 +79,7 @@ module('Integration | Component | datasets/owners/suggested owner card', functio this.setProperties({ ownerTypes, commonOwners, - author: model, + author: { owner: model }, removeOwner: noop, confirmSuggestedOwner: owner => { assert.equal(owner.name, model.name, 'Passes the correct information to the confirmOwner function');