mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-15 10:52:41 +00:00
updates last saved by to integrate with newly added properties on GET response for owner and actor
This commit is contained in:
parent
ddb680c38b
commit
3553c95f16
@ -1,7 +1,7 @@
|
|||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import { get, set, getProperties, setProperties } from '@ember/object';
|
import { get, set, getProperties, setProperties } from '@ember/object';
|
||||||
import { task, TaskInstance } from 'ember-concurrency';
|
import { task, TaskInstance } from 'ember-concurrency';
|
||||||
import { action, computed } from '@ember-decorators/object';
|
import { action } from '@ember-decorators/object';
|
||||||
import Notifications from 'wherehows-web/services/notifications';
|
import Notifications from 'wherehows-web/services/notifications';
|
||||||
import { NotificationEvent } from 'wherehows-web/services/notifications';
|
import { NotificationEvent } from 'wherehows-web/services/notifications';
|
||||||
import { IOwner, IOwnerResponse } from 'wherehows-web/typings/api/datasets/owners';
|
import { IOwner, IOwnerResponse } from 'wherehows-web/typings/api/datasets/owners';
|
||||||
@ -69,6 +69,12 @@ export default class DatasetOwnershipContainer extends Component {
|
|||||||
*/
|
*/
|
||||||
avatarProperties: IAppConfig['userEntityProps'] | undefined;
|
avatarProperties: IAppConfig['userEntityProps'] | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata related to the ownership properties for the dataset
|
||||||
|
* @type {{ actor: string, lastModified: number }}
|
||||||
|
* @memberof DatasetOwnershipContainer
|
||||||
|
*/
|
||||||
|
ownershipMetadata: { actor: string; lastModified: number } = { actor: '', lastModified: 0 };
|
||||||
/**
|
/**
|
||||||
* An async parent task to group all data tasks for this container component
|
* An async parent task to group all data tasks for this container component
|
||||||
* @type {Task<TaskInstance<Promise<any>>, (a?: any) => TaskInstance<TaskInstance<Promise<any>>>>}
|
* @type {Task<TaskInstance<Promise<any>>, (a?: any) => TaskInstance<TaskInstance<Promise<any>>>>}
|
||||||
@ -103,34 +109,13 @@ export default class DatasetOwnershipContainer extends Component {
|
|||||||
* @type {Task<Promise<Array<IOwner>>, (a?: any) => TaskInstance<Promise<IOwnerResponse>>>}
|
* @type {Task<Promise<Array<IOwner>>, (a?: any) => TaskInstance<Promise<IOwnerResponse>>>}
|
||||||
*/
|
*/
|
||||||
getDatasetOwnersTask = task(function*(this: DatasetOwnershipContainer): IterableIterator<Promise<IOwnerResponse>> {
|
getDatasetOwnersTask = task(function*(this: DatasetOwnershipContainer): IterableIterator<Promise<IOwnerResponse>> {
|
||||||
const { owners = [], fromUpstream, datasetUrn }: IOwnerResponse = yield readDatasetOwnersByUrn(get(this, 'urn'));
|
const { owners = [], fromUpstream, datasetUrn, lastModified, actor }: IOwnerResponse = yield readDatasetOwnersByUrn(
|
||||||
|
this.urn
|
||||||
|
);
|
||||||
|
|
||||||
setProperties(this, { owners, fromUpstream, upstreamUrn: datasetUrn });
|
setProperties(this, { owners, fromUpstream, upstreamUrn: datasetUrn, ownershipMetadata: { lastModified, actor } });
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves metadata about the current ownership records including modificationTime and actor
|
|
||||||
* @readonly
|
|
||||||
* @type {(Record<'actor' | 'modificationTime', string>)}
|
|
||||||
* @memberof DatasetOwnershipContainer
|
|
||||||
*/
|
|
||||||
@computed('owners.[]')
|
|
||||||
get ownershipMetadata(): Record<'actor' | 'modificationTime', string> {
|
|
||||||
const {
|
|
||||||
owners: [owner]
|
|
||||||
} = this;
|
|
||||||
const ownershipMetadata = { actor: '', modificationTime: '' };
|
|
||||||
|
|
||||||
if (owner) {
|
|
||||||
const { confirmedBy, modifiedTime } = owner;
|
|
||||||
const modificationTime = modifiedTime ? String(modifiedTime) : '';
|
|
||||||
|
|
||||||
return { ...ownershipMetadata, actor: confirmedBy || '', modificationTime };
|
|
||||||
}
|
|
||||||
|
|
||||||
return ownershipMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the suggested owners for this dataset
|
* Fetches the suggested owners for this dataset
|
||||||
* @type {Task<Promise<Array<IOwner>>, (a?: any) => TaskInstance<Promise<IOwnerResponse>>>}
|
* @type {Task<Promise<Array<IOwner>>, (a?: any) => TaskInstance<Promise<IOwnerResponse>>>}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
@import 'owner-table';
|
@import 'owner-table';
|
||||||
@import 'dataset-author';
|
@import 'dataset-author';
|
||||||
@import 'suggested-owners';
|
@import 'suggested-owners';
|
||||||
@import 'ownership-metadata';
|
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
.ownership-metadata {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
@ -40,9 +40,3 @@
|
|||||||
color: set-color(red, red5);
|
color: set-color(red, red5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.policy-last-saved {
|
|
||||||
margin-left: auto;
|
|
||||||
text-align: right;
|
|
||||||
max-width: 300px;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -10,3 +10,9 @@
|
|||||||
margin: item-spacing(0 1);
|
margin: item-spacing(0 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.last-saved-by-container {
|
||||||
|
text-align: right;
|
||||||
|
margin-left: auto;
|
||||||
|
padding: item-spacing(3 0);
|
||||||
|
}
|
||||||
|
|||||||
@ -77,7 +77,7 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<div class="secondary-actions">
|
<div class="secondary-actions">
|
||||||
<div class="policy-last-saved">
|
<div class="last-saved-by-container">
|
||||||
{{last-saved-by actor=complianceInfo.modifiedBy time=complianceInfo.modifiedTime}}
|
{{last-saved-by actor=complianceInfo.modifiedBy time=complianceInfo.modifiedTime}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
<div class="ownership-metadata">
|
<div class="last-saved-by-container">
|
||||||
{{last-saved-by actor=ownershipMetadata.actor time=ownershipMetadata.modificationTime}}
|
{{last-saved-by actor=ownershipMetadata.actor time=ownershipMetadata.lastModified}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{dataset-authors
|
{{dataset-authors
|
||||||
|
|||||||
@ -27,6 +27,10 @@ interface IOwnerResponse {
|
|||||||
owners?: Array<IOwner>;
|
owners?: Array<IOwner>;
|
||||||
fromUpstream: boolean;
|
fromUpstream: boolean;
|
||||||
datasetUrn: string;
|
datasetUrn: string;
|
||||||
|
// date the ownership information was last modified
|
||||||
|
lastModified: number;
|
||||||
|
// entity that performed the modification
|
||||||
|
actor: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -103,14 +103,18 @@ const ownersWithModifiedTimeAsDate = arrayMap(ownerWithModifiedTimeAsDate);
|
|||||||
const readDatasetOwnersByUrn = async (urn: string): Promise<IOwnerResponse> => {
|
const readDatasetOwnersByUrn = async (urn: string): Promise<IOwnerResponse> => {
|
||||||
let owners: Array<IOwner> = [],
|
let owners: Array<IOwner> = [],
|
||||||
fromUpstream = false,
|
fromUpstream = false,
|
||||||
datasetUrn = '';
|
datasetUrn = '',
|
||||||
|
lastModified = 0,
|
||||||
|
actor = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
({ owners = [], fromUpstream, datasetUrn } = await getJSON<IOwnerResponse>({ url: datasetOwnersUrlByUrn(urn) }));
|
({ owners = [], fromUpstream, datasetUrn, actor, lastModified } = await getJSON<IOwnerResponse>({
|
||||||
return { owners: ownersWithModifiedTimeAsDate(owners), fromUpstream, datasetUrn };
|
url: datasetOwnersUrlByUrn(urn)
|
||||||
|
}));
|
||||||
|
return { owners: ownersWithModifiedTimeAsDate(owners), fromUpstream, datasetUrn, actor, lastModified };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (isNotFoundApiError(e)) {
|
if (isNotFoundApiError(e)) {
|
||||||
return { owners, fromUpstream, datasetUrn };
|
return { owners, fromUpstream, datasetUrn, actor, lastModified };
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@ -125,16 +129,18 @@ const readDatasetOwnersByUrn = async (urn: string): Promise<IOwnerResponse> => {
|
|||||||
const readDatasetSuggestedOwnersByUrn = async (urn: string): Promise<IOwnerResponse> => {
|
const readDatasetSuggestedOwnersByUrn = async (urn: string): Promise<IOwnerResponse> => {
|
||||||
let owners: Array<IOwner> = [],
|
let owners: Array<IOwner> = [],
|
||||||
fromUpstream = false,
|
fromUpstream = false,
|
||||||
datasetUrn = '';
|
datasetUrn = '',
|
||||||
|
lastModified = 0,
|
||||||
|
actor = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
({ owners = [], fromUpstream, datasetUrn } = await getJSON<IOwnerResponse>({
|
({ owners = [], fromUpstream, datasetUrn, actor, lastModified } = await getJSON<IOwnerResponse>({
|
||||||
url: datasetSuggestedOwnersUrlByUrn(urn)
|
url: datasetSuggestedOwnersUrlByUrn(urn)
|
||||||
}));
|
}));
|
||||||
return { owners: ownersWithModifiedTimeAsDate(owners), fromUpstream, datasetUrn };
|
return { owners: ownersWithModifiedTimeAsDate(owners), fromUpstream, datasetUrn, actor, lastModified };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (isNotFoundApiError(e)) {
|
if (isNotFoundApiError(e)) {
|
||||||
return { owners, fromUpstream, datasetUrn };
|
return { owners, fromUpstream, datasetUrn, actor, lastModified };
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user