mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-21 23:58:06 +00:00
updates the behaviour for custom identifier types to set a default classification
This commit is contained in:
parent
53a30d5a77
commit
c91ca85a90
@ -398,11 +398,19 @@ export default Component.extend({
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default classification for the given identifier field
|
* Sets the default classification for the given identifier field
|
||||||
* @param {String} identifierField
|
* Using the provided logicalType, or in some cases the identifierType, determines the fields
|
||||||
* @param {String} logicalType
|
* 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 = '' } = {}) {
|
setDefaultClassification({ identifierField, identifierType }, { value: logicalType = '' } = {}) {
|
||||||
const defaultTypeClassification = defaultFieldDataTypeClassification[logicalType] || null;
|
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 });
|
this.actions.onFieldClassificationChange.call(this, { identifierField }, { value: defaultTypeClassification });
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -499,15 +507,25 @@ export default Component.extend({
|
|||||||
const complianceList = get(this, policyComplianceEntitiesKey);
|
const complianceList = get(this, policyComplianceEntitiesKey);
|
||||||
// A reference to the current field in the compliance list if it exists
|
// A reference to the current field in the compliance list if it exists
|
||||||
const currentFieldInComplianceList = complianceList.findBy('identifierField', identifierField);
|
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, {
|
const updatedEntity = Object.assign({}, currentFieldInComplianceList, {
|
||||||
identifierField,
|
identifierField,
|
||||||
identifierType: subjectId === identifierType ? fieldIdentifierTypes.member.value : identifierType,
|
identifierType: unwrappedIdentifierType,
|
||||||
isSubject: subjectId === identifierType ? true : null,
|
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
|
logicalType: !currentFieldInComplianceList ? logicalType : void 0
|
||||||
});
|
});
|
||||||
let transientComplianceList = complianceList;
|
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) {
|
if (currentFieldInComplianceList) {
|
||||||
transientComplianceList = complianceList.filter(
|
transientComplianceList = complianceList.filter(
|
||||||
({ identifierField: fieldName }) => fieldName !== identifierField
|
({ identifierField: fieldName }) => fieldName !== identifierField
|
||||||
@ -515,7 +533,10 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
complianceList.setObjects([updatedEntity, ...transientComplianceList]);
|
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 });
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
const idLogicalTypes = ['ID', 'URN', 'REVERSED_URN', 'COMPOSITE_URN'];
|
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
|
// Default mapping of field data types to security classification
|
||||||
// https://iwww.corp.linkedin.com/wiki/cf/display/DWH/List+of+Metadata+for+Data+Sets
|
// https://iwww.corp.linkedin.com/wiki/cf/display/DWH/List+of+Metadata+for+Data+Sets
|
||||||
const nonIdFieldLogicalTypes = {
|
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}
|
* @type {Object}
|
||||||
*/
|
*/
|
||||||
const idFieldDataTypeClassification = idLogicalTypes.reduce((classification, idLogicalType) => {
|
const idFieldDataTypeClassification = [
|
||||||
|
...customIdLogicalTypes,
|
||||||
|
...idLogicalTypes
|
||||||
|
].reduce((classification, idLogicalType) => {
|
||||||
return Object.assign(classification, { [idLogicalType]: 'limitedDistribution' });
|
return Object.assign(classification, { [idLogicalType]: 'limitedDistribution' });
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
@ -155,7 +164,9 @@ const fieldIdentifierTypes = {
|
|||||||
},
|
},
|
||||||
custom: {
|
custom: {
|
||||||
value: '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'
|
displayAs: 'Custom ID'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
|
|
||||||
<button class="nacho-button nacho-button--large action-bar__item"
|
<button class="nacho-button nacho-button--large action-bar__item"
|
||||||
{{action "resetCompliance"}}>
|
{{action "resetCompliance"}}>
|
||||||
<i class="fa fa-times" title="Start Over">
|
<i class="fa fa-times" title="Cancel">
|
||||||
</i>
|
</i>
|
||||||
Start Over
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{{#if _message}}
|
{{#if _message}}
|
||||||
@ -58,15 +58,15 @@
|
|||||||
class="nacho-button--large nacho-button--secondary secondary-actions__action">
|
class="nacho-button--large nacho-button--secondary secondary-actions__action">
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#unless isNewComplianceInfo}}
|
{{#unless isNewComplianceInfo}}
|
||||||
<button
|
<button
|
||||||
{{action "onComplianceDownloadJson"}}
|
{{action "onComplianceDownloadJson"}}
|
||||||
class="nacho-button nacho-button--large-inverse secondary-actions__action">
|
class="nacho-button nacho-button--large-inverse secondary-actions__action">
|
||||||
Download as a JSON file
|
Download as a JSON file
|
||||||
</button>
|
</button>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section class="metadata-prompt">
|
<section class="metadata-prompt">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user