Charlie Tran 843a6c5bbb
feat(frontend): update datahub-web client UI code (#1806)
* 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
2020-08-26 15:44:50 -07:00

44 lines
2.2 KiB
TypeScript

import { arrayMap } from '@datahub/utils/array/index';
import { IComplianceChangeSet, ISuggestedFieldTypeValues } from 'datahub-web/typings/app/dataset-compliance';
/**
* Takes a list of suggestions with confidence values, and if the confidence is greater than
* a low confidence threshold
* @param {number} confidenceLevel percentage indicating how confidence the system is in the suggested value
* @param {number} suggestionConfidenceThreshold threshold number to consider as a valid suggestion
* @return {boolean}
*/
const isHighConfidenceSuggestion = (
{ confidenceLevel = 0 }: { confidenceLevel: number },
suggestionConfidenceThreshold = 0
): boolean => confidenceLevel > suggestionConfidenceThreshold;
/**
* Extracts the tag suggestion from an IComplianceChangeSet tag.
* If a suggestionAuthority property exists on the tag, then the user has already either accepted or ignored
* the suggestion for this tag. It's value should not be taken into account on re-renders,
* in place, this substitutes an empty suggestion
* @param {number} suggestionConfidenceThreshold confidence threshold for filtering out higher quality suggestions
* @return {(tag?: IComplianceChangeSet) => (ISuggestedFieldTypeValues | void)}
*/
const getTagSuggestions = ({ suggestionConfidenceThreshold }: { suggestionConfidenceThreshold: number }) => (
tag: IComplianceChangeSet = {} as IComplianceChangeSet
): ISuggestedFieldTypeValues | void => {
const { suggestion } = tag;
if (suggestion && isHighConfidenceSuggestion(suggestion, suggestionConfidenceThreshold)) {
const { identifierType, logicalType, confidenceLevel: confidence } = suggestion;
return { identifierType, logicalType, confidence: +(confidence * 100).toFixed(2) };
}
};
/**
* Gets the suggestions for a list of IComplianceChangeSet fields
* @param {number} suggestionConfidenceThreshold
* @return {(array: Array<IComplianceChangeSet>) => Array<ISuggestedFieldTypeValues | void>}
*/
const getTagsSuggestions = ({ suggestionConfidenceThreshold }: { suggestionConfidenceThreshold: number }) =>
arrayMap(getTagSuggestions({ suggestionConfidenceThreshold }));
export { isHighConfidenceSuggestion, getTagSuggestions, getTagsSuggestions };