mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-15 02:43:19 +00:00
adds error messages display for JSON parse and some issues with matching compliance metadata schema
This commit is contained in:
parent
84ccd903d2
commit
55cd632f2d
@ -124,6 +124,13 @@ export default class DatasetCompliance extends Component {
|
|||||||
*/
|
*/
|
||||||
isManualApplyDisabled: boolean = false;
|
isManualApplyDisabled: boolean = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String representation of a parse error that may have occurred when validating manually entered compliance entities
|
||||||
|
* @type {string}
|
||||||
|
* @memberof DatasetCompliance
|
||||||
|
*/
|
||||||
|
manualParseError: string = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag indicating the current compliance policy edit-view mode
|
* Flag indicating the current compliance policy edit-view mode
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@ -994,13 +1001,13 @@ export default class DatasetCompliance extends Component {
|
|||||||
};
|
};
|
||||||
const isValid = validateMetadataObject(metadataObject, complianceEntitiesTaxonomy);
|
const isValid = validateMetadataObject(metadataObject, complianceEntitiesTaxonomy);
|
||||||
|
|
||||||
set(this, 'isManualApplyDisabled', !isValid);
|
setProperties(this, { isManualApplyDisabled: !isValid, manualParseError: '' });
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
set(this, 'manuallyEnteredComplianceEntities', metadataObject);
|
set(this, 'manuallyEnteredComplianceEntities', metadataObject);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (e) {
|
||||||
set(this, 'isManualApplyDisabled', true);
|
setProperties(this, { isManualApplyDisabled: true, manualParseError: e.message });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -93,6 +93,14 @@ $navbar-transition-speed: $banner-animation-speed;
|
|||||||
&__content {
|
&__content {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
|
|
||||||
|
&__error-messages {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
color: get-color(red5);
|
||||||
|
margin-left: item-spacing(2);
|
||||||
|
padding-right: item-spacing(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__item + &__item {
|
&__item + &__item {
|
||||||
|
|||||||
@ -321,6 +321,10 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__manual-entry-errors {
|
||||||
|
margin-left: item-spacing(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataset-compliance-editor {
|
.dataset-compliance-editor {
|
||||||
|
|||||||
@ -89,6 +89,16 @@
|
|||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
{{/track-ui-event}}
|
{{/track-ui-event}}
|
||||||
|
|
||||||
|
{{#if (and isInitialEditStep (and manualParseError (not showGuidedComplianceEditMode)))}}
|
||||||
|
<div class="action-bar__content__error-messages">
|
||||||
|
{{fa-icon "times-circle-o"}}
|
||||||
|
|
||||||
|
<span class="dataset-compliance-fields__manual-entry-errors">
|
||||||
|
{{manualParseError}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { DatasetClassifiers } from 'wherehows-web/constants';
|
|||||||
import { arrayEvery, arrayMap, arrayReduce } from 'wherehows-web/utils/array';
|
import { arrayEvery, arrayMap, arrayReduce } from 'wherehows-web/utils/array';
|
||||||
import { IObject } from 'wherehows-web/typings/generic';
|
import { IObject } from 'wherehows-web/typings/generic';
|
||||||
import { isObject } from 'wherehows-web/utils/object';
|
import { isObject } from 'wherehows-web/utils/object';
|
||||||
|
import { difference } from 'lodash';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the interface for an IDL that specifies the data types for properties on
|
* Defines the interface for an IDL that specifies the data types for properties on
|
||||||
@ -146,14 +147,21 @@ const keyValueHasMatch = (object: IObject<any>) => (metadataType: IMetadataType)
|
|||||||
* @param {IObject<any>} object
|
* @param {IObject<any>} object
|
||||||
* @param {Array<IMetadataType>} typeMaps
|
* @param {Array<IMetadataType>} typeMaps
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
|
* @throws {Error} if object keys do not match type @names
|
||||||
*/
|
*/
|
||||||
const keysMatchNames = (object: IObject<any>, typeMaps: Array<IMetadataType>): boolean =>
|
const keysMatchNames = (object: IObject<any>, typeMaps: Array<IMetadataType>): boolean => {
|
||||||
Object.keys(object)
|
const objectKeys = Object.keys(object).sort();
|
||||||
.sort()
|
const typeKeys = arrayMap((typeMap: IMetadataType) => typeMap['@name'])(typeMaps).sort();
|
||||||
.toString() ===
|
const objectKeysSerialized = objectKeys.toString();
|
||||||
arrayMap((typeMap: IMetadataType) => typeMap['@name'])(typeMaps)
|
const typeKeysSerialized = typeKeys.toString();
|
||||||
.sort()
|
const match = objectKeysSerialized === typeKeysSerialized;
|
||||||
.toString();
|
|
||||||
|
if (!match) {
|
||||||
|
throw new Error(`Extra attributes found: ${difference(objectKeys, typeKeys).join(', ')}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks each key on an object matches the expected types in the typeMap
|
* Checks each key on an object matches the expected types in the typeMap
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user