Charlie Tran 843a6c5bbb
feat(frontend): update datahub-web client UI code (#1806)
* Releases updated version of datahub-web client UI code

* Fix typo in yarn lock

* Change yarn lock to match yarn registry directories

* Previous commit missed some paths

* Even more changes to yarnlock missing in previous commit

* Include codegen file for typings

* Add files to get parity for datahub-web and current OS datahub-midtier

* Add in typo fix from previous commit - change to proper license

* Implement proper OS fix for person entity picture url

* Workarounds for open source DH issues

* Fixes institutional memory api and removes unopensourced tabs for datasets

* Fixes search dataset deprecation and user search issue as a result of changes

* Remove internal only options in the avatar menu
2020-08-26 15:44:50 -07:00

93 lines
2.6 KiB
TypeScript

import Component from '@ember/component';
import { get } from '@ember/object';
import { action } from '@ember/object';
import Notifications from '@datahub/utils/services/notifications';
import { updateDatasetDeprecationByUrn } from 'datahub-web/utils/api/datasets/properties';
import { inject as service } from '@ember/service';
import { NotificationEvent } from '@datahub/utils/constants/notifications';
import { DatasetEntity } from '@datahub/data-models/entity/dataset/dataset-entity';
import { alias } from '@ember/object/computed';
type DeprecationType = Exclude<Com.Linkedin.Dataset.Dataset['deprecation'], undefined>;
export default class DatasetPropertiesContainer extends Component {
/**
* The urn identifier for the dataset
* @type {string}
*/
urn: string;
/**
* DatasetEntity instace passed down from the entity-page container
*/
entity: DatasetEntity;
/**
* Flag indicating that the dataset is deprecated
*/
@alias('entity.deprecated')
deprecated: DeprecationType['deprecated'] | undefined;
/**
* Text string, intended to indicate the reason for deprecation
*/
@alias('entity.deprecationNote')
deprecationNote: DeprecationType['note'] | undefined = '';
/**
* Time when the dataset will be decommissioned
*/
@alias('entity.decommissionTime')
decommissionTime: DeprecationType['decommissionTime'] | undefined;
/**
* THe list of properties for the dataset, currently unavailable for v2
* @type {any[]}
*/
properties: Array<never> = [];
/**
* References the application notifications service
* @memberof DatasetPropertiesContainer
* @type {ComputedProperty<Notifications>}
*/
@service
notifications: Notifications;
/**
* Persists the changes to the dataset deprecation properties upstream
* @param {boolean} isDeprecated
* @param {string} updatedDeprecationNote
* @param {Date} decommissionTime dataset decommission date
* @return {Promise<void>}
*/
@action
async updateDeprecation(
this: DatasetPropertiesContainer,
isDeprecated: boolean,
updatedDeprecationNote: string,
decommissionTime: number | null
): Promise<void> {
const { notify } = get(this, 'notifications');
try {
await updateDatasetDeprecationByUrn(
get(this, 'urn'),
isDeprecated,
updatedDeprecationNote || '',
isDeprecated && decommissionTime ? decommissionTime : null
);
notify({
type: NotificationEvent.success,
content: 'Successfully updated deprecation status'
});
} catch (e) {
notify({
type: NotificationEvent.error,
content: `An error occurred: ${e.message}`
});
}
}
}