mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-13 11:06:30 +00:00
refactor compliance upload action using decorator
This commit is contained in:
parent
4cb324861a
commit
ce53a709cf
@ -67,6 +67,7 @@ import { IdLogicalType, NonIdLogicalType } from 'wherehows-web/constants/dataset
|
|||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
import { trackableEvent, TrackableEventCategory } from 'wherehows-web/constants/analytics/event-tracking';
|
import { trackableEvent, TrackableEventCategory } from 'wherehows-web/constants/analytics/event-tracking';
|
||||||
import { notificationDialogActionFactory } from 'wherehows-web/utils/notifications/notifications';
|
import { notificationDialogActionFactory } from 'wherehows-web/utils/notifications/notifications';
|
||||||
|
import { action } from '@ember-decorators/object';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
complianceDataException,
|
complianceDataException,
|
||||||
@ -890,6 +891,39 @@ export default class DatasetCompliance extends Component {
|
|||||||
get(this, 'updateEditStepTask').perform();
|
get(this, 'updateEditStepTask').perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives the json representation for compliance and applies each key to the policy
|
||||||
|
* @param {string} textString string representation for the JSON file
|
||||||
|
*/
|
||||||
|
@action
|
||||||
|
async onComplianceJsonUpload(this: DatasetCompliance, textString: string): Promise<void> {
|
||||||
|
const {
|
||||||
|
complianceInfo,
|
||||||
|
notifications: { notify }
|
||||||
|
} = getProperties(this, ['complianceInfo', 'notifications']);
|
||||||
|
|
||||||
|
if (complianceInfo) {
|
||||||
|
try {
|
||||||
|
const policy = JSON.parse(textString);
|
||||||
|
|
||||||
|
if (isPolicyExpectedShape(policy)) {
|
||||||
|
setProperties(complianceInfo, {
|
||||||
|
complianceEntities: policy.complianceEntities,
|
||||||
|
datasetClassification: policy.datasetClassification
|
||||||
|
});
|
||||||
|
|
||||||
|
notify(NotificationEvent.info, {
|
||||||
|
content: successUploading
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
notify(NotificationEvent.error, {
|
||||||
|
content: invalidPolicyData
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
actions: IDatasetComplianceActions = {
|
actions: IDatasetComplianceActions = {
|
||||||
/**
|
/**
|
||||||
* Action handles wizard step cancellation
|
* Action handles wizard step cancellation
|
||||||
@ -1161,47 +1195,6 @@ export default class DatasetCompliance extends Component {
|
|||||||
set(tag, 'suggestionAuthority', intent);
|
set(tag, 'suggestionAuthority', intent);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Receives the json representation for compliance and applies each key to the policy
|
|
||||||
* @param {string} textString string representation for the JSON file
|
|
||||||
*/
|
|
||||||
onComplianceJsonUpload(this: DatasetCompliance, textString: string): void {
|
|
||||||
const complianceInfo = get(this, 'complianceInfo');
|
|
||||||
const { notify } = get(this, 'notifications');
|
|
||||||
let policy;
|
|
||||||
|
|
||||||
if (!complianceInfo) {
|
|
||||||
notify(NotificationEvent.error, {
|
|
||||||
content: 'Could not find compliance current compliance policy for this dataset'
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
policy = JSON.parse(textString);
|
|
||||||
} catch (e) {
|
|
||||||
notify(NotificationEvent.error, {
|
|
||||||
content: invalidPolicyData
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPolicyExpectedShape(policy)) {
|
|
||||||
setProperties(complianceInfo, {
|
|
||||||
complianceEntities: policy.complianceEntities,
|
|
||||||
datasetClassification: policy.datasetClassification
|
|
||||||
});
|
|
||||||
|
|
||||||
notify(NotificationEvent.info, {
|
|
||||||
content: successUploading
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
notify(NotificationEvent.error, {
|
|
||||||
content: invalidPolicyData
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the compliance policy download action
|
* Handles the compliance policy download action
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user