updates the behaviour for custom identifier types to set a default classification

This commit is contained in:
Seyi Adebajo 2017-06-06 11:34:53 -07:00 committed by Mars Lan
parent 53a30d5a77
commit c91ca85a90
3 changed files with 53 additions and 21 deletions

View File

@ -398,11 +398,19 @@ export default Component.extend({
/**
* Sets the default classification for the given identifier field
* @param {String} identifierField
* @param {String} logicalType
* Using the provided logicalType, or in some cases the identifierType, determines the fields
* default security classification based on a lookup
* @param {String} identifierField the field for which the default classification should apply
* @param {String} [identifierType] the current identifier type for the field
* @param {String} [logicalType] the logicalType / (field format) for the identifierField
*/
setDefaultClassification({ identifierField }, { value: logicalType = '' } = {}) {
const defaultTypeClassification = defaultFieldDataTypeClassification[logicalType] || null;
setDefaultClassification({ identifierField, identifierType }, { value: logicalType = '' } = {}) {
let defaultTypeClassification = defaultFieldDataTypeClassification[logicalType] || null;
// If the identifierType is of custom, set the default classification to the of a CUSTOM_ID, otherwise use value
// based on logicalType
defaultTypeClassification = identifierType === fieldIdentifierTypes.custom.value
? defaultFieldDataTypeClassification['CUSTOM_ID']
: defaultTypeClassification;
this.actions.onFieldClassificationChange.call(this, { identifierField }, { value: defaultTypeClassification });
},
@ -499,15 +507,25 @@ export default Component.extend({
const complianceList = get(this, policyComplianceEntitiesKey);
// A reference to the current field in the compliance list if it exists
const currentFieldInComplianceList = complianceList.findBy('identifierField', identifierField);
const subjectId = fieldIdentifierTypes.subjectMember.value;
const subjectIdString = fieldIdentifierTypes.subjectMember.value;
// Some rendered identifierTypes may be masks of other underlying types, e.g. subjectId Member type is really
// a memberId with an attribute of isSubject in the affirmative
const unwrappedIdentifierType = subjectIdString === identifierType
? fieldIdentifierTypes.member.value
: identifierType;
const updatedEntity = Object.assign({}, currentFieldInComplianceList, {
identifierField,
identifierType: subjectId === identifierType ? fieldIdentifierTypes.member.value : identifierType,
isSubject: subjectId === identifierType ? true : null,
identifierType: unwrappedIdentifierType,
isSubject: subjectIdString === identifierType ? true : null,
// If the field is currently not in the complianceList,
// we will set the logicalType to be the provided value, otherwise, set to undefined
// since the next step removes it from the updated list
logicalType: !currentFieldInComplianceList ? logicalType : void 0
});
let transientComplianceList = complianceList;
// If the identifierField is in the current compliance list,
// create a filtered list excluding the identifierField before updating the list
if (currentFieldInComplianceList) {
transientComplianceList = complianceList.filter(
({ identifierField: fieldName }) => fieldName !== identifierField
@ -515,7 +533,10 @@ export default Component.extend({
}
complianceList.setObjects([updatedEntity, ...transientComplianceList]);
this.setDefaultClassification({ identifierField });
// Set the defaultClassification for the identifierField,
// although the classification is based on the logicalType,
// an identifierField may only have one valid logicalType for it's given identifierType
this.setDefaultClassification({ identifierField, identifierType: unwrappedIdentifierType });
},
/**

View File

@ -4,6 +4,12 @@
*/
const idLogicalTypes = ['ID', 'URN', 'REVERSED_URN', 'COMPOSITE_URN'];
/**
* A list of custom logical types that may be treated ids but have a different behaviour from regular ids
* @type {Array.<String>}
*/
const customIdLogicalTypes = ['CUSTOM_ID'];
// Default mapping of field data types to security classification
// https://iwww.corp.linkedin.com/wiki/cf/display/DWH/List+of+Metadata+for+Data+Sets
const nonIdFieldLogicalTypes = {
@ -82,10 +88,13 @@ const nonIdFieldLogicalTypes = {
};
/**
* A map of id logical types to the default field classification for Ids
* A map of id logical types including custom ids to the default field classification for Ids
* @type {Object}
*/
const idFieldDataTypeClassification = idLogicalTypes.reduce((classification, idLogicalType) => {
const idFieldDataTypeClassification = [
...customIdLogicalTypes,
...idLogicalTypes
].reduce((classification, idLogicalType) => {
return Object.assign(classification, { [idLogicalType]: 'limitedDistribution' });
}, {});
@ -155,7 +164,9 @@ const fieldIdentifierTypes = {
},
custom: {
value: 'custom',
isId: true,
isId: false,
// Although rendered as though an id, it's custom and from a UI perspective does not share a key similarity to other
// ids, a logicalType / (field format) is not required to update this fields properties
displayAs: 'Custom ID'
}
};

View File

@ -26,9 +26,9 @@
<button class="nacho-button nacho-button--large action-bar__item"
{{action "resetCompliance"}}>
<i class="fa fa-times" title="Start Over">
<i class="fa fa-times" title="Cancel">
</i>
Start Over
Cancel
</button>
{{#if _message}}
@ -58,15 +58,15 @@
class="nacho-button--large nacho-button--secondary secondary-actions__action">
Edit
</button>
{{/if}}
{{#unless isNewComplianceInfo}}
<button
{{action "onComplianceDownloadJson"}}
class="nacho-button nacho-button--large-inverse secondary-actions__action">
Download as a JSON file
</button>
{{/unless}}
{{#unless isNewComplianceInfo}}
<button
{{action "onComplianceDownloadJson"}}
class="nacho-button nacho-button--large-inverse secondary-actions__action">
Download as a JSON file
</button>
{{/unless}}
{{/if}}
</div>
<section class="metadata-prompt">