adds additional keys on policy metadata json download

This commit is contained in:
Seyi Adebajo 2018-05-31 11:27:33 -07:00
parent 97327eea66
commit a90c932d9b
2 changed files with 25 additions and 2 deletions

View File

@ -1173,7 +1173,16 @@ export default class DatasetCompliance extends Component {
});
}
const policy = Object.assign({}, getProperties(currentPolicy, ['datasetClassification', 'complianceEntities']));
const policy = Object.assign(
{},
getProperties(currentPolicy, [
'datasetClassification',
'complianceEntities',
'compliancePurgeNote',
'complianceType',
'confidentiality'
])
);
const href = `data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(policy))}`;
const download = `${get(this, 'datasetName')}_policy.json`;
const anchor = document.createElement('a');

View File

@ -33,7 +33,7 @@ const datasetClassificationPropType = (prop: string): IMetadataType => ({
/**
* Defines the shape of the dataset compliance metadata json object using the IMetadataType interface
* @type {({'@type': string; '@name': string; '@props': Array<IMetadataType>} | {'@type': string; '@name': string; '@props': ({'@name': string; '@type': string} | {'@name': string; '@type': string[]} | {'@name': string; '@type': string[]; '@symbols': any[]} | {'@type': string[]; '@name': string})[]})[]}
* @type {Array<IMetadataType>}
*/
const complianceMetadataTaxonomy: Array<IMetadataType> = [
{
@ -71,6 +71,18 @@ const complianceMetadataTaxonomy: Array<IMetadataType> = [
'@type': ['string', 'null']
}
]
},
{
'@type': ['string', 'null'],
'@name': 'compliancePurgeNote'
},
{
'@type': 'string',
'@name': 'complianceType'
},
{
'@type': ['string', 'null'],
'@name': 'confidentiality'
}
];
@ -104,11 +116,13 @@ const keyValueHasMatch = (object: IObject<any>) => (metadataType: IMetadataType)
const innerType = metadataType['@props'];
if (type.includes('object') && isObject(value)) {
// recurse on object properties
return rootValueEquiv && keysEquiv(value, innerType!);
}
if (type.includes('array') && Array.isArray(value)) {
return (
// recursively reduce on array elements
rootValueEquiv &&
arrayReduce((isEquiv: boolean, value: any) => isEquiv && keysEquiv(value, innerType!), rootValueEquiv)(value)
);