Merge pull request #945 from theseyi/inactive-owners

adds support for identifying inactive owners that are included in lis…
This commit is contained in:
Seyi Adebajo 2018-01-23 17:22:53 -08:00 committed by GitHub
commit b308768c42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 21 deletions

View File

@ -1,5 +1,5 @@
import Component from '@ember/component'; import Component from '@ember/component';
import ComputedProperty, { equal } from '@ember/object/computed'; import ComputedProperty, { equal, not } from '@ember/object/computed';
import { getProperties, computed } from '@ember/object'; import { getProperties, computed } from '@ember/object';
import { assert } from '@ember/debug'; import { assert } from '@ember/debug';
@ -18,7 +18,10 @@ export default class DatasetAuthor extends Component {
classNames = ['dataset-author-record']; classNames = ['dataset-author-record'];
classNameBindings = ['isConfirmedSuggestedOwner:dataset-author-record--disabled']; classNameBindings = [
'isConfirmedSuggestedOwner:dataset-author-record--disabled',
'isOwnerInActive:dataset-author-record--inactive'
];
/** /**
* The owner record being rendered * The owner record being rendered
@ -71,23 +74,28 @@ export default class DatasetAuthor extends Component {
*/ */
isOwnerMutable: ComputedProperty<boolean> = equal('owner.source', OwnerSource.Ui); isOwnerMutable: ComputedProperty<boolean> = equal('owner.source', OwnerSource.Ui);
/**
* Negates the owner attribute flag `isActive`, indicating owner record is considered inactive
* @type {ComputedProperty<boolean>}
* @memberOf DatasetAuthor
*/
isOwnerInActive: ComputedProperty<boolean> = not('owner.isActive');
/** /**
* Determines if the owner record is a system suggested owner and if this record is confirmed by a user * Determines if the owner record is a system suggested owner and if this record is confirmed by a user
* @type {ComputedProperty<boolean>} * @type {ComputedProperty<boolean>}
* @memberof DatasetAuthor * @memberof DatasetAuthor
*/ */
isConfirmedSuggestedOwner: ComputedProperty<boolean> = computed('commonOwners', function(this: DatasetAuthor) { isConfirmedSuggestedOwner: ComputedProperty<boolean> = computed('commonOwners', function(
this: DatasetAuthor
): boolean {
const { commonOwners, isOwnerMutable, owner: { userName } } = getProperties(this, [ const { commonOwners, isOwnerMutable, owner: { userName } } = getProperties(this, [
'commonOwners', 'commonOwners',
'isOwnerMutable', 'isOwnerMutable',
'owner' 'owner'
]); ]);
if (!isOwnerMutable) { return isOwnerMutable ? false : !!commonOwners.findBy('userName', userName);
return commonOwners.findBy('userName', userName);
}
return false;
}); });
constructor() { constructor() {

View File

@ -105,7 +105,8 @@ const defaultOwnerProps: IOwner = {
sortId: 0, sortId: 0,
source: OwnerSource.Ui, source: OwnerSource.Ui,
confirmedBy: null, confirmedBy: null,
idType: OwnerIdType.User idType: OwnerIdType.User,
isActive: true
}; };
export { export {

View File

@ -1,5 +1,3 @@
$owner-list-issue-color: set-color(red, maroonflush);
.dataset-author { .dataset-author {
margin-top: item-spacing(7); margin-top: item-spacing(7);
@ -21,10 +19,20 @@ $owner-list-issue-color: set-color(red, maroonflush);
pointer-events: none; pointer-events: none;
} }
&--inactive {
text-decoration: line-through;
}
&#{&} &__action { &#{&} &__action {
&--disabled { &--disabled {
background-color: set-color(grey, mid); background-color: set-color(grey, mid);
} }
&--inactive {
background-color: set-color(red, maroonflush);
outline: none;
pointer-events: none;
}
} }
} }

View File

@ -1,6 +1,15 @@
<td> <td>
{{user-avatar userName=owner.userName}} {{user-avatar userName=owner.userName}}
{{owner.userName}} {{owner.userName}}
{{#if isOwnerInActive}}
<button class="nacho-button nacho-button--small dataset-author-record__action--inactive">
Inactive
</button>
{{/if}}
</td> </td>
<td> <td>

View File

@ -13,8 +13,8 @@
<p class="dataset-author__required-count"> <p class="dataset-author__required-count">
{{#if requiredMinNotConfirmed}} {{#if requiredMinNotConfirmed}}
Add <strong>at least {{ownersRequiredCount}}</strong> owner(s) with ID Type - <code>USER</code> Add <strong>{{ownersRequiredCount}}</strong> owner(s) with ID Type - <code>USER</code>
and Ownership Type - <code>Data Owner</code> , Ownership Type - <code>Data Owner</code>, and who is also <code>Active</code>
{{/if}} {{/if}}
</p> </p>

View File

@ -8,7 +8,7 @@ interface IOwner {
confirmedBy: null | string; confirmedBy: null | string;
email: null | string; email: null | string;
idType: OwnerIdType; idType: OwnerIdType;
isActive?: boolean; isActive: boolean;
isGroup: boolean; isGroup: boolean;
modifiedTime?: number | Date; modifiedTime?: number | Date;
name: string; name: string;

View File

@ -8,6 +8,7 @@ import {
} from 'wherehows-web/typings/api/datasets/party-entities'; } from 'wherehows-web/typings/api/datasets/party-entities';
import { IOwner, IOwnerPostResponse, IOwnerResponse } from 'wherehows-web/typings/api/datasets/owners'; import { IOwner, IOwnerPostResponse, IOwnerResponse } from 'wherehows-web/typings/api/datasets/owners';
import { getJSON, postJSON } from 'wherehows-web/utils/api/fetcher'; import { getJSON, postJSON } from 'wherehows-web/utils/api/fetcher';
import { arrayFilter } from 'wherehows-web/utils/array';
/** /**
* Defines a string enum for valid owner types * Defines a string enum for valid owner types
@ -184,14 +185,18 @@ const readPartyEntitiesMap = (partyEntities: Array<IPartyEntity>): IUserEntityMa
); );
/** /**
* Filters out a list of valid confirmed owners in a list of owners * Given an IOwner object, determines if it qualifies as a valid confirmed owner
* @param {Array<IOwner>} [owners=[]] the owners to filter * @param {IOwner}
* @returns {Array<IOwner>} * @return {boolean}
*/ */
const validConfirmedOwners = (owners: Array<IOwner> = []): Array<IOwner> => const isValidConfirmedOwner = ({ confirmedBy, type, idType, isActive }: IOwner): boolean =>
owners.filter( !!confirmedBy && type === OwnerType.Owner && idType === OwnerIdType.User && isActive;
({ confirmedBy, type, idType }) => confirmedBy && type === OwnerType.Owner && idType === OwnerIdType.User
); /**
* Filters out a list of valid confirmed owners in a list of owners
* @type {(array: Array<IOwner> = []) => Array<IOwner>}
*/
const validConfirmedOwners = arrayFilter(isValidConfirmedOwner);
/** /**
* Checks that the required minimum number of confirmed users is met with the type Owner and idType User * Checks that the required minimum number of confirmed users is met with the type Owner and idType User