mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-06 22:04:16 +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 { run, schedule } from '@ember/runloop';
|
||||||
import { inject } from '@ember/service';
|
import { inject } from '@ember/service';
|
||||||
import { classify } from '@ember/string';
|
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 { Classification } from 'wherehows-web/constants/datasets/compliance';
|
||||||
import { IDatasetView } from 'wherehows-web/typings/api/datasets/dataset';
|
import { IDatasetView } from 'wherehows-web/typings/api/datasets/dataset';
|
||||||
import { IDataPlatform } from 'wherehows-web/typings/api/list/platforms';
|
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 isTrackingHeaderField from 'wherehows-web/utils/validators/tracking-headers';
|
||||||
import {
|
import {
|
||||||
securityClassificationDropdownOptions,
|
getSecurityClassificationDropDownOptions,
|
||||||
DatasetClassifiers,
|
DatasetClassifiers,
|
||||||
getFieldIdentifierOptions,
|
getFieldIdentifierOptions,
|
||||||
getDefaultSecurityClassification,
|
getDefaultSecurityClassification,
|
||||||
@ -248,7 +248,7 @@ export default class DatasetCompliance extends ObservableDecorator {
|
|||||||
complianceDataTypes: Array<IComplianceDataType>;
|
complianceDataTypes: Array<IComplianceDataType>;
|
||||||
|
|
||||||
// Map of classifiers options for drop down
|
// Map of classifiers options for drop down
|
||||||
classifiers = securityClassificationDropdownOptions;
|
classifiers: Array<ISecurityClassificationOption> = getSecurityClassificationDropDownOptions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default to show all fields to review
|
* Default to show all fields to review
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import { get } from '@ember/object';
|
import { get, computed } from '@ember/object';
|
||||||
import { ISecurityClassificationOption, securityClassificationDropdownOptions } from 'wherehows-web/constants';
|
import { getSecurityClassificationDropDownOptions, ISecurityClassificationOption } from 'wherehows-web/constants';
|
||||||
|
|
||||||
export default class SchemalessTagging extends Component {
|
export default class SchemalessTagging extends Component {
|
||||||
classNames = ['schemaless-tagging'];
|
classNames = ['schemaless-tagging'];
|
||||||
@ -31,7 +31,11 @@ export default class SchemalessTagging extends Component {
|
|||||||
* @type {Array<ISecurityClassificationOption>}
|
* @type {Array<ISecurityClassificationOption>}
|
||||||
* @memberof SchemalessTagging
|
* @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
|
* Flag indicating if this component should be in edit mode or readonly
|
||||||
@ -54,6 +58,10 @@ export default class SchemalessTagging extends Component {
|
|||||||
* @returns boolean
|
* @returns boolean
|
||||||
*/
|
*/
|
||||||
onPersonalDataToggle(this: SchemalessTagging, containsPersonalDataTag: boolean) {
|
onPersonalDataToggle(this: SchemalessTagging, containsPersonalDataTag: boolean) {
|
||||||
|
if (containsPersonalDataTag) {
|
||||||
|
this.actions.onSecurityClassificationChange.call(this, { value: null });
|
||||||
|
}
|
||||||
|
|
||||||
return get(this, 'onPersonalDataChange')(containsPersonalDataTag);
|
return get(this, 'onPersonalDataChange')(containsPersonalDataTag);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -62,7 +70,10 @@ export default class SchemalessTagging extends Component {
|
|||||||
* @param {ISecurityClassificationOption} { value } security Classification value for the dataset
|
* @param {ISecurityClassificationOption} { value } security Classification value for the dataset
|
||||||
* @returns null | Classification
|
* @returns null | Classification
|
||||||
*/
|
*/
|
||||||
onSecurityClassificationChange(this: SchemalessTagging, { value }: ISecurityClassificationOption) {
|
onSecurityClassificationChange(
|
||||||
|
this: SchemalessTagging,
|
||||||
|
{ value }: { value: ISecurityClassificationOption['value'] }
|
||||||
|
) {
|
||||||
const securityClassification = value || null;
|
const securityClassification = value || null;
|
||||||
return get(this, 'onClassificationChange')(securityClassification);
|
return get(this, 'onClassificationChange')(securityClassification);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,12 @@ const classifiers = [
|
|||||||
Classification.Public
|
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
|
* Takes a string, returns a formatted string. Niche , single use case
|
||||||
* for now, so no need to make into a helper
|
* 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, ' '));
|
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
|
* Derives the list of security classification options from the list of classifiers and disables options if
|
||||||
* @type {Array<ISecurityClassificationOption>}
|
* 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(
|
const getSecurityClassificationDropDownOptions = (containsPii: boolean = false): Array<ISecurityClassificationOption> =>
|
||||||
(value: ISecurityClassificationOption['value']) => ({
|
[null, ...classifiers].map((value: ISecurityClassificationOption['value']) => ({
|
||||||
value,
|
value,
|
||||||
label: value ? formatAsCapitalizedStringWithSpaces(value) : 'Unspecified',
|
label: value ? formatAsCapitalizedStringWithSpaces(value) : 'Unspecified',
|
||||||
isDisabled: !value
|
isDisabled: !value || (containsPii && classifiersExcludedIfPII.includes(value))
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the identifierType is a mixed Id
|
* Checks if the identifierType is a mixed Id
|
||||||
@ -86,7 +93,7 @@ const getDefaultSecurityClassification = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
securityClassificationDropdownOptions,
|
getSecurityClassificationDropDownOptions,
|
||||||
formatAsCapitalizedStringWithSpaces,
|
formatAsCapitalizedStringWithSpaces,
|
||||||
fieldIdentifierTypeValues,
|
fieldIdentifierTypeValues,
|
||||||
isMixedId,
|
isMixedId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user