@@ -24,6 +24,37 @@ import { useLibraryRoutes } from '../routes';
2424import messages from './messages' ;
2525import { ToastContext } from '../../generic/toast-context' ;
2626
27+ interface BlockHeaderProps {
28+ block : LibraryBlockMetadata ;
29+ onTagClick : ( ) => void ;
30+ }
31+
32+ /** Component header, split out to reuse in drag overlay */
33+ const BlockHeader = ( { block, onTagClick } : BlockHeaderProps ) => (
34+ < >
35+ < Stack direction = "horizontal" gap = { 2 } className = "font-weight-bold" >
36+ < Icon src = { getItemIcon ( block . blockType ) } />
37+ { block . displayName }
38+ </ Stack >
39+ < ActionRow . Spacer />
40+ < Stack direction = "horizontal" gap = { 3 } >
41+ { block . hasUnpublishedChanges && (
42+ < Badge
43+ className = "px-2 pt-1"
44+ variant = "warning"
45+ >
46+ < Stack direction = "horizontal" gap = { 1 } >
47+ < Icon className = "mb-1" size = "xs" src = { Description } />
48+ < FormattedMessage { ...messages . draftChipText } />
49+ </ Stack >
50+ </ Badge >
51+ ) }
52+ < TagCount size = "sm" count = { block . tagsCount } onClick = { onTagClick } />
53+ < ComponentMenu usageKey = { block . id } />
54+ </ Stack >
55+ </ >
56+ ) ;
57+
2758interface LibraryUnitBlocksProps {
2859 /** set to true if it is rendered as preview
2960 * This disables drag and drop
@@ -98,70 +129,46 @@ export const LibraryUnitBlocks = ({ preview }: LibraryUnitBlocksProps) => {
98129 return null ;
99130 }
100131 return (
101- < ActionRow className = ' bg-light-200 border border-light-500 p-2 rounded' >
102- < BlockHeader block = { block } />
132+ < ActionRow className = " bg-light-200 border border-light-500 p-2 rounded" >
133+ < BlockHeader block = { block } onTagClick = { openManageTagsDrawer } />
103134 < IconButton
104135 src = { DragIndicator }
105136 variant = "light"
106137 iconAs = { Icon }
107- alt = { '' }
138+ alt = ""
108139 />
109140 </ ActionRow >
110141 ) ;
111- }
112-
113- /** Component header, split out to reuse in drag overlay */
114- const BlockHeader = ( { block} : { block : LibraryBlockMetadata } ) => (
115- < >
116- < Stack direction = "horizontal" gap = { 2 } className = "font-weight-bold" >
117- < Icon src = { getItemIcon ( block . blockType ) } />
118- { block . displayName }
119- </ Stack >
120- < ActionRow . Spacer />
121- < Stack direction = "horizontal" gap = { 3 } >
122- { block . hasUnpublishedChanges && (
123- < Badge
124- className = "px-2 pt-1"
125- variant = "warning"
126- >
127- < Stack direction = "horizontal" gap = { 1 } >
128- < Icon className = "mb-1" size = "xs" src = { Description } />
129- < FormattedMessage { ...messages . draftChipText } />
130- </ Stack >
131- </ Badge >
132- ) }
133- < TagCount size = "sm" count = { block . tagsCount } onClick = { openManageTagsDrawer } />
134- < ComponentMenu usageKey = { block . id } />
135- </ Stack >
136- </ >
137- ) ;
142+ } ;
138143
139144 const renderedBlocks = orderedBlocks ?. map ( ( block ) => (
140145 < IframeProvider key = { block . id } >
141146 < SortableItem
142147 id = { block . id }
143148 componentStyle = { null }
144- actions = { < BlockHeader block = { block } /> }
149+ actions = { < BlockHeader block = { block } onTagClick = { openManageTagsDrawer } /> }
145150 actionStyle = { {
146151 borderRadius : '8px 8px 0px 0px' ,
147152 padding : '0.5rem 1rem' ,
148153 background : '#FBFAF9' ,
149154 borderBottom : 'solid 1px #E1DDDB' ,
150- outline : hidePreviewFor === block . id && '2px dashed gray'
155+ outline : hidePreviewFor === block . id && '2px dashed gray' ,
151156 } }
152157 isClickable
153158 onClick = { ( ) => handleComponentSelection ( block ) }
154159 disabled = { preview }
155160 >
156- { hidePreviewFor !== block . id && < div className = { classNames ( 'p-3' , {
161+ { hidePreviewFor !== block . id && (
162+ < div className = { classNames ( 'p-3' , {
157163 'container-mw-md' : block . blockType === blockTypes . video ,
158164 } ) }
159165 >
160166 < LibraryBlock
161167 usageKey = { block . id }
162168 version = { showOnlyPublished ? 'published' : undefined }
163169 />
164- </ div > }
170+ </ div >
171+ ) }
165172 </ SortableItem >
166173 </ IframeProvider >
167174 ) ) ;
0 commit comments