diff --git a/wherehows-web/app/components/dataset-compliance.js b/wherehows-web/app/components/dataset-compliance.js index 0a8c04949f..537662a5a0 100644 --- a/wherehows-web/app/components/dataset-compliance.js +++ b/wherehows-web/app/components/dataset-compliance.js @@ -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 }); }, /** diff --git a/wherehows-web/app/constants/metadata-acquisition.js b/wherehows-web/app/constants/metadata-acquisition.js index 260c0bf2cc..82113269d1 100644 --- a/wherehows-web/app/constants/metadata-acquisition.js +++ b/wherehows-web/app/constants/metadata-acquisition.js @@ -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.} + */ +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' } }; diff --git a/wherehows-web/app/templates/components/dataset-compliance.hbs b/wherehows-web/app/templates/components/dataset-compliance.hbs index 970817b6cb..2835639767 100644 --- a/wherehows-web/app/templates/components/dataset-compliance.hbs +++ b/wherehows-web/app/templates/components/dataset-compliance.hbs @@ -26,9 +26,9 @@ {{#if _message}} @@ -58,15 +58,15 @@ class="nacho-button--large nacho-button--secondary secondary-actions__action"> Edit - {{/if}} - {{#unless isNewComplianceInfo}} - - {{/unless}} + {{#unless isNewComplianceInfo}} + + {{/unless}} + {{/if}}