mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-11 10:46:52 +00:00

* 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
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import Component from '@glimmer/component';
|
|
import { IHydrateEntity } from '@datahub/data-models/types/entity/rendering/page-components';
|
|
import { DataModelEntityInstance, DataModelName } from '@datahub/data-models/constants/entity';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
import DataModelsService from '@datahub/data-models/services/data-models';
|
|
import { ETaskPromise } from '@datahub/utils/types/concurrency';
|
|
import { task } from 'ember-concurrency';
|
|
import { set } from '@ember/object';
|
|
|
|
interface IEntityPageContentHydrateEntityArgs {
|
|
// Dehydrated entity
|
|
entity: DataModelEntityInstance;
|
|
// Child component that will receive
|
|
options: IHydrateEntity['options'];
|
|
}
|
|
|
|
/**
|
|
* This component will create an entity given an entity... wait what? The problem is that
|
|
* sometimes entity intances are not completely instatiated (with all props). This class will act as
|
|
* a simple container calling DataModels and instanciating a complete instance.
|
|
*/
|
|
export default class EntityPageContentHydrateEntity extends Component<IEntityPageContentHydrateEntityArgs> {
|
|
/**
|
|
* Data Models service to hydrate entities
|
|
*/
|
|
@service('data-models')
|
|
dataModels!: DataModelsService;
|
|
|
|
/**
|
|
* Output of this component
|
|
*/
|
|
hydratedEntity!: DataModelEntityInstance;
|
|
|
|
/**
|
|
* Task that will hydrate the entity by calling create instance
|
|
*/
|
|
@(task(function*(this: EntityPageContentHydrateEntity): IterableIterator<Promise<DataModelEntityInstance>> {
|
|
const { entity } = this.args;
|
|
const { dataModels } = this;
|
|
|
|
if (entity && entity.urn) {
|
|
const hydratedEntity = yield dataModels.createInstance(
|
|
entity.staticInstance.displayName as DataModelName,
|
|
entity.urn
|
|
);
|
|
set(this, 'hydratedEntity', (hydratedEntity as unknown) as DataModelEntityInstance);
|
|
}
|
|
}).restartable())
|
|
hydrateEntityTask!: ETaskPromise<void>;
|
|
|
|
/**
|
|
* Will invoke hydrateEntityTask upon creation
|
|
* @param owner passthrough to parent
|
|
* @param args passthrough to parent
|
|
*/
|
|
constructor(owner: unknown, args: IEntityPageContentHydrateEntityArgs) {
|
|
super(owner, args);
|
|
|
|
this.hydrateEntityTask.perform();
|
|
}
|
|
}
|