mirror of
				https://github.com/scm-manager/scm-manager.git
				synced 2025-10-31 02:25:53 +01:00 
			
		
		
		
	use reflow to migrate from flow to typescript
This commit is contained in:
		
							
								
								
									
										39
									
								
								scm-ui/ui-components/src/repos/changesets/ChangesetDiff.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								scm-ui/ui-components/src/repos/changesets/ChangesetDiff.tsx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| import React from 'react'; | ||||
| import { Changeset } from '@scm-manager/ui-types'; | ||||
| import LoadingDiff from '../LoadingDiff'; | ||||
| import Notification from '../../Notification'; | ||||
| import { translate } from 'react-i18next'; | ||||
|  | ||||
| type Props = { | ||||
|   changeset: Changeset; | ||||
|   defaultCollapse?: boolean; | ||||
|  | ||||
|   // context props | ||||
|   t: (p: string) => string; | ||||
| }; | ||||
|  | ||||
| class ChangesetDiff extends React.Component<Props> { | ||||
|   isDiffSupported(changeset: Changeset) { | ||||
|     return !!changeset._links.diff; | ||||
|   } | ||||
|  | ||||
|   createUrl(changeset: Changeset) { | ||||
|     return changeset._links.diff.href + '?format=GIT'; | ||||
|   } | ||||
|  | ||||
|   render() { | ||||
|     const { changeset, defaultCollapse, t } = this.props; | ||||
|     if (!this.isDiffSupported(changeset)) { | ||||
|       return ( | ||||
|         <Notification type="danger"> | ||||
|           {t('changeset.diffNotSupported')} | ||||
|         </Notification> | ||||
|       ); | ||||
|     } else { | ||||
|       const url = this.createUrl(changeset); | ||||
|       return <LoadingDiff url={url} defaultCollapse={defaultCollapse} />; | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default translate('repos')(ChangesetDiff); | ||||
		Reference in New Issue
	
	Block a user