mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-26 10:06:13 +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
57 lines
2.2 KiB
TypeScript
57 lines
2.2 KiB
TypeScript
import Route from '@ember/routing/route';
|
|
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
|
import { inject as service } from '@ember/service';
|
|
import { DataModelEntity } from '@datahub/data-models/constants/entity';
|
|
import { IDynamicLinkNode } from '@datahub/utils/types/vendor/dynamic-link';
|
|
import { capitalize } from '@ember/string';
|
|
import DataModelsService from '@datahub/data-models/services/data-models';
|
|
import { IDynamicComponent } from '@datahub/shared/types/dynamic-component';
|
|
|
|
/**
|
|
* Links for browse entity. It needs the name of the string, and also it will
|
|
* reset the queryParams (that is why `path: null`)
|
|
*/
|
|
type IBrowseEntityLink = IDynamicLinkNode<[string], 'browse.entity', { path: null }>;
|
|
|
|
/**
|
|
* model contains link for the home page cards for the different entity types
|
|
* of the app
|
|
*/
|
|
interface IBrowseIndexModel {
|
|
entities: Array<IBrowseEntityLink>;
|
|
browseHeaderComponents: Array<IDynamicComponent>;
|
|
}
|
|
|
|
export default class BrowseIndexRoute extends Route.extend(AuthenticatedRouteMixin) {
|
|
@service('data-models')
|
|
dataModels!: DataModelsService;
|
|
|
|
model(): IBrowseIndexModel {
|
|
const { dataModels } = this;
|
|
const unGuardedEntities = this.dataModels.guards.unGuardedEntities.map(
|
|
(entity): DataModelEntity => dataModels.getModel(entity.displayName)
|
|
);
|
|
const browseHeaderComponents = (unGuardedEntities
|
|
.map((entity): Array<IDynamicComponent> | undefined => entity.renderProps.browseHeaderComponents)
|
|
.filter(Boolean) as Array<Array<IDynamicComponent>>).reduce((acc, val) => acc.concat(val), []); //flat
|
|
const entities: IBrowseIndexModel['entities'] = unGuardedEntities
|
|
.filter((entity): boolean => Boolean(entity.renderProps.browse)) // filter entities that does not support browse
|
|
.map(
|
|
(entity: DataModelEntity): IBrowseEntityLink => ({
|
|
title: capitalize(entity.displayName),
|
|
text: '',
|
|
route: 'browse.entity',
|
|
model: [String(entity.displayName).toLowerCase()], // Normalize casing between BaseEntity and entityDefinition type string values
|
|
queryParams: {
|
|
path: null
|
|
}
|
|
})
|
|
);
|
|
|
|
return {
|
|
entities,
|
|
browseHeaderComponents
|
|
};
|
|
}
|
|
}
|