diff --git a/wherehows-web/app/components/dataset-compliance.ts b/wherehows-web/app/components/dataset-compliance.ts index d7dec725c1..ee66300c65 100644 --- a/wherehows-web/app/components/dataset-compliance.ts +++ b/wherehows-web/app/components/dataset-compliance.ts @@ -239,6 +239,11 @@ export default class DatasetCompliance extends Component { onReset: () => Promise; onSave: () => Promise; + /** + * Passthrough from parent to export policy component to save the retention policy + */ + onSaveRetentionPolicy: () => Promise; + /** * Passthrough from parent to export policy component to save the export policy */ @@ -1499,10 +1504,11 @@ export default class DatasetCompliance extends Component { try { const isSaving = true; const onSave = get(this, 'onSave'); + const onSaveRetentionPolicy = get(this, 'onSaveRetentionPolicy'); setSaveFlag(isSaving); await this.beforeSaveCompliance(editTarget); - await onSave(); + await (editTarget === ComplianceEdit.PurgePolicy ? onSaveRetentionPolicy() : onSave()); return; } finally { setSaveFlag(); diff --git a/wherehows-web/app/components/datasets/containers/dataset-compliance.ts b/wherehows-web/app/components/datasets/containers/dataset-compliance.ts index dc42280f55..382f0a636b 100644 --- a/wherehows-web/app/components/datasets/containers/dataset-compliance.ts +++ b/wherehows-web/app/components/datasets/containers/dataset-compliance.ts @@ -40,6 +40,9 @@ import { notificationDialogActionFactory } from 'wherehows-web/utils/notificatio import Configurator from 'wherehows-web/services/configurator'; import { typeOf } from '@ember/utils'; import { service } from '@ember-decorators/service'; +import { saveDatasetRetentionByUrn } from 'wherehows-web/utils/api/datasets/retention'; +import { extractRetentionFromComplianceInfo } from 'wherehows-web/utils/datasets/retention'; +import { IDatasetRetention } from 'wherehows-web/typings/api/datasets/retention'; /** * Type alias for the response when container data items are batched @@ -340,6 +343,30 @@ export default class DatasetComplianceContainer extends Component { } } + /** + * Persists the updates to the retention policy on the remote host + * @return {Promise} + */ + @action + async saveRetentionPolicy(this: DatasetComplianceContainer): Promise { + const complianceInfo = get(this, 'complianceInfo'); + if (complianceInfo) { + const { complianceEntities } = complianceInfo; + + await this.notifyOnSave( + saveDatasetRetentionByUrn( + get(this, 'urn'), + extractRetentionFromComplianceInfo({ + ...complianceInfo, + complianceEntities: removeReadonlyAttr(editableTags(complianceEntities)) + }) + ) + ); + + this.resetPrivacyCompliancePolicy.call(this); + } + } + /** * Persists the updates to the export policy on the remote host * @return {Promise