Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): Module consolidation for some test modules and reduces errors from unsupported API calls #1844

Merged
merged 2 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ export class DatasetEntity extends BaseEntity<Com.Linkedin.Dataset.Dataset> {
@reads('entity.health.score')
healthScore?: number;

/**
* Description for the dataset that contains more information about the nature of the data or metadata
*/
@oneWay('entity.dataset.description')
description?: string;

/**
* gets the dataorigin field (needed from search)
* from the urn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,10 @@ export const getRenderProps = (): IEntityRenderProps => {
},
customHeaderComponents: [
{
name: 'insight/carousel',
options: {
components: [
{
name: 'health/carousel-insight',
options: {
priority: 1
}
},
{
name: 'top-consumers/insight/top-consumers-insight',
options: {
isOptional: true,
component: 'top-consumers/insight/insight-card'
}
}
]
}
}
name: 'dynamic-components/entity/field',
options: { className: 'dataset-header__description', fieldName: 'description' }
},
{ name: 'datasets/containers/dataset-owner-list' }
]
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { Server } from 'ember-cli-mirage';
import { getApiRoot, ApiVersion } from '@datahub/utils/api/shared';
import { ownershipEndpoint } from '@datahub/data-models/api/dataset/ownership';
import { getDatasetOwnership } from '@datahub/data-models/mirage-addon/test-helpers/datasets/ownership';

import { getEntity } from '@datahub/data-models/mirage-addon/test-helpers/get-entity';
/**
* Shareable mirage/config for dependent modules
* @param {Server} server the passed in Mirage server instance in the calling test
*/
export const setup = (server: Server): void => {
server.namespace = getApiRoot(ApiVersion.v2);

server.get('/:entityType/:identifier', getEntity);
server.get(`datasets/:urn/${ownershipEndpoint}`, getDatasetOwnership);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { HandlerFunction, Schema, Request } from 'ember-cli-mirage';

interface IGetEntityParams {
entityType: keyof Schema;
identifier: string;
}
export const getEntity: HandlerFunction = function(schema: Schema, request: Request) {
const params: IGetEntityParams | undefined = (request.params as unknown) as IGetEntityParams;
const db = schema[params?.entityType];
const results = db.where({ urn: params?.identifier });

return this.serialize(results.models[0]);
};
3 changes: 2 additions & 1 deletion datahub-web/@datahub/data-models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

module.exports = {
name: require('./package').name,
isDevelopingAddon: () => true
isDevelopingAddon: () => true,
...require('../../configs/import-mirage-tree-from-addon')
};
4 changes: 2 additions & 2 deletions datahub-web/@datahub/data-models/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"ember-cli-htmlbars": "^4.2.2",
"ember-cli-typescript": "^3.1.3",
"ember-fetch": "^7.0.0",
"ember-lodash": "^4.18.0"
"ember-lodash": "^4.18.0",
"faker": "^4.1.0"
},
"devDependencies": {
"@babel/core": "^7.8.4",
Expand Down Expand Up @@ -68,7 +69,6 @@
"ember-source": "~3.16.3",
"ember-source-channel-url": "^2.0.1",
"ember-try": "^1.4.0",
"faker": "^4.1.0",
"loader.js": "^4.7.0",
"qunit-dom": "^0.9.1",
"typescript": "^3.9.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ export default class DatasetMainContainer extends Component {
/**
* Reference to the entity class for use by downstream components, for example, to access the Entity's render props
*/
entityClass: typeof DatasetEntity = DatasetEntity;
get entityClass(): typeof DatasetEntity {
return this.dataModels.getModel(DatasetEntity.displayName);
}

/**
* Indicate if the container is in a error state and what error ocurred
Expand Down Expand Up @@ -223,12 +225,12 @@ export default class DatasetMainContainer extends Component {
return entity.readPath;
}
/**
* Array of tabs that are available for this entity
* Array of tabs that are available for this entity. Is a computed property as there is a possibility the dataset
* entity is initially undefined and will be applied following first render
*/
@computed('entity')
get datasetTabs(): Array<ITabProperties> {
const { entity } = this;

if (!entity) {
return [];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
import { getDatasetEntity } from '@datahub/datasets-core/mirage-addon/helpers/get-dataset-entity';
import {
getDatasetCompliance,
postDatasetCompliance
} from '@datahub/datasets-core/mirage-addon/helpers/compliance/info';
import { getDatasetSchema } from '@datahub/datasets-core/mirage-addon/helpers/schema';
import { getDatasetComplianceSuggestions } from '@datahub/datasets-core/mirage-addon/helpers/compliance/suggestions';
import { getComplianceDataTypes } from '@datahub/datasets-core/mirage-addon/helpers/compliance/data-types';
import {
getDatasetExportPolicy,
postDatasetExportPolicy
} from '@datahub/datasets-core/mirage-addon/helpers/compliance/export-policy';
import { getDataPlatforms } from '@datahub/datasets-core/mirage-addon/helpers/platforms';
import { getDatasetOwnership } from '@datahub/datasets-core/mirage-addon/helpers/ownership';
import {
getDatasetPurgePolicy,
postDatasetPurgePolicy
} from '@datahub/datasets-core/mirage-addon/helpers/compliance/purge-policy';
import { Server } from 'ember-cli-mirage';
import { IMirageServer } from '@datahub/utils/types/vendor/ember-cli-mirage-deprecated';

Expand All @@ -25,27 +10,12 @@ export function datasetsMirageConfig(server: Server | IMirageServer): void {
server = server as IMirageServer;
server.namespace = '/api/v2';

server.get('/datasets/:urn', getDatasetEntity);

server.get('/datasets/:urn/compliance', getDatasetCompliance);
// TODO: [META-8403] Make sure the post response is sufficient for compliance entities
server.post('/datasets/:urn/compliance', postDatasetCompliance);

server.get('/datasets/:urn/compliance/suggestion', getDatasetComplianceSuggestions);

server.get('/datasets/:urn/schema', getDatasetSchema);

server.get('/datasets/:urn/exportpolicy', getDatasetExportPolicy);
server.post('/datasets/:urn/exportpolicy', postDatasetExportPolicy);

server.get('/datasets/:urn/retention', getDatasetPurgePolicy);
server.post('/datasets/:urn/retention', postDatasetPurgePolicy);
// Temporary solution as we don't need real upstreams at the moment, we just don't wnat mirage to throw
// any errors
server.get('/datasets/:urn/upstreams', () => []);

server.get('/list/compliance-data-types', getComplianceDataTypes);

server.get('/list/platforms', getDataPlatforms);

server.get(`datasets/:urn/owners`, getDatasetOwnership);
Expand Down
Loading