mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-29 10:57:52 +00:00
adds options to filter compliance entities via suggested values
This commit is contained in:
parent
b6347971fc
commit
0335078a31
@ -36,11 +36,13 @@ import {
|
||||
tagsForIdentifierField,
|
||||
overrideTagReadonly,
|
||||
editableTags,
|
||||
lowQualitySuggestionConfidenceThreshold
|
||||
lowQualitySuggestionConfidenceThreshold,
|
||||
TagFilter,
|
||||
tagSuggestionNeedsReview
|
||||
} from 'wherehows-web/constants';
|
||||
import { getTagsSuggestions } from 'wherehows-web/utils/datasets/compliance-suggestions';
|
||||
import { arrayMap, compact, isListUnique, iterateArrayAsync } from 'wherehows-web/utils/array';
|
||||
import { noop } from 'wherehows-web/utils/helpers/functions';
|
||||
import { arrayFilter, arrayMap, compact, isListUnique, iterateArrayAsync } from 'wherehows-web/utils/array';
|
||||
import { identity, noop } from 'wherehows-web/utils/helpers/functions';
|
||||
import { IComplianceDataType } from 'wherehows-web/typings/api/list/compliance-datatypes';
|
||||
import Notifications, { NotificationEvent } from 'wherehows-web/services/notifications';
|
||||
import { IDatasetColumn } from 'wherehows-web/typings/api/datasets/columns';
|
||||
@ -59,8 +61,7 @@ import {
|
||||
IDropDownOption,
|
||||
ISchemaFieldsToPolicy,
|
||||
ISchemaFieldsToSuggested,
|
||||
ISecurityClassificationOption,
|
||||
ShowAllShowReview
|
||||
ISecurityClassificationOption
|
||||
} from 'wherehows-web/typings/app/dataset-compliance';
|
||||
import { uniqBy } from 'lodash';
|
||||
import { IColumnFieldProps } from 'wherehows-web/typings/app/dataset-columns';
|
||||
@ -279,7 +280,7 @@ export default class DatasetCompliance extends Component {
|
||||
* @type {string}
|
||||
* @memberof DatasetCompliance
|
||||
*/
|
||||
fieldReviewOption: 'showReview' | 'showAll' = 'showAll';
|
||||
fieldReviewOption: TagFilter = TagFilter.showAll;
|
||||
|
||||
/**
|
||||
* Flag indicating that the component is in edit mode
|
||||
@ -494,8 +495,9 @@ export default class DatasetCompliance extends Component {
|
||||
* @memberof DatasetCompliance
|
||||
*/
|
||||
fieldReviewOptions: Array<{ value: DatasetCompliance['fieldReviewOption']; label: string }> = [
|
||||
{ value: 'showAll', label: 'Showing all fields' },
|
||||
{ value: 'showReview', label: 'Showing only fields to review' }
|
||||
{ value: TagFilter.showAll, label: 'Showing all fields' },
|
||||
{ value: TagFilter.showReview, label: 'Showing only fields to review' },
|
||||
{ value: TagFilter.showSuggested, label: 'Show suggested fields' }
|
||||
];
|
||||
|
||||
didReceiveAttrs(): void {
|
||||
@ -785,15 +787,32 @@ export default class DatasetCompliance extends Component {
|
||||
'complianceDataTypes',
|
||||
'suggestionConfidenceThreshold',
|
||||
function(this: DatasetCompliance): Array<IComplianceChangeSet> {
|
||||
/**
|
||||
* Aliases the index signature for a hash of callback functions keyed by TagFilter
|
||||
* to filter out compliance changeset items
|
||||
* @alias
|
||||
*/
|
||||
type TagFilterCallback<T = Array<IComplianceChangeSet>> = { [K in TagFilter]: (x: T) => T };
|
||||
|
||||
const {
|
||||
compliancePolicyChangeSet: changeSet,
|
||||
complianceDataTypes,
|
||||
suggestionConfidenceThreshold
|
||||
} = getProperties(this, ['compliancePolicyChangeSet', 'complianceDataTypes', 'suggestionConfidenceThreshold']);
|
||||
|
||||
return get(this, 'fieldReviewOption') === 'showReview'
|
||||
? tagsRequiringReview(complianceDataTypes, { checkSuggestions: true, suggestionConfidenceThreshold })(changeSet)
|
||||
: changeSet;
|
||||
// references the filter predicate for changeset items based on the currently set tag filter
|
||||
const changeSetFilter = (<TagFilterCallback>{
|
||||
[TagFilter.showAll]: identity,
|
||||
[TagFilter.showReview]: tagsRequiringReview(complianceDataTypes, {
|
||||
checkSuggestions: true,
|
||||
suggestionConfidenceThreshold
|
||||
}),
|
||||
[TagFilter.showSuggested]: arrayFilter((tag: IComplianceChangeSet) =>
|
||||
tagSuggestionNeedsReview({ ...tag, suggestionConfidenceThreshold })
|
||||
)
|
||||
})[get(this, 'fieldReviewOption')];
|
||||
|
||||
return changeSetFilter(changeSet);
|
||||
}
|
||||
);
|
||||
|
||||
@ -1264,10 +1283,10 @@ export default class DatasetCompliance extends Component {
|
||||
|
||||
/**
|
||||
* Updates the fieldReviewOption with the user selected value
|
||||
* @param {{value: ShowAllShowReview}} { value }
|
||||
* @returns {ShowAllShowReview}
|
||||
* @param {{value: TagFilter}} { value }
|
||||
* @returns {TagFilter}
|
||||
*/
|
||||
onFieldReviewChange(this: DatasetCompliance, { value }: { value: ShowAllShowReview }): ShowAllShowReview {
|
||||
onFieldReviewChange(this: DatasetCompliance, { value }: { value: TagFilter }): TagFilter {
|
||||
const option = set(this, 'fieldReviewOption', value);
|
||||
get(this, 'foldChangeSetTask').perform();
|
||||
|
||||
|
||||
@ -53,6 +53,16 @@ const compliancePolicyStrings = {
|
||||
const changeSetReviewableAttributeTriggers =
|
||||
'isDirty,suggestion,privacyPolicyExists,suggestionAuthority,logicalType,identifierType,nonOwner,valuePattern,readonly';
|
||||
|
||||
/**
|
||||
* Defines the available options for filtering the list of compliance entities
|
||||
* @type {string}
|
||||
*/
|
||||
enum TagFilter {
|
||||
showAll = 'show-all',
|
||||
showReview = 'show-review',
|
||||
showSuggested = 'show-suggested'
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a compliance data type and transforms it into a compliance field identifier option
|
||||
* @param {IComplianceDataType} complianceDataType
|
||||
@ -623,6 +633,8 @@ const sortFoldedChangeSetTuples = (
|
||||
const overrideTagReadonly = (tag: IComplianceChangeSet): IComplianceChangeSet =>
|
||||
setProperties(tag, { ...tag, readonly: false });
|
||||
|
||||
export { TagFilter };
|
||||
|
||||
export {
|
||||
suggestedIdentifierTypesInList,
|
||||
compliancePolicyStrings,
|
||||
@ -634,6 +646,7 @@ export {
|
||||
isAutoGeneratedPolicy,
|
||||
removeReadonlyAttr,
|
||||
tagNeedsReview,
|
||||
tagSuggestionNeedsReview,
|
||||
isTagIdType,
|
||||
mergeComplianceEntitiesWithSuggestions,
|
||||
isRecentSuggestion,
|
||||
|
||||
@ -150,7 +150,7 @@
|
||||
{{#if
|
||||
(and row.suggestion (and (not row.suggestionMatchesCurrentValue) (not row.suggestionResolution)))}}
|
||||
|
||||
<span class="nacho-tooltip" title="Has suggestions">
|
||||
<span class="nacho-tooltip" data-title="Has suggestions">
|
||||
<i class="fa fa-exclamation dataset-compliance-fields__has-suggestions__icon"
|
||||
title="Compliance field has suggested values"></i>
|
||||
</span>
|
||||
@ -159,14 +159,14 @@
|
||||
|
||||
{{#if row.isReviewRequested}}
|
||||
|
||||
<span class="nacho-tooltip" title="Please review">
|
||||
<span class="nacho-tooltip" data-title="Please review">
|
||||
<i class="fa fa-question dataset-compliance-fields--review-required__icon"
|
||||
title="Compliance policy information needs review"></i>
|
||||
</span>
|
||||
|
||||
{{else}}
|
||||
|
||||
<span class="nacho-tooltip" title="All good!">
|
||||
<span class="nacho-tooltip" data-title="All good!">
|
||||
<i class="fa fa-check dataset-compliance-fields--ok__icon" title="All good!"></i>
|
||||
</span>
|
||||
|
||||
@ -401,7 +401,7 @@
|
||||
{{/basic-dropdown}}
|
||||
|
||||
{{#if (and isEditing (not row.hasSingleTag))}}
|
||||
<span class="nacho-tooltip" title="Delete Tag">
|
||||
<span class="nacho-tooltip" data-title="Delete Tag">
|
||||
<button class="nacho-button nacho-button--tertiary dataset-compliance-fields__remove-tag"
|
||||
onclick={{action row.onRemoveFieldTag tag}}>
|
||||
{{fa-icon "trash"}}
|
||||
@ -426,7 +426,7 @@
|
||||
{{tag.identifierType}}{{if tag.logicalType (concat " (" tag.logicalType ")")}}
|
||||
|
||||
{{#if row.isReadonly}}
|
||||
<span class="nacho-tooltip" title="Readonly">
|
||||
<span class="nacho-tooltip" data-title="Readonly">
|
||||
<button class="nacho-button nacho-button--tertiary dataset-compliance-fields--readonly__icon"
|
||||
disabled={{not isEditing}}
|
||||
onclick={{action row.onEditReadonlyTag tag}}>
|
||||
|
||||
@ -145,14 +145,8 @@ type IComplianceFieldFormatOption = IDropDownOption<IdLogicalType | null>;
|
||||
*/
|
||||
type ISecurityClassificationOption = IDropDownOption<Classification | null>;
|
||||
|
||||
/**
|
||||
* Defines the applicable string values for compliance fields drop down filter
|
||||
*/
|
||||
type ShowAllShowReview = 'showReview' | 'showAll';
|
||||
|
||||
export {
|
||||
IComplianceChangeSet,
|
||||
ShowAllShowReview,
|
||||
IDatasetComplianceActions,
|
||||
IComplianceEntityWithMetadata,
|
||||
ISchemaFieldsToPolicy,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user