mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	more event-differ
This commit is contained in:
		
							parent
							
								
									cc8ccfd403
								
							
						
					
					
						commit
						be35162a94
					
				
							
								
								
									
										16
									
								
								frontend/dist/bundle.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								frontend/dist/bundle.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								frontend/dist/bundle.js.map
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								frontend/dist/bundle.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -18,6 +18,67 @@ const SPADEN_CLASS = { | |||||||
|     N: style.positive, // added |     N: style.positive, // added | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | function getIcon (type) { | ||||||
|  |     if (type.indexOf('created') > -1 ) { | ||||||
|  |         return 'add'; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (type.indexOf('deleted') > -1 ) { | ||||||
|  |         return 'remove'; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (type.indexOf('updated') > -1 ) { | ||||||
|  |         return 'update'; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (type.indexOf('archived') > -1 ) { | ||||||
|  |         return 'archived'; | ||||||
|  |     } | ||||||
|  |     return 'bookmark'; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function buildItemDiff (diff, key) { | ||||||
|  |     let change; | ||||||
|  |     if (diff.lhs !== undefined) { | ||||||
|  |         change = ( | ||||||
|  |             <div> | ||||||
|  |                 <div className={SPADEN_CLASS.D}>- {key}: {JSON.stringify(diff.lhs)}</div> | ||||||
|  |             </div> | ||||||
|  |         ); | ||||||
|  |     } else if (diff.rhs !== undefined) { | ||||||
|  |         change = ( | ||||||
|  |             <div> | ||||||
|  |                 <div className={SPADEN_CLASS.N}>+ {key}: {JSON.stringify(diff.rhs)}</div> | ||||||
|  |             </div> | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return change; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function buildDiff (diff, idx) { | ||||||
|  |     let change; | ||||||
|  |     const key = diff.path.join('.'); | ||||||
|  | 
 | ||||||
|  |     if (diff.item) { | ||||||
|  |         change = buildItemDiff(diff.item, key); | ||||||
|  |     } else if (diff.lhs !== undefined && diff.rhs !== undefined) { | ||||||
|  |         change = ( | ||||||
|  |             <div> | ||||||
|  |                 <div className={SPADEN_CLASS.D}>- {key}: {JSON.stringify(diff.lhs)}</div> | ||||||
|  |                 <div className={SPADEN_CLASS.N}>+ {key}: {JSON.stringify(diff.rhs)}</div> | ||||||
|  |             </div> | ||||||
|  |         ); | ||||||
|  |     } else { | ||||||
|  |         const spadenClass = SPADEN_CLASS[diff.kind]; | ||||||
|  |         const prefix      = DIFF_PREFIXES[diff.kind]; | ||||||
|  | 
 | ||||||
|  |         change = (<div className={spadenClass}>{prefix} {key}: {JSON.stringify(diff.rhs || diff.item)}</div>); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return (<div key={idx}>{change}</div>); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| class HistoryItem extends Component { | class HistoryItem extends Component { | ||||||
| 
 | 
 | ||||||
|     static propTypes () { |     static propTypes () { | ||||||
| @ -26,51 +87,11 @@ class HistoryItem extends Component { | |||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     getIcon (type) { |  | ||||||
|         if (type.indexOf('created') > -1 ) { |  | ||||||
|             return 'add'; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (type.indexOf('deleted') > -1 ) { |  | ||||||
|             return 'remove'; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (type.indexOf('updated') > -1 ) { |  | ||||||
|             return 'update'; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (type.indexOf('archived') > -1 ) { |  | ||||||
|             return 'archived'; |  | ||||||
|         } |  | ||||||
|         return 'bookmark'; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     buildDiff (diff, idx) { |  | ||||||
|         let change; |  | ||||||
|         const key = diff.path.join('.'); |  | ||||||
| 
 |  | ||||||
|         if (diff.lhs !== undefined && diff.rhs !== undefined) { |  | ||||||
|             change = ( |  | ||||||
|                 <div> |  | ||||||
|                   <div className={SPADEN_CLASS.D}>- {key}: {JSON.stringify(diff.lhs)}</div> |  | ||||||
|                   <div className={SPADEN_CLASS.N}>+ {key}: {JSON.stringify(diff.rhs)}</div> |  | ||||||
|                 </div> |  | ||||||
|             ); |  | ||||||
|         } else { |  | ||||||
|             const spadenClass = SPADEN_CLASS[diff.kind]; |  | ||||||
|             const prefix      = DIFF_PREFIXES[diff.kind]; |  | ||||||
| 
 |  | ||||||
|             change = (<div className={spadenClass}>{prefix} {key}: {JSON.stringify(diff.rhs)}</div>); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         return (<div key={idx}>{change}</div>); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     renderEventDiff (logEntry) { |     renderEventDiff (logEntry) { | ||||||
|         if (!logEntry.diffs) { |         if (!logEntry.diffs) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         const changes = logEntry.diffs.map(this.buildDiff); |         const changes = logEntry.diffs.map(buildDiff); | ||||||
|         return ( |         return ( | ||||||
|             <code className="smalltext man">{changes.length === 0 ? '(no changes)' : changes}</code> |             <code className="smalltext man">{changes.length === 0 ? '(no changes)' : changes}</code> | ||||||
|         ); |         ); | ||||||
| @ -95,7 +116,7 @@ class HistoryItem extends Component { | |||||||
|         } = this.props.entry; |         } = this.props.entry; | ||||||
| 
 | 
 | ||||||
|         const createdAt = (new Date(this.props.entry.createdAt)).toLocaleString('nb-NO'); |         const createdAt = (new Date(this.props.entry.createdAt)).toLocaleString('nb-NO'); | ||||||
|         const icon = this.getIcon(type); |         const icon = getIcon(type); | ||||||
| 
 | 
 | ||||||
|         const data = this.props.showData ? |         const data = this.props.showData ? | ||||||
|             this.renderFullEventData(this.props.entry) : this.renderEventDiff(this.props.entry); |             this.renderFullEventData(this.props.entry) : this.renderEventDiff(this.props.entry); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user