11import React from 'react'
2+ import { useHistory } from 'react-router-dom' ;
23import moment from 'moment'
34import Skeleton from '@mui/material/Skeleton' ;
45import Timeline from '@mui/lab/Timeline' ;
@@ -19,16 +20,21 @@ import compact from 'lodash/compact'
1920import map from 'lodash/map'
2021
2122import { copyURL } from '../../common/utils' ;
23+ import UserChip from '../users/UserChip'
24+ import RepoChip from '../repos/RepoChip'
2225
2326const History = ( { versions, loading, icon, resource } ) => {
27+ const history = useHistory ( )
2428 const getRepoDetails = uri => {
2529 const parts = compact ( uri . split ( '/' ) )
2630 return {
2731 ownerType : parts [ 0 ] ,
2832 owner : parts [ 1 ] ,
33+ type : parts [ 2 ] === 'sources' ? 'Source Version' : ( parts [ 2 ] === 'collections' ? 'Collection Version' : parts [ 2 ] ) ,
2934 id : parts [ 3 ] ,
3035 version : parts [ 4 ] ,
31- uri : uri
36+ uri : uri ,
37+ version_url : uri
3238 }
3339 }
3440 return (
@@ -95,21 +101,21 @@ const History = ({ versions, loading, icon, resource }) => {
95101 }
96102 </ TimelineSeparator >
97103 < TimelineContent >
98- < Card variant = "outlined" >
104+ < Card variant = "outlined" sx = { { cursor : 'pointer' } } onClick = { event => { event . preventDefault ( ) ; event . stopPropagation ( ) ; history . push ( url ) ; return false ; } } >
99105 < CardContent sx = { { padding : '4px 12px !important' } } >
100106 < div className = 'col-xs-12 padding-0' style = { { display : 'flex' } } >
101107 < div className = 'col-xs-8 padding-left-0' >
102- < Button variant = 'text' color = 'primary' href = { `# ${ version . version_url } ` } sx = { { margin : 0 , padding : 0 , fontSize : '12px' , textTransform : 'none' , minWidth : 'auto' } } >
103- < Typography sx = { { fontSize : '16px' } } component = "div" >
104- {
105- version . update_comment ?
106- version . update_comment :
107- < i > - </ i >
108- }
109- </ Typography >
110- </ Button >
111- < Typography sx = { { fontSize : '12px' } } color = "text.secondary" >
112- < Button variant = 'text' href = { `#/users/ ${ version . version_updated_by } ` } sx = { { margin : 0 , padding : 0 , fontSize : '12px' , textTransform : 'none' , minWidth : 'auto' } } > { version . version_updated_by } </ Button > updated { moment ( version . version_updated_on ) . fromNow ( ) }
108+ {
109+ version . update_comment &&
110+ < Button variant = 'text' color = 'primary' href = { `# ${ version . version_url } ` } sx = { { margin : 0 , padding : 0 , fontSize : '12px' , textTransform : 'none' , minWidth : 'auto' } } >
111+ < Typography sx = { { fontSize : '16px' } } component = "div" >
112+ { version . update_comment }
113+ </ Typography >
114+ </ Button >
115+ }
116+ < Typography sx = { { fontSize : '12px' , display : 'inline-flex' , alignItems : 'center' } } color = "text.secondary" component = 'span' >
117+ < UserChip size = 'small' hideType user = { { username : version . version_updated_by , type : 'User' , url : `/users/ ${ version . version_updated_by } ` } } sx = { { '.MuiChip-label' : { padding : 0 } , marginRight : '4px' , border : 0 , padding : 0 , minWidth : 'auto' , '.MuiAvatar-root' : { margin : '0 4px 0 0' , width : '16px' , height : '16px' , background : 'transparent' } } } / >
118+ updated { moment ( version . version_updated_on ) . fromNow ( ) }
113119 </ Typography >
114120 {
115121 version . source_versions ?. length > 0 ?
@@ -121,7 +127,7 @@ const History = ({ versions, loading, icon, resource }) => {
121127 map ( version . source_versions , repoVersion => {
122128 const repo = getRepoDetails ( repoVersion )
123129 return (
124- < Button key = { repoVersion } variant = 'text' href = { `# ${ repoVersion } ` } sx = { { margin : '0 4px' , padding : 0 , fontSize : '12px' , textTransform : 'none' , minWidth : 'auto' } } > { repo . id } / { repo . version } </ Button >
130+ < RepoChip hideType key = { repoVersion } repo = { repo } size = 'small' sx = { { padding : '4px' , '.MuiChip-label' : { padding : '0 2px 0 0' } , margin : '2px 0' } } / >
125131 )
126132 } )
127133 }
@@ -137,7 +143,7 @@ const History = ({ versions, loading, icon, resource }) => {
137143 map ( version . collection_versions , repoVersion => {
138144 const repo = getRepoDetails ( repoVersion )
139145 return (
140- < Button key = { repoVersion } variant = 'text' href = { `# ${ repoVersion } ` } sx = { { margin : '0 4px' , padding : 0 , fontSize : '12px' , textTransform : 'none' , minWidth : 'auto' } } > { repo . id } / { repo . version } </ Button >
146+ < RepoChip hideType key = { repoVersion } repo = { repo } size = 'small' sx = { { padding : '4px' , '.MuiChip-label' : { padding : '0 2px 0 0' } , margin : '2px 0' } } / >
141147 )
142148 } )
143149 }
0 commit comments