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

40 lines
1.5 KiB
TypeScript

import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import DataModelsService from '@datahub/data-models/services/data-models';
import { DataModelEntityInstance } from '@datahub/data-models/constants/entity';
import { extractEntityType } from '@datahub/utils/validators/urn';
interface IGetEntityByUrnArgs {
urn: string;
}
/**
* Allows us to get an entity instance from our data model service by its urn. Helpful when we are composing templates
* and only have a urn to work with (and we may or may not know the entity type we are working with) and we want to
* abstract the concern of instantiating a model with the data models service away from the parent component.
*
* @example
* <GetEntityByUrn @urn="urn:li:dataset:someDataset" as |dataset|>
* <tr>
* <td>{{dataset.name}}</td>
* <td>{{dataset.someOtherInfo}}</td>
* </tr>
* </GetEntityByUrn>
*/
export default class GetEntityByUrn extends Component<IGetEntityByUrnArgs> {
/**
* Injects the data models service so that we can get the actual entity class/instance
*/
@service
dataModels!: DataModelsService;
/**
* Given the entity type and urn, we are able to return a partial instance
*/
get entityInstance(): DataModelEntityInstance | void {
const urn = this.args.urn;
const entityModel = this.dataModels.getModelByApiName(extractEntityType(urn) as string);
return entityModel && this.dataModels.createPartialInstance(entityModel.displayName, urn);
}
}