| 
									
										
										
										
											2017-10-20 21:34:58 -07:00
										 |  |  | import Ember from 'ember'; | 
					
						
							| 
									
										
										
										
											2017-10-09 10:58:35 -07:00
										 |  |  | import { fieldIdentifierTypes } from 'wherehows-web/constants/metadata-acquisition'; | 
					
						
							| 
									
										
										
										
											2017-10-20 21:34:58 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | const { String: { htmlSafe } } = Ember; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-18 15:01:28 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Defines a map of values for the compliance policy on a dataset | 
					
						
							| 
									
										
										
										
											2017-09-10 19:31:54 -07:00
										 |  |  |  * @type {object} | 
					
						
							| 
									
										
										
										
											2017-07-18 15:01:28 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | const compliancePolicyStrings = { | 
					
						
							| 
									
										
										
										
											2017-09-20 14:25:27 -07:00
										 |  |  |   // TODO:  DSS-6122 Create and move to Error module
 | 
					
						
							| 
									
										
										
										
											2017-07-18 15:01:28 -07:00
										 |  |  |   complianceDataException: 'Unexpected discrepancy in compliance data', | 
					
						
							| 
									
										
										
										
											2017-09-19 10:57:59 -07:00
										 |  |  |   missingTypes: 'Looks like you may have forgotten to specify a `Field Format` for all ID fields?', | 
					
						
							| 
									
										
										
										
											2017-08-30 10:26:44 -07:00
										 |  |  |   successUpdating: 'Congrats! Your changes have been successfully saved!', | 
					
						
							| 
									
										
										
										
											2017-07-18 15:01:28 -07:00
										 |  |  |   failedUpdating: 'Oops! We are having trouble updating this dataset at the moment.', | 
					
						
							| 
									
										
										
										
											2017-08-30 10:26:44 -07:00
										 |  |  |   successUploading: 'Metadata successfully updated! Please "Save" when ready.', | 
					
						
							|  |  |  |   invalidPolicyData: 'Received policy in an unexpected format! Please check the provided attributes and try again.', | 
					
						
							| 
									
										
										
										
											2017-07-18 15:01:28 -07:00
										 |  |  |   helpText: { | 
					
						
							|  |  |  |     classification: | 
					
						
							|  |  |  |       'The default value is taken from go/dht and should be good enough in most cases. ' + | 
					
						
							| 
									
										
										
										
											2017-08-30 10:26:44 -07:00
										 |  |  |       'You can optionally override it if required by house security.' | 
					
						
							| 
									
										
										
										
											2017-07-18 15:01:28 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-09 10:58:35 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * List of identifier type keys without the none object value | 
					
						
							|  |  |  |  * @type {Array<string>} | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | const fieldIdentifierTypeKeysBarNone: Array<string> = Object.keys(fieldIdentifierTypes).filter(k => k !== 'none'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Keys for the field display options | 
					
						
							|  |  |  |  * @type {Array<string>} | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | const fieldDisplayKeys: Array<string> = ['none', '_', ...fieldIdentifierTypeKeysBarNone]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * A list of field identifier types mapped to label, value options for select display | 
					
						
							|  |  |  |  * @type {Array<{value: string, label: string, isDisabled: boolean}>} | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | const fieldIdentifierOptions: Array<{ | 
					
						
							|  |  |  |   value: string; | 
					
						
							|  |  |  |   label: string; | 
					
						
							|  |  |  |   isDisabled: boolean; | 
					
						
							|  |  |  | }> = fieldDisplayKeys.map(fieldIdentifierType => { | 
					
						
							|  |  |  |   const divider = '──────────'; | 
					
						
							|  |  |  |   const { value = fieldIdentifierType, displayAs: label = divider } = fieldIdentifierTypes[fieldIdentifierType] || {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Adds a divider for a value of _
 | 
					
						
							|  |  |  |   // Visually this separates ID from none fieldIdentifierTypes
 | 
					
						
							|  |  |  |   return { | 
					
						
							|  |  |  |     value, | 
					
						
							|  |  |  |     label, | 
					
						
							|  |  |  |     isDisabled: fieldIdentifierType === '_' | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-20 21:34:58 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Defines the html string for informing the user of hidden tracking fields | 
					
						
							|  |  |  |  * @type {Ember.String.htmlSafe} | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | const hiddenTrackingFields = htmlSafe( | 
					
						
							|  |  |  |   '<p>Some fields in this dataset have been hidden from the table(s) below. ' + | 
					
						
							|  |  |  |     "These are tracking fields for which we've been able to predetermine the compliance classification.</p>" + | 
					
						
							|  |  |  |     '<p>For example: <code>header.memberId</code>, <code>requestHeader</code>. ' + | 
					
						
							|  |  |  |     'Hopefully, this saves you some scrolling!</p>' | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Defines the sequence of edit steps in the compliance policy component | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | const complianceSteps = { | 
					
						
							|  |  |  |   0: { | 
					
						
							|  |  |  |     name: 'editCompliancePolicy' | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   1: { | 
					
						
							|  |  |  |     name: 'editPurgePolicy' | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   2: { | 
					
						
							|  |  |  |     name: 'editDatasetClassification' | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export { compliancePolicyStrings, fieldIdentifierOptions, complianceSteps, hiddenTrackingFields }; |