mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-30 20:15:56 +00:00
Merge pull request #945 from theseyi/inactive-owners
adds support for identifying inactive owners that are included in lis…
This commit is contained in:
commit
b308768c42
@ -1,5 +1,5 @@
|
||||
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 { assert } from '@ember/debug';
|
||||
|
||||
@ -18,7 +18,10 @@ export default class DatasetAuthor extends Component {
|
||||
|
||||
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
|
||||
@ -71,23 +74,28 @@ export default class DatasetAuthor extends Component {
|
||||
*/
|
||||
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
|
||||
* @type {ComputedProperty<boolean>}
|
||||
* @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, [
|
||||
'commonOwners',
|
||||
'isOwnerMutable',
|
||||
'owner'
|
||||
]);
|
||||
|
||||
if (!isOwnerMutable) {
|
||||
return commonOwners.findBy('userName', userName);
|
||||
}
|
||||
|
||||
return false;
|
||||
return isOwnerMutable ? false : !!commonOwners.findBy('userName', userName);
|
||||
});
|
||||
|
||||
constructor() {
|
||||
|
@ -105,7 +105,8 @@ const defaultOwnerProps: IOwner = {
|
||||
sortId: 0,
|
||||
source: OwnerSource.Ui,
|
||||
confirmedBy: null,
|
||||
idType: OwnerIdType.User
|
||||
idType: OwnerIdType.User,
|
||||
isActive: true
|
||||
};
|
||||
|
||||
export {
|
||||
|
@ -1,5 +1,3 @@
|
||||
$owner-list-issue-color: set-color(red, maroonflush);
|
||||
|
||||
.dataset-author {
|
||||
margin-top: item-spacing(7);
|
||||
|
||||
@ -21,10 +19,20 @@ $owner-list-issue-color: set-color(red, maroonflush);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&--inactive {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
&#{&} &__action {
|
||||
&--disabled {
|
||||
background-color: set-color(grey, mid);
|
||||
}
|
||||
|
||||
&--inactive {
|
||||
background-color: set-color(red, maroonflush);
|
||||
outline: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,15 @@
|
||||
<td>
|
||||
{{user-avatar userName=owner.userName}}
|
||||
|
||||
{{owner.userName}}
|
||||
|
||||
{{#if isOwnerInActive}}
|
||||
|
||||
<button class="nacho-button nacho-button--small dataset-author-record__action--inactive">
|
||||
Inactive
|
||||
</button>
|
||||
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
@ -13,8 +13,8 @@
|
||||
<p class="dataset-author__required-count">
|
||||
{{#if requiredMinNotConfirmed}}
|
||||
|
||||
Add <strong>at least {{ownersRequiredCount}}</strong> owner(s) with ID Type - <code>USER</code>
|
||||
and Ownership Type - <code>Data Owner</code>
|
||||
Add <strong>{{ownersRequiredCount}}</strong> owner(s) with ID Type - <code>USER</code>
|
||||
, Ownership Type - <code>Data Owner</code>, and who is also <code>Active</code>
|
||||
|
||||
{{/if}}
|
||||
</p>
|
||||
|
@ -8,7 +8,7 @@ interface IOwner {
|
||||
confirmedBy: null | string;
|
||||
email: null | string;
|
||||
idType: OwnerIdType;
|
||||
isActive?: boolean;
|
||||
isActive: boolean;
|
||||
isGroup: boolean;
|
||||
modifiedTime?: number | Date;
|
||||
name: string;
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
} from 'wherehows-web/typings/api/datasets/party-entities';
|
||||
import { IOwner, IOwnerPostResponse, IOwnerResponse } from 'wherehows-web/typings/api/datasets/owners';
|
||||
import { getJSON, postJSON } from 'wherehows-web/utils/api/fetcher';
|
||||
import { arrayFilter } from 'wherehows-web/utils/array';
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param {Array<IOwner>} [owners=[]] the owners to filter
|
||||
* @returns {Array<IOwner>}
|
||||
* Given an IOwner object, determines if it qualifies as a valid confirmed owner
|
||||
* @param {IOwner}
|
||||
* @return {boolean}
|
||||
*/
|
||||
const validConfirmedOwners = (owners: Array<IOwner> = []): Array<IOwner> =>
|
||||
owners.filter(
|
||||
({ confirmedBy, type, idType }) => confirmedBy && type === OwnerType.Owner && idType === OwnerIdType.User
|
||||
);
|
||||
const isValidConfirmedOwner = ({ confirmedBy, type, idType, isActive }: IOwner): boolean =>
|
||||
!!confirmedBy && type === OwnerType.Owner && idType === OwnerIdType.User && isActive;
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user