mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-31 02:37:05 +00:00 
			
		
		
		
	Merge pull request #891 from theseyi/master
refactors informational text in purge policy into constant. adds inte…
This commit is contained in:
		
						commit
						f1fefc9714
					
				| @ -5,14 +5,29 @@ import { | |||||||
|   baseCommentEditorOptions, |   baseCommentEditorOptions, | ||||||
|   exemptPolicy, |   exemptPolicy, | ||||||
|   isExempt, |   isExempt, | ||||||
|  |   missingPolicyText, | ||||||
|   PurgePolicy, |   PurgePolicy, | ||||||
|   purgePolicyProps |   purgePolicyProps | ||||||
| } from 'wherehows-web/constants'; | } from 'wherehows-web/constants'; | ||||||
| import noop from 'wherehows-web/utils/noop'; | import noop from 'wherehows-web/utils/noop'; | ||||||
| 
 | 
 | ||||||
| export default Component.extend({ | export default Component.extend({ | ||||||
|  |   /** | ||||||
|  |    * Reference to the purge exempt policy | ||||||
|  |    * @type {string} | ||||||
|  |    */ | ||||||
|   exemptPolicy, |   exemptPolicy, | ||||||
| 
 | 
 | ||||||
|  |   /** | ||||||
|  |    * Reference to the informational text if the dataset does not have a saved purge policy | ||||||
|  |    * @type {string} | ||||||
|  |    */ | ||||||
|  |   missingPolicyText, | ||||||
|  | 
 | ||||||
|  |   /** | ||||||
|  |    * Reference to client options for each purge policy | ||||||
|  |    * @type {PurgePolicyProperties} | ||||||
|  |    */ | ||||||
|   purgePolicyProps, |   purgePolicyProps, | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|  | |||||||
| @ -35,7 +35,13 @@ const purgePolicyProps: PurgePolicyProperties = { | |||||||
|     displayAs: 'Auto Purge' |     displayAs: 'Auto Purge' | ||||||
|   }, |   }, | ||||||
|   MANUAL_PURGE: { |   MANUAL_PURGE: { | ||||||
|     platforms: [DatasetPlatform.MySql, DatasetPlatform.Espresso, DatasetPlatform.Teradata, DatasetPlatform.Oracle, DatasetPlatform.HDFS], |     platforms: [ | ||||||
|  |       DatasetPlatform.MySql, | ||||||
|  |       DatasetPlatform.Espresso, | ||||||
|  |       DatasetPlatform.Teradata, | ||||||
|  |       DatasetPlatform.Oracle, | ||||||
|  |       DatasetPlatform.HDFS | ||||||
|  |     ], | ||||||
|     desc: 'Choose this option only if you or your team have implemented a custom mechanism to purge this dataset.', |     desc: 'Choose this option only if you or your team have implemented a custom mechanism to purge this dataset.', | ||||||
|     displayAs: 'Manual Purge' |     displayAs: 'Manual Purge' | ||||||
|   }, |   }, | ||||||
| @ -69,4 +75,10 @@ const exemptPolicy = PurgePolicy.PurgeExempt; | |||||||
|  */ |  */ | ||||||
| const isExempt = (policy: PurgePolicy) => policy === PurgePolicy.PurgeExempt; | const isExempt = (policy: PurgePolicy) => policy === PurgePolicy.PurgeExempt; | ||||||
| 
 | 
 | ||||||
| export { PurgePolicy, purgePolicyProps, isExempt, exemptPolicy }; | /** | ||||||
|  |  * User informational text for datasets without a purge policy | ||||||
|  |  * @type {string} | ||||||
|  |  */ | ||||||
|  | const missingPolicyText = 'This dataset does not have a current compliance purge policy.'; | ||||||
|  | 
 | ||||||
|  | export { PurgePolicy, purgePolicyProps, isExempt, exemptPolicy, missingPolicyText }; | ||||||
|  | |||||||
| @ -1 +1,2 @@ | |||||||
| @import 'deprecated-dataset'; | @import 'deprecated-dataset'; | ||||||
|  | @import 'removed-dataset'; | ||||||
|  | |||||||
| @ -0,0 +1,5 @@ | |||||||
|  | .removed-dataset { | ||||||
|  |   @include pill(set-color(red, maroonflush), set-color(white, base)); | ||||||
|  |   margin-top: item-spacing(3); | ||||||
|  |   line-height: item-spacing(5); | ||||||
|  | } | ||||||
| @ -54,7 +54,7 @@ | |||||||
|       </li> |       </li> | ||||||
|     {{else}} |     {{else}} | ||||||
| 
 | 
 | ||||||
|       <p>This dataset does not have a current compliance purge policy.</p> |       <p>{{missingPolicyText}}</p> | ||||||
|       <sub>To update, click edit and follow the steps</sub> |       <sub>To update, click edit and follow the steps</sub> | ||||||
| 
 | 
 | ||||||
|     {{/if}} |     {{/if}} | ||||||
|  | |||||||
| @ -11,6 +11,23 @@ | |||||||
| 
 | 
 | ||||||
|     <div class="row"> |     <div class="row"> | ||||||
|       <div class="col-xs-5"> |       <div class="col-xs-5"> | ||||||
|  |         {{#if datasetView.removed}} | ||||||
|  |           <span class="removed-dataset"> | ||||||
|  |             REMOVED | ||||||
|  |           </span> | ||||||
|  | 
 | ||||||
|  |           <sup> | ||||||
|  |               <span | ||||||
|  |                 class="glyphicon glyphicon-question-sign" | ||||||
|  |                 title="This dataset has been removed"> | ||||||
|  |                 {{tooltip-on-element | ||||||
|  |                   event="hover" | ||||||
|  |                   text="This dataset has been removed" | ||||||
|  |                 }} | ||||||
|  |               </span> | ||||||
|  |           </sup> | ||||||
|  |         {{/if}} | ||||||
|  | 
 | ||||||
|         {{#if datasetView.deprecated}} |         {{#if datasetView.deprecated}} | ||||||
|           <a data-toggle="tab" href="#propertiestab" {{action "showProperties" preventDefault=false}}> |           <a data-toggle="tab" href="#propertiestab" {{action "showProperties" preventDefault=false}}> | ||||||
|             <span class="deprecated-dataset"> |             <span class="deprecated-dataset"> | ||||||
| @ -19,7 +36,7 @@ | |||||||
|             <sup> |             <sup> | ||||||
|               <span |               <span | ||||||
|                 class="glyphicon glyphicon-question-sign" |                 class="glyphicon glyphicon-question-sign" | ||||||
|                 title={{helpText.classification}}> |                 title="Click to view dataset properties"> | ||||||
|                 {{tooltip-on-element |                 {{tooltip-on-element | ||||||
|                   event="hover" |                   event="hover" | ||||||
|                   text="Click to view dataset properties" |                   text="Click to view dataset properties" | ||||||
|  | |||||||
| @ -0,0 +1,99 @@ | |||||||
|  | import { moduleForComponent, test } from 'ember-qunit'; | ||||||
|  | import hbs from 'htmlbars-inline-precompile'; | ||||||
|  | import { triggerEvent } from 'ember-native-dom-helpers'; | ||||||
|  | import { missingPolicyText, purgePolicyProps, exemptPolicy } from 'wherehows-web/constants'; | ||||||
|  | 
 | ||||||
|  | moduleForComponent('purge-policy', 'Integration | Component | purge policy', { | ||||||
|  |   integration: true | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | const policyList = '.purge-policy-list'; | ||||||
|  | const policyTypes = Object.keys(purgePolicyProps); | ||||||
|  | 
 | ||||||
|  | test('it renders', function(assert) { | ||||||
|  |   assert.expect(1); | ||||||
|  | 
 | ||||||
|  |   this.render(hbs`{{purge-policy}}`); | ||||||
|  | 
 | ||||||
|  |   assert.equal(document.querySelector(policyList).tagName, 'UL', 'expected component element is rendered'); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('it renders each purge policy in edit mode', function(assert) { | ||||||
|  |   assert.expect(1); | ||||||
|  |   const purgePoliciesLength = policyTypes.length; | ||||||
|  | 
 | ||||||
|  |   this.set('isEditable', true); | ||||||
|  |   this.render(hbs`{{purge-policy isEditable=isEditable}}`); | ||||||
|  | 
 | ||||||
|  |   assert.equal( | ||||||
|  |     document.querySelectorAll(`${policyList} [type=radio]`).length, | ||||||
|  |     purgePoliciesLength, | ||||||
|  |     'all policies are rendered' | ||||||
|  |   ); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('it triggers the onPolicyChange action', function(assert) { | ||||||
|  |   assert.expect(2); | ||||||
|  |   let onPolicyChangeActionCallCount = 0; | ||||||
|  | 
 | ||||||
|  |   this.set('isEditable', true); | ||||||
|  | 
 | ||||||
|  |   this.set('onPolicyChange', () => { | ||||||
|  |     assert.equal(++onPolicyChangeActionCallCount, 1, 'onPolicyChange action is invoked when change event is triggered'); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   this.render(hbs`{{purge-policy onPolicyChange=onPolicyChange isEditable=isEditable}}`); | ||||||
|  |   assert.equal(onPolicyChangeActionCallCount, 0, 'onPolicyChange action is not invoked on instantiation'); | ||||||
|  | 
 | ||||||
|  |   triggerEvent(`${policyList} [type=radio]`, 'change'); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('it renders a user message if the purge policy is not set and is in readonly mode', function(assert) { | ||||||
|  |   assert.expect(1); | ||||||
|  | 
 | ||||||
|  |   this.render(hbs`{{purge-policy}}`); | ||||||
|  |   assert.equal( | ||||||
|  |     document.querySelector(`${policyList} p`).textContent, | ||||||
|  |     missingPolicyText, | ||||||
|  |     `${missingPolicyText} is rendered` | ||||||
|  |   ); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('it indicates the currently selected purge policy', function(assert) { | ||||||
|  |   assert.expect(1); | ||||||
|  |   const selectedPolicy = policyTypes[1]; | ||||||
|  |   const platform = purgePolicyProps[selectedPolicy].platforms[0]; | ||||||
|  | 
 | ||||||
|  |   this.set('isEditable', true); | ||||||
|  |   this.set('platform', platform); | ||||||
|  |   this.set('purgePolicy', selectedPolicy); | ||||||
|  | 
 | ||||||
|  |   this.render(hbs`{{purge-policy isEditable=isEditable purgePolicy=purgePolicy platform=platform}}`); | ||||||
|  | 
 | ||||||
|  |   assert.ok( | ||||||
|  |     document.querySelector(`${policyList} [type=radio][value=${selectedPolicy}]`).checked, | ||||||
|  |     `${selectedPolicy} radio is checked` | ||||||
|  |   ); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('it focuses the comment element for exempt policy', function(assert) { | ||||||
|  |   assert.expect(1); | ||||||
|  | 
 | ||||||
|  |   const focusEditor = () => { | ||||||
|  |     assert.equal(++focusMethodCount, 1, 'focusEditor action is invoked'); | ||||||
|  |   }; | ||||||
|  |   let selectedPolicy = exemptPolicy; | ||||||
|  |   let platform = purgePolicyProps[selectedPolicy].platforms[0]; | ||||||
|  |   let focusMethodCount = 0; | ||||||
|  | 
 | ||||||
|  |   this.setProperties({ | ||||||
|  |     platform, | ||||||
|  |     focusEditor, | ||||||
|  |     isEditable: true, | ||||||
|  |     purgePolicy: selectedPolicy | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   this.render( | ||||||
|  |     hbs`{{purge-policy isEditable=isEditable purgePolicy=purgePolicy platform=platform focusEditor=focusEditor}}` | ||||||
|  |   ); | ||||||
|  | }); | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Seyi Adebajo
						Seyi Adebajo