11import React from "react" ;
22
3- import { ValidIconName } from "../../components/Icon/canonicalIconNames" ;
4- import { IconProps } from "../../components/Icon/Icon" ;
5- import { TestIconProps } from "../../components/Icon/TestIcon" ;
6- import { TestableComponent } from "../../components/interfaces" ;
7- import { ProgressBarProps } from "../../components/ProgressBar/ProgressBar" ;
8- import { SpinnerProps } from "../../components/Spinner/Spinner" ;
9- import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
3+ import { ValidIconName } from "../../components/Icon/canonicalIconNames" ;
4+ import { IconProps } from "../../components/Icon/Icon" ;
5+ import { TestIconProps } from "../../components/Icon/TestIcon" ;
6+ import { TestableComponent } from "../../components/interfaces" ;
7+ import { ProgressBarProps } from "../../components/ProgressBar/ProgressBar" ;
8+ import { SpinnerProps } from "../../components/Spinner/Spinner" ;
9+ import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
1010import {
1111 Card ,
1212 ContextMenu ,
13+ DecoupledOverlay ,
1314 IconButton ,
1415 MenuItem ,
16+ Notification ,
17+ NotificationProps ,
1518 OverflowText ,
1619 OverviewItem ,
1720 OverviewItemActions ,
@@ -97,14 +100,24 @@ interface IActivityContextMenu extends TestableComponent {
97100export interface ActivityControlWidgetAction extends TestableComponent {
98101 // The action that should be triggered
99102 action : ( ) => void ;
100- // The tooltip that should be shown over the action icon
103+ // The tooltip that should be shown over the action icon on hover
101104 tooltip ?: string ;
102105 // The icon of the action button
103106 icon : ValidIconName | React . ReactElement < TestIconProps > ;
104107 // Action is currently disabled (but shown)
105108 disabled ?: boolean ;
106109 // Warning state
107110 hasStateWarning ?: boolean ;
111+ // Active state
112+ active ?: boolean
113+ /** A notification that is shown in an overlay pointing at the activity action button. */
114+ notification ?: {
115+ message : string
116+ onClose : ( ) => void
117+ intent ?: NotificationProps [ "intent" ]
118+ // Timeout in ms before notification is closed. Default: none
119+ timeout ?: number
120+ }
108121}
109122
110123interface IActivityMenuAction extends ActivityControlWidgetAction {
@@ -210,13 +223,9 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
210223 >
211224 { activityActions &&
212225 activityActions . map ( ( action , idx ) => {
213- return (
226+ const actionButtonRef = React . useRef ( null ) ;
227+ const ActionButton = ( ) => (
214228 < IconButton
215- key = {
216- typeof action . icon === "string"
217- ? action . icon
218- : action [ "data-test-id" ] ?? action [ "data-testid" ] ?? idx
219- }
220229 data-test-id = { action [ "data-test-id" ] }
221230 data-testid = { action [ "data-testid" ] }
222231 name = { action . icon }
@@ -226,10 +235,28 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
226235 intent = { action . hasStateWarning ? "warning" : undefined }
227236 tooltipProps = { {
228237 hoverOpenDelay : 200 ,
229- placement : "bottom" ,
238+ placement : "bottom"
230239 } }
240+ active = { action . active }
231241 />
232- ) ;
242+ )
243+ return action . notification ?
244+ < >
245+ < span key = { idx } ref = { actionButtonRef } >
246+ < ActionButton />
247+ </ span >
248+ { actionButtonRef . current && (
249+ < DecoupledOverlay targetSelectorOrElement = { actionButtonRef . current } paddingSize = { "small" } >
250+ < Notification
251+ message = { action . notification . message }
252+ intent = { action . notification . intent ?? "neutral" }
253+ onDismiss = { action . notification . onClose }
254+ timeout = { action . notification . timeout }
255+ />
256+ </ DecoupledOverlay >
257+ ) }
258+ </ > :
259+ < ActionButton key = { idx } />
233260 } ) }
234261 { additionalActions }
235262 { activityContextMenu && activityContextMenu . menuItems . length > 0 && (
@@ -241,11 +268,7 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
241268 return (
242269 < MenuItem
243270 icon = { menuAction . icon }
244- key = {
245- typeof menuAction . icon === "string"
246- ? menuAction . icon
247- : menuAction [ "data-test-id" ] ?? idx
248- }
271+ key = { idx }
249272 onClick = { menuAction . action }
250273 text = { menuAction . tooltip }
251274 />
0 commit comments