mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-27 17:02:03 +00:00
adds transform functions for readonly compliance entities onSave operation. adds styling for readony table row component. adds ui behavior for table row component
This commit is contained in:
parent
a0af350644
commit
c33027796a
@ -21,7 +21,7 @@ import { columnDataTypesAndFieldNames } from 'wherehows-web/utils/api/datasets/c
|
||||
import { readDatasetSchemaByUrn } from 'wherehows-web/utils/api/datasets/schema';
|
||||
import { ApiError } from 'wherehows-web/utils/api/errors/errors';
|
||||
import { readComplianceDataTypes } from 'wherehows-web/utils/api/list/compliance-datatypes';
|
||||
import { compliancePolicyStrings } from 'wherehows-web/constants';
|
||||
import { compliancePolicyStrings, removeReadonlyAttr, filterEditableEntities } from 'wherehows-web/constants';
|
||||
|
||||
const { successUpdating, failedUpdating } = compliancePolicyStrings;
|
||||
|
||||
@ -194,7 +194,15 @@ export default class DatasetComplianceContainer extends Component {
|
||||
async savePrivacyCompliancePolicy(this: DatasetComplianceContainer): Promise<void> {
|
||||
const complianceInfo = get(this, 'complianceInfo');
|
||||
if (complianceInfo) {
|
||||
return this.notifyOnSave<void>(saveDatasetComplianceByUrn(get(this, 'urn'), complianceInfo));
|
||||
const { complianceEntities } = complianceInfo;
|
||||
|
||||
return this.notifyOnSave<void>(
|
||||
saveDatasetComplianceByUrn(get(this, 'urn'), {
|
||||
...complianceInfo,
|
||||
// filter out readonly entities, then fleece readonly attribute from remaining entities before save
|
||||
complianceEntities: removeReadonlyAttr(filterEditableEntities(complianceEntities))
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import Ember from 'ember';
|
||||
import { Classification, ComplianceFieldIdValue, IdLogicalType } from 'wherehows-web/constants/datasets/compliance';
|
||||
import { IComplianceEntity } from 'wherehows-web/typings/api/datasets/compliance';
|
||||
import { IComplianceDataType } from 'wherehows-web/typings/api/list/compliance-datatypes';
|
||||
import { arrayMap } from 'wherehows-web/utils/array';
|
||||
import { arrayFilter, arrayMap } from 'wherehows-web/utils/array';
|
||||
import { fleece } from 'wherehows-web/utils/object';
|
||||
|
||||
const { String: { htmlSafe } } = Ember;
|
||||
|
||||
@ -117,6 +119,29 @@ const getComplianceSteps = (hasSchema: boolean = true): { [x: number]: { name: s
|
||||
return complianceSteps;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if argument of type IComplianceEntity has its readonly attribute not set to true
|
||||
* @param {IComplianceEntity} { readonly }
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isEditableComplianceEntity = ({ readonly }: IComplianceEntity): boolean => readonly !== true;
|
||||
|
||||
/**
|
||||
* Filters out from a list of compliance entities, entities that are editable
|
||||
* @param {Array<IComplianceEntity>} entities
|
||||
* @returns {Array<IComplianceEntity>}
|
||||
*/
|
||||
const filterEditableEntities = (entities: Array<IComplianceEntity>): Array<IComplianceEntity> =>
|
||||
arrayFilter(isEditableComplianceEntity)(entities);
|
||||
|
||||
/**
|
||||
* Strips out the readonly attribute from a list of compliance entities
|
||||
* @type {(entities: Array<IComplianceEntity>) => Array<IComplianceEntity>}
|
||||
*/
|
||||
const removeReadonlyAttr = <(entities: Array<IComplianceEntity>) => Array<IComplianceEntity>>arrayMap(
|
||||
fleece<IComplianceEntity, 'readonly'>(['readonly'])
|
||||
);
|
||||
|
||||
export {
|
||||
compliancePolicyStrings,
|
||||
getFieldIdentifierOption,
|
||||
@ -124,6 +149,8 @@ export {
|
||||
complianceSteps,
|
||||
hiddenTrackingFields,
|
||||
getComplianceSteps,
|
||||
filterEditableEntities,
|
||||
removeReadonlyAttr,
|
||||
IComplianceFieldIdentifierOption,
|
||||
IComplianceFieldFormatOption,
|
||||
ISecurityClassificationOption,
|
||||
|
||||
@ -278,31 +278,6 @@ export default class extends Controller.extend({
|
||||
|
||||
this.set('currentInstance', instance.dbId);
|
||||
this.refreshVersions(instance.dbId);
|
||||
},
|
||||
|
||||
/**
|
||||
* Requests the privacyCompliancePolicy for the current dataset id
|
||||
* and sets the result on the controller `privacyCompliancePolicy` property
|
||||
* @returns {Promise.<*>}
|
||||
*/
|
||||
resetPrivacyCompliancePolicy() {
|
||||
return getJSON(this.getUrlFor('compliance'), ({ status, complianceInfo }) => {
|
||||
status === 'ok' &&
|
||||
setProperties(this, {
|
||||
complianceInfo,
|
||||
isNewComplianceInfo: false
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves the current version of the privacyCompliancePolicy document and invokes an api to persist the document
|
||||
* then updates controller state if successful
|
||||
*/
|
||||
savePrivacyCompliancePolicy() {
|
||||
return this.saveJson('compliance', get(this, 'complianceInfo'))
|
||||
.then(this.actions.resetPrivacyCompliancePolicy.bind(this))
|
||||
.catch(this.exceptionOnSave);
|
||||
}
|
||||
}
|
||||
}) {
|
||||
|
||||
@ -30,6 +30,19 @@
|
||||
margin-top: item-spacing(2);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
&--readonly {
|
||||
&#{&}#{&} {
|
||||
color: get-color(slate5);
|
||||
opacity: 0.7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
color: get-color(red7);
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.compliance-depends {
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
classification=classification
|
||||
suggestionResolution=suggestionResolution
|
||||
suggestion=prediction
|
||||
isReadonly=isReadonlyEntity
|
||||
identifierTypeBeforeSuggestion=identifierTypeBeforeSuggestion
|
||||
logicalTypeBeforeSuggestion=logicalTypeBeforeSuggestion
|
||||
isReviewRequested=isReviewRequested
|
||||
|
||||
@ -81,18 +81,28 @@
|
||||
}}
|
||||
|
||||
{{#row.cell}}
|
||||
{{#if (and row.suggestion (not row.suggestionResolution))}}
|
||||
{{#if row.isReadonly}}
|
||||
|
||||
<span class="notification-dot notification-dot--has-prediction"
|
||||
aria-label="Compliance fields have suggested values"></span>
|
||||
<i class="fa fa-lock dataset-compliance-fields--readonly__icon" title="Readonly">
|
||||
{{tooltip-on-element
|
||||
text="Readonly"
|
||||
}}
|
||||
</i>
|
||||
|
||||
{{else}}
|
||||
{{#if (and row.suggestion (not row.suggestionResolution))}}
|
||||
|
||||
<span class="notification-dot notification-dot--has-prediction"
|
||||
aria-label="Compliance fields have suggested values"></span>
|
||||
|
||||
{{else}}
|
||||
|
||||
{{#if row.isReviewRequested}}
|
||||
<span class="notification-dot notification-dot--needs-review"
|
||||
aria-label="Compliance policy for field does not exist"></span>
|
||||
{{/if}}
|
||||
|
||||
{{#if row.isReviewRequested}}
|
||||
<span class="notification-dot notification-dot--needs-review"
|
||||
aria-label="Compliance policy for field does not exist"></span>
|
||||
{{/if}}
|
||||
|
||||
{{/if}}
|
||||
{{/row.cell}}
|
||||
|
||||
@ -137,7 +147,7 @@
|
||||
</div>
|
||||
|
||||
{{ember-selector
|
||||
disabled=(not isEditing)
|
||||
disabled=(or (not isEditing) row.isReadonly)
|
||||
values=complianceFieldIdDropdownOptions
|
||||
selected=(readonly row.identifierType)
|
||||
selectionDidChange=(action row.onFieldIdentifierTypeChange)
|
||||
@ -154,17 +164,17 @@
|
||||
<a
|
||||
target="_blank"
|
||||
href="http://go/metadata_acquisition#ProjectOverview-compliance">
|
||||
<sup>
|
||||
More Info
|
||||
<sup>
|
||||
More Info
|
||||
|
||||
<span class="glyphicon glyphicon-question-sign"
|
||||
title="More information on Field Format"></span>
|
||||
</sup>
|
||||
<span class="glyphicon glyphicon-question-sign"
|
||||
title="More information on Field Format"></span>
|
||||
</sup>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{{ember-selector
|
||||
disabled=(not isEditing)
|
||||
disabled=(or (not isEditing) row.isReadonly)
|
||||
values=row.fieldFormats
|
||||
selected=(readonly row.logicalType)
|
||||
selectionDidChange=(action row.onFieldLogicalTypeChange)
|
||||
@ -184,7 +194,7 @@
|
||||
id=(concat row.rowId '-compliance-field-owner-toggle')
|
||||
type="checkbox"
|
||||
class="toggle-switch toggle-switch--light"
|
||||
disabled=(not isEditing)
|
||||
disabled=(or (not isEditing) row.isReadonly)
|
||||
checked=(readonly row.nonOwner)
|
||||
change=(action row.onOwnerChange value="target.checked")
|
||||
}}
|
||||
@ -209,7 +219,7 @@
|
||||
|
||||
{{ember-selector
|
||||
class="nacho-select--hidden-state"
|
||||
disabled=(not isEditing)
|
||||
disabled=(or (not isEditing) row.isReadonly)
|
||||
values=classifiers
|
||||
selected=row.classification
|
||||
selectionDidChange=(action row.onFieldClassificationChange)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user