mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-03 12:16:10 +00:00
adds function to derive disabled or enabled security classification options based on pii info. depends selectcted security classification dropdown option for schemaless datasets on pii toggle. removes static list of security dropdown options from schemaless and schema datasets compliance forms
This commit is contained in:
parent
29f1d23d63
commit
0cc73216a5
@ -4,7 +4,7 @@ import ComputedProperty, { gt, not, or } from '@ember/object/computed';
|
||||
import { run, schedule } from '@ember/runloop';
|
||||
import { inject } from '@ember/service';
|
||||
import { classify } from '@ember/string';
|
||||
import { IFieldIdentifierOption } from 'wherehows-web/constants/dataset-compliance';
|
||||
import { IFieldIdentifierOption, ISecurityClassificationOption } from 'wherehows-web/constants/dataset-compliance';
|
||||
import { Classification } from 'wherehows-web/constants/datasets/compliance';
|
||||
import { IDatasetView } from 'wherehows-web/typings/api/datasets/dataset';
|
||||
import { IDataPlatform } from 'wherehows-web/typings/api/list/platforms';
|
||||
@ -12,7 +12,7 @@ import { readPlatforms } from 'wherehows-web/utils/api/list/platforms';
|
||||
|
||||
import isTrackingHeaderField from 'wherehows-web/utils/validators/tracking-headers';
|
||||
import {
|
||||
securityClassificationDropdownOptions,
|
||||
getSecurityClassificationDropDownOptions,
|
||||
DatasetClassifiers,
|
||||
getFieldIdentifierOptions,
|
||||
getDefaultSecurityClassification,
|
||||
@ -248,7 +248,7 @@ export default class DatasetCompliance extends ObservableDecorator {
|
||||
complianceDataTypes: Array<IComplianceDataType>;
|
||||
|
||||
// Map of classifiers options for drop down
|
||||
classifiers = securityClassificationDropdownOptions;
|
||||
classifiers: Array<ISecurityClassificationOption> = getSecurityClassificationDropDownOptions();
|
||||
|
||||
/**
|
||||
* Default to show all fields to review
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Component from '@ember/component';
|
||||
import { get } from '@ember/object';
|
||||
import { ISecurityClassificationOption, securityClassificationDropdownOptions } from 'wherehows-web/constants';
|
||||
import { get, computed } from '@ember/object';
|
||||
import { getSecurityClassificationDropDownOptions, ISecurityClassificationOption } from 'wherehows-web/constants';
|
||||
|
||||
export default class SchemalessTagging extends Component {
|
||||
classNames = ['schemaless-tagging'];
|
||||
@ -31,7 +31,11 @@ export default class SchemalessTagging extends Component {
|
||||
* @type {Array<ISecurityClassificationOption>}
|
||||
* @memberof SchemalessTagging
|
||||
*/
|
||||
classifiers: Array<ISecurityClassificationOption> = securityClassificationDropdownOptions;
|
||||
classifiers = computed('containsPersonalData', function(
|
||||
this: SchemalessTagging
|
||||
): Array<ISecurityClassificationOption> {
|
||||
return getSecurityClassificationDropDownOptions(get(this, 'containsPersonalData'));
|
||||
});
|
||||
|
||||
/**
|
||||
* Flag indicating if this component should be in edit mode or readonly
|
||||
@ -54,6 +58,10 @@ export default class SchemalessTagging extends Component {
|
||||
* @returns boolean
|
||||
*/
|
||||
onPersonalDataToggle(this: SchemalessTagging, containsPersonalDataTag: boolean) {
|
||||
if (containsPersonalDataTag) {
|
||||
this.actions.onSecurityClassificationChange.call(this, { value: null });
|
||||
}
|
||||
|
||||
return get(this, 'onPersonalDataChange')(containsPersonalDataTag);
|
||||
},
|
||||
|
||||
@ -62,7 +70,10 @@ export default class SchemalessTagging extends Component {
|
||||
* @param {ISecurityClassificationOption} { value } security Classification value for the dataset
|
||||
* @returns null | Classification
|
||||
*/
|
||||
onSecurityClassificationChange(this: SchemalessTagging, { value }: ISecurityClassificationOption) {
|
||||
onSecurityClassificationChange(
|
||||
this: SchemalessTagging,
|
||||
{ value }: { value: ISecurityClassificationOption['value'] }
|
||||
) {
|
||||
const securityClassification = value || null;
|
||||
return get(this, 'onClassificationChange')(securityClassification);
|
||||
}
|
||||
|
||||
@ -30,6 +30,12 @@ const classifiers = [
|
||||
Classification.Public
|
||||
];
|
||||
|
||||
/**
|
||||
* Lists the dataset security classification options that are exluded for datasets containing PII
|
||||
* @type {Classification[]}
|
||||
*/
|
||||
const classifiersExcludedIfPII = [Classification.Internal, Classification.Public];
|
||||
|
||||
/**
|
||||
* Takes a string, returns a formatted string. Niche , single use case
|
||||
* for now, so no need to make into a helper
|
||||
@ -38,16 +44,17 @@ const classifiers = [
|
||||
const formatAsCapitalizedStringWithSpaces = (string: string) => capitalize(string.toLowerCase().replace(/[_]/g, ' '));
|
||||
|
||||
/**
|
||||
* A derived list of security classification options from classifiers list, including an empty string option and value
|
||||
* @type {Array<ISecurityClassificationOption>}
|
||||
* Derives the list of security classification options from the list of classifiers and disables options if
|
||||
* the containsPii argument is truthy. Includes a disabled placeholder option: Unspecified
|
||||
* @param {boolean = false} containsPii flag indicating if the dataset contains Pii
|
||||
* @return {Array<ISecurityClassificationOption>}
|
||||
*/
|
||||
const securityClassificationDropdownOptions: Array<ISecurityClassificationOption> = [null, ...classifiers].map(
|
||||
(value: ISecurityClassificationOption['value']) => ({
|
||||
const getSecurityClassificationDropDownOptions = (containsPii: boolean = false): Array<ISecurityClassificationOption> =>
|
||||
[null, ...classifiers].map((value: ISecurityClassificationOption['value']) => ({
|
||||
value,
|
||||
label: value ? formatAsCapitalizedStringWithSpaces(value) : 'Unspecified',
|
||||
isDisabled: !value
|
||||
})
|
||||
);
|
||||
isDisabled: !value || (containsPii && classifiersExcludedIfPII.includes(value))
|
||||
}));
|
||||
|
||||
/**
|
||||
* Checks if the identifierType is a mixed Id
|
||||
@ -86,7 +93,7 @@ const getDefaultSecurityClassification = (
|
||||
};
|
||||
|
||||
export {
|
||||
securityClassificationDropdownOptions,
|
||||
getSecurityClassificationDropDownOptions,
|
||||
formatAsCapitalizedStringWithSpaces,
|
||||
fieldIdentifierTypeValues,
|
||||
isMixedId,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user