11import React , { useRef } from "react" ;
22import { useTranslation } from "react-i18next" ;
3- import ConfirmModal from "../../shared/ConfirmModal" ;
43import EmbeddingCodeModal from "./modals/EmbeddingCodeModal" ;
54import { getUserInformation } from "../../../selectors/userInfoSelectors" ;
65import { hasAccess } from "../../../utils/utils" ;
@@ -17,6 +16,8 @@ import {
1716import { Event , deleteEvent } from "../../../slices/eventSlice" ;
1817import { Tooltip } from "../../shared/Tooltip" ;
1918import { openModal } from "../../../slices/eventDetailsSlice" ;
19+ import { ActionCellDelete } from "../../shared/ActionCellDelete" ;
20+ import { IconButton } from "../../shared/IconButton" ;
2021import { Modal , ModalHandle } from "../../shared/modals/Modal" ;
2122
2223/**
@@ -30,16 +31,11 @@ const EventActionCell = ({
3031 const { t } = useTranslation ( ) ;
3132 const dispatch = useAppDispatch ( ) ;
3233
33- const deleteConfirmationModalRef = useRef < ModalHandle > ( null ) ;
3434 const seriesDetailsModalRef = useRef < ModalHandle > ( null ) ;
3535 const embeddingCodeModalRef = useRef < ModalHandle > ( null ) ;
3636
3737 const user = useAppSelector ( state => getUserInformation ( state ) ) ;
3838
39- const hideDeleteConfirmation = ( ) => {
40- deleteConfirmationModalRef . current ?. close ?.( )
41- } ;
42-
4339 const deletingEvent = ( id : string ) => {
4440 dispatch ( deleteEvent ( id ) ) ;
4541 } ;
@@ -95,44 +91,32 @@ const EventActionCell = ({
9591 ) }
9692
9793 { /* Open event details */ }
98- { hasAccess ( "ROLE_UI_EVENTS_DETAILS_VIEW" , user ) && (
99- < Tooltip title = { t ( "EVENTS.EVENTS.TABLE.TOOLTIP.DETAILS" ) } >
100- < button
101- onClick = { ( ) => onClickEventDetails ( ) }
102- className = "button-like-anchor more"
103- />
104- </ Tooltip >
105- ) }
94+ < IconButton
95+ callback = { onClickEventDetails }
96+ iconClassname = { "more" }
97+ editAccessRole = { "ROLE_UI_EVENTS_DETAILS_VIEW" }
98+ tooltipText = { "EVENTS.EVENTS.TABLE.TOOLTIP.DETAILS" }
99+ />
106100
107101 { /* If event belongs to a series then the corresponding series details can be opened */ }
108- { ! ! row . series && hasAccess ( "ROLE_UI_SERIES_DETAILS_VIEW" , user ) && (
109- < Tooltip title = { t ( "EVENTS.SERIES.TABLE.TOOLTIP.DETAILS" ) } >
110- < button
111- onClick = { ( ) => onClickSeriesDetails ( ) }
112- className = "button-like-anchor more-series"
113- />
114- </ Tooltip >
102+ { ! ! row . series && (
103+ < IconButton
104+ callback = { onClickSeriesDetails }
105+ iconClassname = { "more-series" }
106+ editAccessRole = { "ROLE_UI_SERIES_DETAILS_VIEW" }
107+ tooltipText = { "EVENTS.SERIES.TABLE.TOOLTIP.DETAILS" }
108+ / >
115109 ) }
116110
117111 { /* Delete an event */ }
118112 { /*TODO: needs to be checked if event is published */ }
119- { hasAccess ( "ROLE_UI_EVENTS_DELETE" , user ) && (
120- < Tooltip title = { t ( "EVENTS.EVENTS.TABLE.TOOLTIP.DELETE" ) } >
121- < button
122- onClick = { ( ) => deleteConfirmationModalRef . current ?. open ( ) }
123- className = "button-like-anchor remove"
124- />
125- </ Tooltip >
126- ) }
127-
128- { /* Confirmation for deleting an event*/ }
129- < ConfirmModal
130- close = { hideDeleteConfirmation }
131- resourceName = { row . title }
132- resourceType = "EVENT"
113+ < ActionCellDelete
114+ editAccessRole = { "ROLE_UI_EVENTS_DELETE" }
115+ tooltipText = { "EVENTS.EVENTS.TABLE.TOOLTIP.DELETE" }
133116 resourceId = { row . id }
117+ resourceName = { row . title }
118+ resourceType = { "EVENT" }
134119 deleteMethod = { deletingEvent }
135- modalRef = { deleteConfirmationModalRef }
136120 />
137121
138122 { /* If the event has an preview then the editor can be opened and status if it needs to be cut is shown */ }
@@ -156,54 +140,48 @@ const EventActionCell = ({
156140
157141 { /* If the event has comments and no open comments then the comment tab of event details can be opened directly */ }
158142 { row . has_comments && ! row . has_open_comments && (
159- < Tooltip title = { t ( "EVENTS.EVENTS.TABLE.TOOLTIP.COMMENTS" ) } >
160- < button
161- onClick = { ( ) => onClickComments ( ) }
162- className = "button-like-anchor comments"
163- />
164- </ Tooltip >
143+ < IconButton
144+ callback = { ( ) => onClickComments ( ) }
145+ iconClassname = { "comments" }
146+ tooltipText = { "EVENTS.EVENTS.TABLE.TOOLTIP.COMMENTS" }
147+ />
165148 ) }
166149
167150 { /* If the event has comments and open comments then the comment tab of event details can be opened directly */ }
168151 { row . has_comments && row . has_open_comments && (
169- < Tooltip title = { t ( "EVENTS.EVENTS.TABLE.TOOLTIP.COMMENTS" ) } >
170- < button
171- onClick = { ( ) => onClickComments ( ) }
172- className = "button-like-anchor comments-open"
173- />
174- </ Tooltip >
152+ < IconButton
153+ callback = { ( ) => onClickComments ( ) }
154+ iconClassname = { "comments-open" }
155+ tooltipText = { "EVENTS.EVENTS.TABLE.TOOLTIP.COMMENTS" }
156+ />
175157 ) }
176158
177159 { /*If the event is in in a paused workflow state then a warning icon is shown and workflow tab of event
178- details can be opened directly */}
160+ details can be opened directly */}
179161 { row . workflow_state === "PAUSED" &&
180- hasAccess ( "ROLE_UI_EVENTS_DETAILS_WORKFLOWS_EDIT" , user ) && (
181- < Tooltip title = { t ( "EVENTS.EVENTS.TABLE.TOOLTIP.PAUSED_WORKFLOW" ) } >
182- < button
183- onClick = { ( ) => onClickWorkflow ( ) }
184- className = "button-like-anchor fa fa-warning"
185- />
186- </ Tooltip >
187- ) }
162+ < IconButton
163+ callback = { ( ) => onClickWorkflow ( ) }
164+ iconClassname = { "fa fa-warning" }
165+ editAccessRole = { "ROLE_UI_EVENTS_DETAILS_WORKFLOWS_EDIT" }
166+ tooltipText = { "EVENTS.EVENTS.TABLE.TOOLTIP.PAUSED_WORKFLOW" }
167+ />
168+ }
188169
189170 { /* Open assets tab of event details directly*/ }
190- { hasAccess ( "ROLE_UI_EVENTS_DETAILS_ASSETS_VIEW" , user ) && (
191- < Tooltip title = { t ( "EVENTS.EVENTS.TABLE.TOOLTIP.ASSETS" ) } >
192- < button
193- onClick = { ( ) => onClickAssets ( ) }
194- className = "button-like-anchor fa fa-folder-open"
195- />
196- </ Tooltip >
197- ) }
171+ < IconButton
172+ callback = { ( ) => onClickAssets ( ) }
173+ iconClassname = { "fa fa-folder-open" }
174+ editAccessRole = { "ROLE_UI_EVENTS_DETAILS_ASSETS_VIEW" }
175+ tooltipText = { "EVENTS.EVENTS.TABLE.TOOLTIP.ASSETS" }
176+ />
177+
198178 { /* Open dialog for embedded code*/ }
199- { hasAccess ( "ROLE_UI_EVENTS_EMBEDDING_CODE_VIEW" , user ) && (
200- < Tooltip title = { t ( "EVENTS.EVENTS.TABLE.TOOLTIP.EMBEDDING_CODE" ) } >
201- < button
202- onClick = { ( ) => showEmbeddingCodeModal ( ) }
203- className = "button-like-anchor fa fa-link"
204- />
205- </ Tooltip >
206- ) }
179+ < IconButton
180+ callback = { ( ) => showEmbeddingCodeModal ( ) }
181+ iconClassname = { "fa fa-link" }
182+ editAccessRole = { "ROLE_UI_EVENTS_EMBEDDING_CODE_VIEW" }
183+ tooltipText = { "EVENTS.EVENTS.TABLE.TOOLTIP.EMBEDDING_CODE" }
184+ />
207185
208186 { /* Embedding Code Modal */ }
209187 < Modal
0 commit comments