Skip to content

Commit 59aaacf

Browse files
author
cptran777
committed
Releases updated version of datahub-web client UI code
1 parent a13c1e1 commit 59aaacf

File tree

2,628 files changed

+60207
-21536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,628 files changed

+60207
-21536
lines changed

datahub-web/.eslintignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
/bower.json.ember-try
2323
/package.json.ember-try
2424

25+
# TODO [META-12204] Fix issues in datahub/pdsc that make us have to ignore the directory
26+
# vendor generator for metadata-models TypeScript type definitions
27+
**/@datahub/pdsc/
28+
29+
# generated metadata-models TypeScript type definitions
30+
**/types/codegen/**/*.d.ts
31+
2532
# generated addon sources for publishing
2633
**/@datahub/*/addon/**/*.js
2734
**/@datahub/*/addon/**/*.js

datahub-web/.eslintrc.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,32 @@ module.exports = {
2828
'@typescript-eslint/interface-name-prefix': ['error', 'always'],
2929
'@typescript-eslint/member-delimiter-style': 'error',
3030
'@typescript-eslint/no-empty-interface': 'error',
31-
'@typescript-eslint/no-angle-bracket-type-assertion': 'warn',
32-
'@typescript-eslint/array-type': ['error', 'generic'],
31+
'@typescript-eslint/consistent-type-assertions': 'warn',
32+
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
3333
'@typescript-eslint/no-non-null-assertion': 'warn',
3434
'@typescript-eslint/explicit-member-accessibility': 'off',
3535
'@typescript-eslint/no-parameter-properties': 'off',
36-
'@typescript-eslint/no-object-literal-type-assertion': 'warn',
3736
'@typescript-eslint/explicit-function-return-type': 'warn',
37+
'@typescript-eslint/ban-ts-ignore': 'warn',
38+
'@typescript-eslint/no-empty-function': 'warn',
3839
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
3940
'prettier/prettier': ['error', { singleQuote: true, printWidth: 120 }],
40-
'ember/no-ember-super-in-es-classes': 'error'
41+
'ember/no-ember-super-in-es-classes': 'error',
42+
'@datahub/no-addon-import': 'error',
43+
'@datahub/no-linkedin-import': 'warn',
44+
eqeqeq: ['error', 'always']
4145
},
42-
plugins: ['prettier', 'ember', '@typescript-eslint'],
46+
plugins: ['prettier', 'ember', '@typescript-eslint', '@datahub'],
4347
overrides: [
4448
// node files
4549
{
4650
files: [
4751
'**/.eslintrc.js',
4852
'**/.template-lintrc.js',
4953
'**/ember-cli-build.js',
54+
'**/scripts/**/*.js',
5055
'**/testem.js',
51-
'**/blueprints/*/index.js',
56+
'**/index.js',
5257
'**/config/**/*.js',
5358
'**/lib/*/**.js'
5459
],
@@ -63,6 +68,17 @@ module.exports = {
6368
rules: {
6469
'@typescript-eslint/no-var-requires': 'off'
6570
}
71+
},
72+
{
73+
files: [
74+
'@linkedin/**/*.ts',
75+
'@linkedin/**/*.js',
76+
'packages/data-portal-internal-clone/**/*.ts',
77+
'packages/data-portal-internal-clone/**/*.js'
78+
],
79+
rules: {
80+
'@datahub/no-linkedin-import': 'off'
81+
}
6682
}
6783
]
6884
};

datahub-web/.eslintrc.precommit.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
module.exports = {
22
rules: {
3-
'@typescript-eslint/no-angle-bracket-type-assertion': 'error',
3+
'@typescript-eslint/consistent-type-assertions': 'error',
44
'@typescript-eslint/no-non-null-assertion': 'error',
5-
'@typescript-eslint/no-object-literal-type-assertion': 'error',
65
'@typescript-eslint/explicit-function-return-type': 'error',
7-
'@typescript-eslint/no-explicit-any': 'error'
6+
'@typescript-eslint/no-explicit-any': 'error',
7+
eqeqeq: ['error', 'always']
88
},
99
overrides: [
1010
{
1111
files: ['*-test.js', '*-test.ts', '**/mirage/**/*.ts'],
1212
rules: {
13-
'@typescript-eslint/no-angle-bracket-type-assertion': 'warn',
13+
'@typescript-eslint/consistent-type-assertions': 'warn',
1414
'@typescript-eslint/no-non-null-assertion': 'warn',
15-
'@typescript-eslint/no-object-literal-type-assertion': 'warn',
1615
'@typescript-eslint/explicit-function-return-type': 'warn',
1716
'@typescript-eslint/no-explicit-any': 'warn'
17+
},
18+
files: ['*.js'],
19+
rules: {
20+
'@typescript-eslint/explicit-function-return-type': 'warn'
1821
}
1922
}
2023
]

datahub-web/@datahub/data-models/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/.ember-cli
1212
/.eslintignore
1313
/.eslintrc.js
14+
/.git/
1415
/.gitignore
1516
/.watchmanconfig
1617
/.travis.yml

datahub-web/@datahub/data-models/.travis.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: node_js
33
node_js:
44
# we recommend testing addons with the same minimum supported node version as Ember CLI
55
# so that your addon works for all apps
6-
- "6"
6+
- '10'
77

88
sudo: false
99
dist: trusty
@@ -26,29 +26,35 @@ jobs:
2626

2727
include:
2828
# runs linting and tests with current locked deps
29-
30-
- stage: "Tests"
31-
name: "Tests"
29+
- stage: 'Tests'
30+
name: 'Tests'
3231
install:
3332
- yarn install --non-interactive
3433
script:
3534
- yarn lint:hbs
3635
- yarn lint:js
3736
- yarn test
3837

39-
- name: "Floating Dependencies"
38+
- name: 'Floating Dependencies'
4039
script:
4140
- yarn test
4241

42+
- stage: 'Additional Tests'
43+
name: 'Floating Dependencies'
44+
install:
45+
- npm install --no-package-lock
46+
script:
47+
- npm test
48+
4349
# we recommend new addons test the current and previous LTS
4450
# as well as latest stable release (bonus points to beta/canary)
45-
- stage: "Additional Tests"
46-
env: EMBER_TRY_SCENARIO=ember-lts-2.16
47-
- env: EMBER_TRY_SCENARIO=ember-lts-2.18
51+
- env: EMBER_TRY_SCENARIO=ember-lts-3.8
52+
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
4853
- env: EMBER_TRY_SCENARIO=ember-release
4954
- env: EMBER_TRY_SCENARIO=ember-beta
5055
- env: EMBER_TRY_SCENARIO=ember-canary
5156
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
57+
- env: EMBER_TRY_SCENARIO=ember-classic
5258

5359
before_install:
5460
- curl -o- -L https://yarnpkg.com/install.sh | bash

datahub-web/@datahub/data-models/LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019
3+
Copyright (c) 2020
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,48 @@
1-
@datahub/data-models
2-
==============================================================================
1+
# @datahub/data-models
32

4-
[Short description of the addon.]
3+
## Compatibility
54

6-
Installation
7-
------------------------------------------------------------------------------
5+
- Ember.js v3.8 or above
6+
- Ember CLI v2.13 or above
7+
- Node.js v8 or above
8+
9+
## Installation
810

911
```
1012
ember install @datahub/data-models
1113
```
1214

13-
14-
Usage
15-
------------------------------------------------------------------------------
15+
## Usage
1616

1717
[Longer description of how to use the addon in apps.]
1818

19-
20-
Contributing
21-
------------------------------------------------------------------------------
19+
## Contributing
2220

2321
### Installation
2422

25-
* `git clone <repository-url>`
26-
* `cd @datahub/data-models`
27-
* `yarn install`
23+
- `git clone <repository-url>`
24+
- `cd @datahub/data-models`
25+
- `yarn install`
2826

2927
### Linting
3028

31-
* `yarn lint:hbs`
32-
* `yarn lint:js`
33-
* `yarn lint:js --fix`
29+
- `yarn lint:hbs`
30+
- `yarn lint:js`
31+
- `yarn lint:js --fix`
3432

3533
### Running tests
3634

37-
* `ember test` – Runs the test suite on the current Ember version
38-
* `ember test --server` – Runs the test suite in "watch mode"
39-
* `ember try:each` – Runs the test suite against multiple Ember versions
35+
- `ember test` – Runs the test suite on the current Ember version
36+
- `ember test --server` – Runs the test suite in "watch mode"
37+
- `ember try:each` – Runs the test suite against multiple Ember versions
4038

4139
### Running the dummy application
4240

43-
* `ember serve`
44-
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
41+
- `ember serve`
42+
- Visit the dummy application at [http://localhost:4200](http://localhost:4200).
4543

4644
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
4745

48-
License
49-
------------------------------------------------------------------------------
46+
## License
5047

5148
This project is licensed under the [MIT License](LICENSE.md).
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { IInstitutionalMemory } from '@datahub/metadata-types/types/aspects/institutional-memory';
2+
import { getJSON, postJSON } from '@datahub/utils/api/fetcher';
3+
import buildUrl from '@datahub/utils/api/build-url';
4+
import { ApiVersion, getApiRoot } from '@datahub/utils/api/shared';
5+
6+
/**
7+
* Constructs the url for institutional memory
8+
* @param {string} urn - the urn for the entity
9+
*/
10+
const institutionalMemoryByUrn = (urn: string, entityType: string): string =>
11+
buildUrl(`${getApiRoot(ApiVersion.v2)}/institutionalmemory`, { urn, type: entityType });
12+
13+
/**
14+
* Fetches the list of wiki-type url links to documents related to an entity
15+
* @param {string} urn - urn for the entity
16+
*/
17+
export const readInstitutionalMemory = (
18+
urn: string,
19+
entityType: string
20+
): Promise<{ elements: Array<IInstitutionalMemory> }> => getJSON({ url: institutionalMemoryByUrn(urn, entityType) });
21+
22+
/**
23+
* Returns a view of the full list of wiki-type url links to documents related to an entity. This should be how the
24+
* list appears after any changes by the user (add or delete)
25+
* @param {string} urn - urn for the entity
26+
* @param {Array<IInstitutionalMemory>} wikiLinks - related links snapshot
27+
*/
28+
export const writeInstitutionalMemory = (
29+
urn: string,
30+
entityType: string,
31+
wikiLinks: Array<IInstitutionalMemory>
32+
): Promise<void> =>
33+
postJSON({
34+
url: institutionalMemoryByUrn(urn, entityType),
35+
data: { elements: wikiLinks }
36+
});
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { DataModelName } from '@datahub/data-models/constants/entity';
2+
import { getApiRoot, ApiVersion } from '@datahub/utils/api/shared';
3+
import { getJSON, postJSON } from '@datahub/utils/api/fetcher';
4+
import {
5+
ILikesAspect,
6+
ILikeAction,
7+
IFollowsAspect,
8+
IFollowerType
9+
} from '@datahub/metadata-types/types/aspects/social-actions';
10+
import { encodeUrn } from '@datahub/utils/validators/urn';
11+
12+
/**
13+
* Creates a url for a specific entity by urn and the social action we are constructing
14+
* @param {DataModelName} entityType - the type of entity for which we are making this request
15+
* @param {string} urn - identifier for the specific entity for which we want to construct the url
16+
* @param {string} action - the kind of action we are creating
17+
*/
18+
const getSocialActionsUrl = (entityType: DataModelName, urn: string, action: string): string =>
19+
`${getApiRoot(ApiVersion.v2)}/${entityType}/${encodeUrn(urn)}/${action}`;
20+
21+
/**
22+
* Using the socialActionsUrl as a base, create a function that constructs one specifically for
23+
* like actions
24+
* @param {DataModelName} entityType - type of entity for which we want to construct this url
25+
* @param {string} urn - urn identifier for the specific entity for which we are constructing the url
26+
*/
27+
const getLikeActionsUrl = (entityType: DataModelName, urn: string): string =>
28+
getSocialActionsUrl(entityType, urn, 'likes');
29+
30+
/**
31+
* Given a Likes aspect from the backend, returns the actual like actions related to that aspect
32+
* @param actions - the list of like actions that are retrieved from the api
33+
*/
34+
const getLikeActionsFromAspect = ({ actions }: ILikesAspect): Array<ILikeAction> => actions;
35+
36+
/**
37+
* Given an entity type and urn, construct a getter for which to retrieve likes information
38+
* @param {DataModelName} entityType - the type of entity for which we want to read like information
39+
* @param {string} urn - the identifier for the entity for which we want to read like information
40+
*/
41+
export const readLikesForEntity = (entityType: DataModelName, urn: string): Promise<Array<ILikeAction>> =>
42+
getJSON({ url: getLikeActionsUrl(entityType, urn) }).then(getLikeActionsFromAspect);
43+
44+
/**
45+
* Given an entity type and urn, post an update request that adds the user to the list of those who
46+
* like the specified entity
47+
* @param {DataModelName} entityType - the type of entity for which we want to add a like
48+
* @param {string} urn - the identifier for the entity to which to add the user's like action
49+
* @return an updated likes aspect for the entity
50+
*/
51+
export const addLikeForEntity = (entityType: DataModelName, urn: string): Promise<Array<ILikeAction>> =>
52+
postJSON({ url: `${getLikeActionsUrl(entityType, urn)}/add`, data: {} }).then(getLikeActionsFromAspect);
53+
54+
/**
55+
* Given an entity type and urn, post an update request that removes the user to the list of those
56+
* who like the specified entity
57+
* @param {DataModelName} entityType - the type of entity for which we want to add a like
58+
* @param {string} urn - the identifier for teh entity to which to add the user's like action
59+
* @return an updated likes aspect for the entity
60+
*/
61+
export const removeLikeForEntity = (entityType: DataModelName, urn: string): Promise<Array<ILikeAction>> =>
62+
postJSON({ url: `${getLikeActionsUrl(entityType, urn)}/remove`, data: {} }).then(getLikeActionsFromAspect);
63+
64+
/**
65+
* Using the socialActionsUrl as a base, create a function that constructs one specifically for
66+
* follow actions
67+
* @param {DataModelName} entityType - the type of entity for which we want to construct this urn
68+
* @param {string} urn - urn identifier for the specific entity instance for which we are
69+
* constructing the url
70+
*/
71+
const getFollowActionsUrl = (entityType: DataModelName, urn: string): string =>
72+
getSocialActionsUrl(entityType, urn, 'follows');
73+
74+
/**
75+
* Given the followers aspect from the API response, provided as a convenience function we return
76+
* objects representing the followers themselves
77+
* @param {Array<IFollowAction>} followers - the list of followers presented as
78+
* FollowAction objects
79+
*/
80+
const getFollowersFromAspect = ({ followers }: IFollowsAspect): Array<IFollowerType> =>
81+
followers.map(({ follower }): IFollowerType => follower);
82+
83+
/**
84+
* Given an entity type and urn, construct a getter for which to retrieve follows information
85+
* @param {DataModelName} entityType - the type of entity for which we want to read follow information
86+
* @param {string} urn - the identifier for the entity for which we want to read follow information
87+
*/
88+
export const readFollowsForEntity = (entityType: DataModelName, urn: string): Promise<Array<IFollowerType>> =>
89+
getJSON({ url: getFollowActionsUrl(entityType, urn) }).then(getFollowersFromAspect);
90+
91+
/**
92+
* Given an entity type and urn, construct a getter for which to add the user as a follower
93+
* @param {DataModelName} entityType - the type of entity for which we want to add the user as a follower
94+
* @param {string} urn - the identifier for the entity for which we want to update follow information
95+
* @return an updated follow aspect for the entity, if successful
96+
*/
97+
export const addFollowForEntity = (entityType: DataModelName, urn: string): Promise<Array<IFollowerType>> =>
98+
postJSON({ url: `${getFollowActionsUrl(entityType, urn)}/add`, data: {} }).then(getFollowersFromAspect);
99+
100+
/**
101+
* Given an entity type and urn, construct a getter for which to remove the user as a follower
102+
* @param {DataModelName} entityType - the type of entity for which we want to remove the user as a follower
103+
* @param {string} urn - the identifier for the entity for which we want to update follow information
104+
* @return an updated follow aspect for the entity, if successful
105+
*/
106+
export const removeFollowForEntity = (entityType: DataModelName, urn: string): Promise<Array<IFollowerType>> =>
107+
postJSON({ url: `${getFollowActionsUrl(entityType, urn)}/remove`, data: {} }).then(getFollowersFromAspect);

0 commit comments

Comments
 (0)