mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-31 18:59:23 +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 { readDatasetSchemaByUrn } from 'wherehows-web/utils/api/datasets/schema'; | ||||||
| import { ApiError } from 'wherehows-web/utils/api/errors/errors'; | import { ApiError } from 'wherehows-web/utils/api/errors/errors'; | ||||||
| import { readComplianceDataTypes } from 'wherehows-web/utils/api/list/compliance-datatypes'; | 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; | const { successUpdating, failedUpdating } = compliancePolicyStrings; | ||||||
| 
 | 
 | ||||||
| @ -194,7 +194,15 @@ export default class DatasetComplianceContainer extends Component { | |||||||
|   async savePrivacyCompliancePolicy(this: DatasetComplianceContainer): Promise<void> { |   async savePrivacyCompliancePolicy(this: DatasetComplianceContainer): Promise<void> { | ||||||
|     const complianceInfo = get(this, 'complianceInfo'); |     const complianceInfo = get(this, 'complianceInfo'); | ||||||
|     if (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 Ember from 'ember'; | ||||||
| import { Classification, ComplianceFieldIdValue, IdLogicalType } from 'wherehows-web/constants/datasets/compliance'; | 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 { 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; | const { String: { htmlSafe } } = Ember; | ||||||
| 
 | 
 | ||||||
| @ -117,6 +119,29 @@ const getComplianceSteps = (hasSchema: boolean = true): { [x: number]: { name: s | |||||||
|   return complianceSteps; |   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 { | export { | ||||||
|   compliancePolicyStrings, |   compliancePolicyStrings, | ||||||
|   getFieldIdentifierOption, |   getFieldIdentifierOption, | ||||||
| @ -124,6 +149,8 @@ export { | |||||||
|   complianceSteps, |   complianceSteps, | ||||||
|   hiddenTrackingFields, |   hiddenTrackingFields, | ||||||
|   getComplianceSteps, |   getComplianceSteps, | ||||||
|  |   filterEditableEntities, | ||||||
|  |   removeReadonlyAttr, | ||||||
|   IComplianceFieldIdentifierOption, |   IComplianceFieldIdentifierOption, | ||||||
|   IComplianceFieldFormatOption, |   IComplianceFieldFormatOption, | ||||||
|   ISecurityClassificationOption, |   ISecurityClassificationOption, | ||||||
|  | |||||||
| @ -278,31 +278,6 @@ export default class extends Controller.extend({ | |||||||
| 
 | 
 | ||||||
|       this.set('currentInstance', instance.dbId); |       this.set('currentInstance', instance.dbId); | ||||||
|       this.refreshVersions(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); |     margin-top: item-spacing(2); | ||||||
|     opacity: 0.8; |     opacity: 0.8; | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   &--readonly { | ||||||
|  |     &#{&}#{&} { | ||||||
|  |       color: get-color(slate5); | ||||||
|  |       opacity: 0.7; | ||||||
|  |       cursor: not-allowed; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     &__icon { | ||||||
|  |       color: get-color(red7); | ||||||
|  |       opacity: 0.9; | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .compliance-depends { | .compliance-depends { | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ | |||||||
|           classification=classification |           classification=classification | ||||||
|           suggestionResolution=suggestionResolution |           suggestionResolution=suggestionResolution | ||||||
|           suggestion=prediction |           suggestion=prediction | ||||||
|  |           isReadonly=isReadonlyEntity | ||||||
|           identifierTypeBeforeSuggestion=identifierTypeBeforeSuggestion |           identifierTypeBeforeSuggestion=identifierTypeBeforeSuggestion | ||||||
|           logicalTypeBeforeSuggestion=logicalTypeBeforeSuggestion |           logicalTypeBeforeSuggestion=logicalTypeBeforeSuggestion | ||||||
|           isReviewRequested=isReviewRequested |           isReviewRequested=isReviewRequested | ||||||
|  | |||||||
| @ -81,18 +81,28 @@ | |||||||
|         }} |         }} | ||||||
| 
 | 
 | ||||||
|           {{#row.cell}} |           {{#row.cell}} | ||||||
|             {{#if (and row.suggestion (not row.suggestionResolution))}} |             {{#if row.isReadonly}} | ||||||
| 
 | 
 | ||||||
|               <span class="notification-dot notification-dot--has-prediction" |               <i class="fa fa-lock dataset-compliance-fields--readonly__icon" title="Readonly"> | ||||||
|                     aria-label="Compliance fields have suggested values"></span> |                 {{tooltip-on-element | ||||||
|  |                   text="Readonly" | ||||||
|  |                 }} | ||||||
|  |               </i> | ||||||
| 
 | 
 | ||||||
|             {{else}} |             {{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}} | ||||||
| 
 |  | ||||||
|             {{/if}} |             {{/if}} | ||||||
|           {{/row.cell}} |           {{/row.cell}} | ||||||
| 
 | 
 | ||||||
| @ -137,7 +147,7 @@ | |||||||
|               </div> |               </div> | ||||||
| 
 | 
 | ||||||
|               {{ember-selector |               {{ember-selector | ||||||
|                 disabled=(not isEditing) |                 disabled=(or (not isEditing) row.isReadonly) | ||||||
|                 values=complianceFieldIdDropdownOptions |                 values=complianceFieldIdDropdownOptions | ||||||
|                 selected=(readonly row.identifierType) |                 selected=(readonly row.identifierType) | ||||||
|                 selectionDidChange=(action row.onFieldIdentifierTypeChange) |                 selectionDidChange=(action row.onFieldIdentifierTypeChange) | ||||||
| @ -154,17 +164,17 @@ | |||||||
|                 <a |                 <a | ||||||
|                   target="_blank" |                   target="_blank" | ||||||
|                   href="http://go/metadata_acquisition#ProjectOverview-compliance"> |                   href="http://go/metadata_acquisition#ProjectOverview-compliance"> | ||||||
|                 <sup> |                   <sup> | ||||||
|                 More Info |                     More Info | ||||||
| 
 | 
 | ||||||
|                 <span class="glyphicon glyphicon-question-sign" |                     <span class="glyphicon glyphicon-question-sign" | ||||||
|                       title="More information on Field Format"></span> |                           title="More information on Field Format"></span> | ||||||
|                 </sup> |                   </sup> | ||||||
|                 </a> |                 </a> | ||||||
|               </div> |               </div> | ||||||
| 
 | 
 | ||||||
|               {{ember-selector |               {{ember-selector | ||||||
|                 disabled=(not isEditing) |                 disabled=(or (not isEditing) row.isReadonly) | ||||||
|                 values=row.fieldFormats |                 values=row.fieldFormats | ||||||
|                 selected=(readonly row.logicalType) |                 selected=(readonly row.logicalType) | ||||||
|                 selectionDidChange=(action row.onFieldLogicalTypeChange) |                 selectionDidChange=(action row.onFieldLogicalTypeChange) | ||||||
| @ -184,7 +194,7 @@ | |||||||
|                 id=(concat row.rowId '-compliance-field-owner-toggle') |                 id=(concat row.rowId '-compliance-field-owner-toggle') | ||||||
|                 type="checkbox" |                 type="checkbox" | ||||||
|                 class="toggle-switch toggle-switch--light" |                 class="toggle-switch toggle-switch--light" | ||||||
|                 disabled=(not isEditing) |                 disabled=(or (not isEditing) row.isReadonly) | ||||||
|                 checked=(readonly row.nonOwner) |                 checked=(readonly row.nonOwner) | ||||||
|                 change=(action row.onOwnerChange value="target.checked") |                 change=(action row.onOwnerChange value="target.checked") | ||||||
|               }} |               }} | ||||||
| @ -209,7 +219,7 @@ | |||||||
| 
 | 
 | ||||||
|               {{ember-selector |               {{ember-selector | ||||||
|                 class="nacho-select--hidden-state" |                 class="nacho-select--hidden-state" | ||||||
|                 disabled=(not isEditing) |                 disabled=(or (not isEditing) row.isReadonly) | ||||||
|                 values=classifiers |                 values=classifiers | ||||||
|                 selected=row.classification |                 selected=row.classification | ||||||
|                 selectionDidChange=(action row.onFieldClassificationChange) |                 selectionDidChange=(action row.onFieldClassificationChange) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Seyi Adebajo
						Seyi Adebajo