@@ -4,6 +4,7 @@ import messages from './messages';
44import { Dropdown , Icon , IconButton , Stack } from '@openedx/paragon' ;
55import { ContributorAvatar } from './ContributorAvatars' ;
66import { getItemIcon } from '@src/generic/block-type-utils' ;
7+ import { isContainerUsageKey } from '@src/generic/key-utils' ;
78import moment from 'moment' ;
89import { MoreVert } from '@openedx/paragon/icons' ;
910import { useToggleWithValue } from '@src/hooks' ;
@@ -19,7 +20,9 @@ export const HistoryLogGroupEntries = ({
1920 entries,
2021} : HistoryLogGroupEntriesProps ) => {
2122 const intl = useIntl ( ) ;
22- const [ isChangeModalOpen , changeModalData , openChangeModal , closeChangeModal ] = useToggleWithValue < LibraryHistoryEntry > ( ) ;
23+ const [ isChangeModalOpen , changeModalData , openChangeModal , closeChangeModal ] = useToggleWithValue <
24+ LibraryHistoryEntry
25+ > ( ) ;
2326
2427 const getEntryMessage = ( entry : LibraryHistoryEntry ) => {
2528 switch ( entry . action ) {
@@ -36,67 +39,70 @@ export const HistoryLogGroupEntries = ({
3639
3740 return (
3841 < >
39- < Stack gap = { 0 } >
40- < div className = "history-log-vert" />
41- { entries . map ( ( entry , index , arr ) => {
42- const isLast = index === arr . length - 1 ;
43- const entryMessage = getEntryMessage ( entry ) ;
42+ < Stack gap = { 0 } >
43+ < div className = "history-log-vert" />
44+ { entries . map ( ( entry , index , arr ) => {
45+ const isLast = index === arr . length - 1 ;
46+ const entryMessage = getEntryMessage ( entry ) ;
4447
45- return (
46- < div key = { entry . changedAt } >
47- < Stack direction = "horizontal" gap = { 2 } className = "ml-1.5" >
48- < ContributorAvatar
49- username = { entry . contributor ?. username || intl . formatMessage ( messages . historyEntryDefaultUser ) }
50- src = { entry . contributor ?. profileImageUrls . medium }
51- className = "history-log-group-avatar small-avatar"
52- size = "sm"
53- />
54- < Stack >
55- < Stack direction = "horizontal" gap = { 1 } >
56- < FormattedMessage
57- { ...entryMessage }
58- values = { {
59- user : entry . contributor ?. username ?? intl . formatMessage ( messages . historyEntryDefaultUser ) ,
60- displayName : < span className = "history-log-title text-truncate" > { entry . title } </ span > ,
61- icon : < Icon src = { getItemIcon ( entry . itemType ) } /> ,
62- } }
63- />
48+ return (
49+ < div key = { entry . changedAt } >
50+ < Stack direction = "horizontal" gap = { 2 } className = "ml-1.5" >
51+ < ContributorAvatar
52+ username = { entry . contributor ?. username || intl . formatMessage ( messages . historyEntryDefaultUser ) }
53+ src = { entry . contributor ?. profileImageUrls . medium }
54+ className = "history-log-group-avatar small-avatar"
55+ size = "sm"
56+ />
57+ < Stack >
58+ < Stack direction = "horizontal" gap = { 1 } >
59+ < FormattedMessage
60+ { ...entryMessage }
61+ values = { {
62+ user : entry . contributor ?. username ?? intl . formatMessage ( messages . historyEntryDefaultUser ) ,
63+ displayName : < span className = "history-log-title text-truncate" > { entry . title } </ span > ,
64+ icon : < Icon src = { getItemIcon ( entry . itemType ) } /> ,
65+ } }
66+ />
67+ </ Stack >
68+ < span className = "small text-gray-500" >
69+ { moment ( entry . changedAt ) . fromNow ( ) }
70+ </ span >
6471 </ Stack >
65- < span className = "small text-gray-500" >
66- { moment ( entry . changedAt ) . fromNow ( ) }
67- </ span >
72+ { ! isContainerUsageKey ( itemId ) &&
73+ (
74+ < Dropdown >
75+ < Dropdown . Toggle
76+ id = "dropdown-toggle-with-iconbutton"
77+ as = { IconButton }
78+ src = { MoreVert }
79+ iconAs = { Icon }
80+ variant = "primary"
81+ aria-label = { intl . formatMessage ( messages . moreActions ) }
82+ />
83+ < Dropdown . Menu >
84+ < Dropdown . Item onClick = { ( ) => openChangeModal ( entry ) } >
85+ { intl . formatMessage ( messages . showThisVersion ) }
86+ </ Dropdown . Item >
87+ </ Dropdown . Menu >
88+ </ Dropdown >
89+ ) }
6890 </ Stack >
69- < Dropdown >
70- < Dropdown . Toggle
71- id = "dropdown-toggle-with-iconbutton"
72- as = { IconButton }
73- src = { MoreVert }
74- iconAs = { Icon }
75- variant = "primary"
76- aria-label = { intl . formatMessage ( messages . moreActions ) }
77- />
78- < Dropdown . Menu >
79- < Dropdown . Item onClick = { ( ) => openChangeModal ( entry ) } >
80- { intl . formatMessage ( messages . showThisVersion ) }
81- </ Dropdown . Item >
82- </ Dropdown . Menu >
83- </ Dropdown >
84- </ Stack >
85- { ! isLast && < div className = "history-log-vert" /> }
86- </ div >
87- ) ;
88- } ) }
89- </ Stack >
90- { isChangeModalOpen && changeModalData && (
91- < HistoryCompareChangesModal
92- isOpen = { isChangeModalOpen }
93- onClose = { closeChangeModal }
94- usageKey = { itemId }
95- oldTitle = { changeModalData . title }
96- oldVersion = { changeModalData . oldVersion }
97- newVersion = { changeModalData . newVersion || 'published' }
98- />
99- ) }
100- </ >
91+ { ! isLast && < div className = "history-log-vert" /> }
92+ </ div >
93+ ) ;
94+ } ) }
95+ </ Stack >
96+ { isChangeModalOpen && changeModalData && (
97+ < HistoryCompareChangesModal
98+ isOpen = { isChangeModalOpen }
99+ onClose = { closeChangeModal }
100+ usageKey = { itemId }
101+ oldTitle = { changeModalData . title }
102+ oldVersion = { changeModalData . oldVersion }
103+ newVersion = { changeModalData . newVersion || 'published' }
104+ />
105+ ) }
106+ </ >
101107 ) ;
102108} ;
0 commit comments