Skip to content

Commit

Permalink
feat(frontend): update datahub-web client UI code (datahub-project#1806)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Charlie Tran authored and arunvasudevan committed Sep 10, 2020
1 parent 6d38f5d commit 2b1efba
Show file tree
Hide file tree
Showing 2,634 changed files with 144,325 additions and 21,496 deletions.
7 changes: 7 additions & 0 deletions datahub-web/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
/bower.json.ember-try
/package.json.ember-try

# TODO [META-12204] Fix issues in datahub/pdsc that make us have to ignore the directory
# vendor generator for metadata-models TypeScript type definitions
**/@datahub/pdsc/

# generated metadata-models TypeScript type definitions
**/types/codegen/**/*.d.ts

# generated addon sources for publishing
**/@datahub/*/addon/**/*.js
**/@datahub/*/addon/**/*.js
Expand Down
28 changes: 22 additions & 6 deletions datahub-web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,32 @@ module.exports = {
'@typescript-eslint/interface-name-prefix': ['error', 'always'],
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-angle-bracket-type-assertion': 'warn',
'@typescript-eslint/array-type': ['error', 'generic'],
'@typescript-eslint/consistent-type-assertions': 'warn',
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'warn',
'@typescript-eslint/explicit-function-return-type': 'warn',
'@typescript-eslint/ban-ts-ignore': 'warn',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'prettier/prettier': ['error', { singleQuote: true, printWidth: 120 }],
'ember/no-ember-super-in-es-classes': 'error'
'ember/no-ember-super-in-es-classes': 'error',
'@datahub/no-addon-import': 'error',
'@datahub/no-linkedin-import': 'warn',
eqeqeq: ['error', 'always']
},
plugins: ['prettier', 'ember', '@typescript-eslint'],
plugins: ['prettier', 'ember', '@typescript-eslint', '@datahub'],
overrides: [
// node files
{
files: [
'**/.eslintrc.js',
'**/.template-lintrc.js',
'**/ember-cli-build.js',
'**/scripts/**/*.js',
'**/testem.js',
'**/blueprints/*/index.js',
'**/index.js',
'**/config/**/*.js',
'**/lib/*/**.js'
],
Expand All @@ -63,6 +68,17 @@ module.exports = {
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
},
{
files: [
'@linkedin/**/*.ts',
'@linkedin/**/*.js',
'packages/data-portal-internal-clone/**/*.ts',
'packages/data-portal-internal-clone/**/*.js'
],
rules: {
'@datahub/no-linkedin-import': 'off'
}
}
]
};
13 changes: 8 additions & 5 deletions datahub-web/.eslintrc.precommit.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
module.exports = {
rules: {
'@typescript-eslint/no-angle-bracket-type-assertion': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-object-literal-type-assertion': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'error'
'@typescript-eslint/no-explicit-any': 'error',
eqeqeq: ['error', 'always']
},
overrides: [
{
files: ['*-test.js', '*-test.ts', '**/mirage/**/*.ts'],
rules: {
'@typescript-eslint/no-angle-bracket-type-assertion': 'warn',
'@typescript-eslint/consistent-type-assertions': 'warn',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-object-literal-type-assertion': 'warn',
'@typescript-eslint/explicit-function-return-type': 'warn',
'@typescript-eslint/no-explicit-any': 'warn'
},
files: ['*.js'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'warn'
}
}
]
Expand Down
1 change: 1 addition & 0 deletions datahub-web/@datahub/data-models/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/.ember-cli
/.eslintignore
/.eslintrc.js
/.git/
/.gitignore
/.watchmanconfig
/.travis.yml
Expand Down
22 changes: 14 additions & 8 deletions datahub-web/@datahub/data-models/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "6"
- '10'

sudo: false
dist: trusty
Expand All @@ -26,29 +26,35 @@ jobs:

include:
# runs linting and tests with current locked deps

- stage: "Tests"
name: "Tests"
- stage: 'Tests'
name: 'Tests'
install:
- yarn install --non-interactive
script:
- yarn lint:hbs
- yarn lint:js
- yarn test

- name: "Floating Dependencies"
- name: 'Floating Dependencies'
script:
- yarn test

- stage: 'Additional Tests'
name: 'Floating Dependencies'
install:
- npm install --no-package-lock
script:
- npm test

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- stage: "Additional Tests"
env: EMBER_TRY_SCENARIO=ember-lts-2.16
- env: EMBER_TRY_SCENARIO=ember-lts-2.18
- env: EMBER_TRY_SCENARIO=ember-lts-3.8
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
- env: EMBER_TRY_SCENARIO=ember-classic

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
Expand Down
16 changes: 10 additions & 6 deletions datahub-web/@datahub/data-models/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
The MIT License (MIT)
Copyright (c) 2020 LinkedIn

Copyright (c) 2019
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

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:
http://www.apache.org/licenses/LICENSE-2.0

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
47 changes: 22 additions & 25 deletions datahub-web/@datahub/data-models/README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,48 @@
@datahub/data-models
==============================================================================
# @datahub/data-models

[Short description of the addon.]
## Compatibility

Installation
------------------------------------------------------------------------------
- Ember.js v3.8 or above
- Ember CLI v2.13 or above
- Node.js v8 or above

## Installation

```
ember install @datahub/data-models
```


Usage
------------------------------------------------------------------------------
## Usage

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


Contributing
------------------------------------------------------------------------------
## Contributing

### Installation

* `git clone <repository-url>`
* `cd @datahub/data-models`
* `yarn install`
- `git clone <repository-url>`
- `cd @datahub/data-models`
- `yarn install`

### Linting

* `yarn lint:hbs`
* `yarn lint:js`
* `yarn lint:js --fix`
- `yarn lint:hbs`
- `yarn lint:js`
- `yarn lint:js --fix`

### Running tests

* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `ember try:each` – Runs the test suite against multiple Ember versions
- `ember test` – Runs the test suite on the current Ember version
- `ember test --server` – Runs the test suite in "watch mode"
- `ember try:each` – Runs the test suite against multiple Ember versions

### Running the dummy application

* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
- `ember serve`
- Visit the dummy application at [http://localhost:4200](http://localhost:4200).

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

License
------------------------------------------------------------------------------
## License

This project is licensed under the [MIT License](LICENSE.md).
This project is licensed under the [Apache License](LICENSE.md).
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { IInstitutionalMemory } from '@datahub/metadata-types/types/aspects/institutional-memory';
import { getJSON, postJSON } from '@datahub/utils/api/fetcher';
import { ApiVersion, getApiRoot } from '@datahub/utils/api/shared';

/**
* Constructs the url for institutional memory
* @param {string} urn - the urn for the entity
*/
const institutionalMemoryByUrn = (urn: string, entityType: string): string =>
`${getApiRoot(ApiVersion.v2)}/${entityType}s/${urn}/institutionalmemory`;

/**
* Fetches the list of wiki-type url links to documents related to an entity
* @param {string} urn - urn for the entity
*/
export const readInstitutionalMemory = (
urn: string,
entityType: string
): Promise<{ elements: Array<IInstitutionalMemory> }> => getJSON({ url: institutionalMemoryByUrn(urn, entityType) });

/**
* Returns a view of the full list of wiki-type url links to documents related to an entity. This should be how the
* list appears after any changes by the user (add or delete)
* @param {string} urn - urn for the entity
* @param {Array<IInstitutionalMemory>} wikiLinks - related links snapshot
*/
export const writeInstitutionalMemory = (
urn: string,
entityType: string,
wikiLinks: Array<IInstitutionalMemory>
): Promise<void> =>
postJSON({
url: institutionalMemoryByUrn(urn, entityType),
data: { elements: wikiLinks }
});
107 changes: 107 additions & 0 deletions datahub-web/@datahub/data-models/addon/api/common/social-actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { DataModelName } from '@datahub/data-models/constants/entity';
import { getApiRoot, ApiVersion } from '@datahub/utils/api/shared';
import { getJSON, postJSON } from '@datahub/utils/api/fetcher';
import {
ILikesAspect,
ILikeAction,
IFollowsAspect,
IFollowerType
} from '@datahub/metadata-types/types/aspects/social-actions';
import { encodeUrn } from '@datahub/utils/validators/urn';

/**
* Creates a url for a specific entity by urn and the social action we are constructing
* @param {DataModelName} entityType - the type of entity for which we are making this request
* @param {string} urn - identifier for the specific entity for which we want to construct the url
* @param {string} action - the kind of action we are creating
*/
const getSocialActionsUrl = (entityType: DataModelName, urn: string, action: string): string =>
`${getApiRoot(ApiVersion.v2)}/${entityType}/${encodeUrn(urn)}/${action}`;

/**
* Using the socialActionsUrl as a base, create a function that constructs one specifically for
* like actions
* @param {DataModelName} entityType - type of entity for which we want to construct this url
* @param {string} urn - urn identifier for the specific entity for which we are constructing the url
*/
const getLikeActionsUrl = (entityType: DataModelName, urn: string): string =>
getSocialActionsUrl(entityType, urn, 'likes');

/**
* Given a Likes aspect from the backend, returns the actual like actions related to that aspect
* @param actions - the list of like actions that are retrieved from the api
*/
const getLikeActionsFromAspect = ({ actions }: ILikesAspect): Array<ILikeAction> => actions;

/**
* Given an entity type and urn, construct a getter for which to retrieve likes information
* @param {DataModelName} entityType - the type of entity for which we want to read like information
* @param {string} urn - the identifier for the entity for which we want to read like information
*/
export const readLikesForEntity = (entityType: DataModelName, urn: string): Promise<Array<ILikeAction>> =>
getJSON({ url: getLikeActionsUrl(entityType, urn) }).then(getLikeActionsFromAspect);

/**
* Given an entity type and urn, post an update request that adds the user to the list of those who
* like the specified entity
* @param {DataModelName} entityType - the type of entity for which we want to add a like
* @param {string} urn - the identifier for the entity to which to add the user's like action
* @return an updated likes aspect for the entity
*/
export const addLikeForEntity = (entityType: DataModelName, urn: string): Promise<Array<ILikeAction>> =>
postJSON({ url: `${getLikeActionsUrl(entityType, urn)}/add`, data: {} }).then(getLikeActionsFromAspect);

/**
* Given an entity type and urn, post an update request that removes the user to the list of those
* who like the specified entity
* @param {DataModelName} entityType - the type of entity for which we want to add a like
* @param {string} urn - the identifier for teh entity to which to add the user's like action
* @return an updated likes aspect for the entity
*/
export const removeLikeForEntity = (entityType: DataModelName, urn: string): Promise<Array<ILikeAction>> =>
postJSON({ url: `${getLikeActionsUrl(entityType, urn)}/remove`, data: {} }).then(getLikeActionsFromAspect);

/**
* Using the socialActionsUrl as a base, create a function that constructs one specifically for
* follow actions
* @param {DataModelName} entityType - the type of entity for which we want to construct this urn
* @param {string} urn - urn identifier for the specific entity instance for which we are
* constructing the url
*/
const getFollowActionsUrl = (entityType: DataModelName, urn: string): string =>
getSocialActionsUrl(entityType, urn, 'follows');

/**
* Given the followers aspect from the API response, provided as a convenience function we return
* objects representing the followers themselves
* @param {Array<IFollowAction>} followers - the list of followers presented as
* FollowAction objects
*/
const getFollowersFromAspect = ({ followers }: IFollowsAspect): Array<IFollowerType> =>
followers.map(({ follower }): IFollowerType => follower);

/**
* Given an entity type and urn, construct a getter for which to retrieve follows information
* @param {DataModelName} entityType - the type of entity for which we want to read follow information
* @param {string} urn - the identifier for the entity for which we want to read follow information
*/
export const readFollowsForEntity = (entityType: DataModelName, urn: string): Promise<Array<IFollowerType>> =>
getJSON({ url: getFollowActionsUrl(entityType, urn) }).then(getFollowersFromAspect);

/**
* Given an entity type and urn, construct a getter for which to add the user as a follower
* @param {DataModelName} entityType - the type of entity for which we want to add the user as a follower
* @param {string} urn - the identifier for the entity for which we want to update follow information
* @return an updated follow aspect for the entity, if successful
*/
export const addFollowForEntity = (entityType: DataModelName, urn: string): Promise<Array<IFollowerType>> =>
postJSON({ url: `${getFollowActionsUrl(entityType, urn)}/add`, data: {} }).then(getFollowersFromAspect);

/**
* Given an entity type and urn, construct a getter for which to remove the user as a follower
* @param {DataModelName} entityType - the type of entity for which we want to remove the user as a follower
* @param {string} urn - the identifier for the entity for which we want to update follow information
* @return an updated follow aspect for the entity, if successful
*/
export const removeFollowForEntity = (entityType: DataModelName, urn: string): Promise<Array<IFollowerType>> =>
postJSON({ url: `${getFollowActionsUrl(entityType, urn)}/remove`, data: {} }).then(getFollowersFromAspect);
Loading

0 comments on commit 2b1efba

Please sign in to comment.