@finsemble/finsemble-ui 7.2.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +14 -14
- package/react/assets/css/button.css +34 -6
- package/react/assets/css/contextMenu.css +118 -0
- package/react/assets/css/notificationsCenter.css +3 -214
- package/react/assets/css/userPreferences.css +2 -2
- package/react/components/common/Checkbox.d.ts +3 -2
- package/react/components/common/Checkbox.js +5 -21
- package/react/components/common/Checkbox.js.map +1 -1
- package/react/components/common/ContextMenu.d.ts +13 -0
- package/react/components/common/ContextMenu.js +69 -0
- package/react/components/common/ContextMenu.js.map +1 -0
- package/react/components/common/DropdownButton.d.ts +0 -4
- package/react/components/common/DropdownButton.js +39 -10
- package/react/components/common/DropdownButton.js.map +1 -1
- package/react/components/common/css/FinsembleToggle.css +0 -1
- package/react/components/common/css/application-edit-page.css +3 -4
- package/react/components/common/css/checkbox.css +60 -21
- package/react/components/common/css/icon.css +2 -2
- package/react/components/common/css/toggle.css +4 -1
- package/react/components/common/helpers.js +9 -0
- package/react/components/common/helpers.js.map +1 -1
- package/react/components/common/stories/ContextMenu.stories.d.ts +38 -0
- package/react/components/common/stories/ContextMenu.stories.js +70 -0
- package/react/components/common/stories/ContextMenu.stories.js.map +1 -0
- package/react/components/common/stories/DropdownButton.stories.d.ts +3 -3
- package/react/components/common/stories/DropdownButton.stories.js +11 -10
- package/react/components/common/stories/DropdownButton.stories.js.map +1 -1
- package/react/components/common/tests/Checkbox.spec.js +10 -12
- package/react/components/common/tests/Checkbox.spec.js.map +1 -1
- package/react/components/common/tests/ContextMenu.spec.d.ts +1 -0
- package/react/components/common/tests/ContextMenu.spec.js +108 -0
- package/react/components/common/tests/ContextMenu.spec.js.map +1 -0
- package/react/components/common/tests/DropdownButton.spec.d.ts +1 -0
- package/react/components/common/tests/DropdownButton.spec.js +32 -0
- package/react/components/common/tests/DropdownButton.spec.js.map +1 -0
- package/react/components/fdc3Resolver/ResolverDialog.js +5 -1
- package/react/components/fdc3Resolver/ResolverDialog.js.map +1 -1
- package/react/components/notifications/components/drawer/DrawerHeader.js +3 -3
- package/react/components/notifications/components/drawer/DrawerHeader.js.map +1 -1
- package/react/components/notifications/components/notificationsCenter/NotificationsCenter.js +1 -0
- package/react/components/notifications/components/notificationsCenter/NotificationsCenter.js.map +1 -1
- package/react/components/notifications/components/notificationsToasts/NotificationsToasts.js +2 -0
- package/react/components/notifications/components/notificationsToasts/NotificationsToasts.js.map +1 -1
- package/react/components/notifications/components/shared/IconButton.js +2 -1
- package/react/components/notifications/components/shared/IconButton.js.map +1 -1
- package/react/components/notifications/components/shared/NotificationCardShell.d.ts +2 -0
- package/react/components/notifications/components/shared/NotificationCardShell.js +55 -49
- package/react/components/notifications/components/shared/NotificationCardShell.js.map +1 -1
- package/react/components/notifications/components/shared/notificationCard/NotificationCardBodyShell.js +2 -3
- package/react/components/notifications/components/shared/notificationCard/NotificationCardBodyShell.js.map +1 -1
- package/react/components/notifications/components/shared/notificationCard/NotificationCardHeaderControls.d.ts +4 -0
- package/react/components/notifications/components/shared/notificationCard/NotificationCardHeaderControls.js +92 -13
- package/react/components/notifications/components/shared/notificationCard/NotificationCardHeaderControls.js.map +1 -1
- package/react/components/notifications/components/views/ListView.js +5 -9
- package/react/components/notifications/components/views/ListView.js.map +1 -1
- package/react/components/notifications/css/notification-card.css +165 -0
- package/react/components/notifications/stories/NotificationCardShell.stories.d.ts +14 -0
- package/react/components/notifications/stories/NotificationCardShell.stories.js +108 -0
- package/react/components/notifications/stories/NotificationCardShell.stories.js.map +1 -0
- package/react/components/notifications/tests/NotificationCardShell.spec.d.ts +1 -0
- package/react/components/notifications/tests/NotificationCardShell.spec.js +91 -0
- package/react/components/notifications/tests/NotificationCardShell.spec.js.map +1 -0
- package/react/components/notifications/types.d.ts +4 -2
- package/react/components/notifications/types.js.map +1 -1
- package/react/components/sdd/AddApp.d.ts +3 -3
- package/react/components/sdd/AddApp.js +29 -21
- package/react/components/sdd/AddApp.js.map +1 -1
- package/react/components/sdd/AppEditPage.js +1 -8
- package/react/components/sdd/AppEditPage.js.map +1 -1
- package/react/components/sdd/Appearance.css +2 -1
- package/react/components/sdd/Applications.js +7 -7
- package/react/components/sdd/Applications.js.map +1 -1
- package/react/components/sdd/Navigation.js +2 -4
- package/react/components/sdd/Navigation.js.map +1 -1
- package/react/components/sdd/common/views.js +1 -14
- package/react/components/sdd/common/views.js.map +1 -1
- package/react/components/sdd/css/addApp.css +64 -1
- package/react/components/sdd/css/nav.css +50 -29
- package/react/components/sdd/fixtures/views.js +1 -14
- package/react/components/sdd/fixtures/views.js.map +1 -1
- package/react/components/sdd/tests/AddApp.spec.js +2 -2
- package/react/components/sdd/tests/AddApp.spec.js.map +1 -1
- package/react/components/sdd/tests/AppEditPage.spec.js +5 -8
- package/react/components/sdd/tests/AppEditPage.spec.js.map +1 -1
- package/react/components/sdd/tests/Export.spec.js +11 -11
- package/react/components/sdd/tests/Export.spec.js.map +1 -1
- package/react/components/sdd/tests/ExportZip.spec.js +3 -3
- package/react/components/sdd/tests/ExportZip.spec.js.map +1 -1
- package/react/components/sdd/tests/Navigation.spec.js +3 -2
- package/react/components/sdd/tests/Navigation.spec.js.map +1 -1
- package/react/components/sdd/tests/SmartDesktopDesigner.spec.js +1 -2
- package/react/components/sdd/tests/SmartDesktopDesigner.spec.js.map +1 -1
- package/react/components/toolbar/dashbar/Dashbar.js +18 -14
- package/react/components/toolbar/dashbar/Dashbar.js.map +1 -1
- package/react/components/toolbar/workspaceManagementMenu/components/Workspace.d.ts +9 -1
- package/react/components/toolbar/workspaceManagementMenu/components/Workspace.js +35 -1
- package/react/components/toolbar/workspaceManagementMenu/components/Workspace.js.map +1 -1
- package/react/components/toolbar/workspaceManagementMenu/stores/workspaceManagementMenuStore.js +1 -1
- package/react/components/toolbar/workspaceManagementMenu/stores/workspaceManagementMenuStore.js.map +1 -1
- package/react/components/userPreferences/components/content/Workspaces.d.ts +3 -1
- package/react/components/userPreferences/components/content/Workspaces.js +20 -3
- package/react/components/userPreferences/components/content/Workspaces.js.map +1 -1
- package/react/components/userPreferences/components/workspaces/WorkspaceItem.d.ts +1 -0
- package/react/components/userPreferences/components/workspaces/WorkspaceItem.js +3 -2
- package/react/components/userPreferences/components/workspaces/WorkspaceItem.js.map +1 -1
- package/react/components/userPreferences/tests/NotificationsPreferencesHome.spec.js +12 -9
- package/react/components/userPreferences/tests/NotificationsPreferencesHome.spec.js.map +1 -1
- package/react/components/userPreferences/tests/UserPreferencesBase.spec.js +2 -0
- package/react/components/userPreferences/tests/UserPreferencesBase.spec.js.map +1 -1
- package/react/components/windowTitleBar/WindowTitleBarShell.d.ts +99 -26
- package/react/components/windowTitleBar/WindowTitleBarShell.js +206 -138
- package/react/components/windowTitleBar/WindowTitleBarShell.js.map +1 -1
- package/react/components/windowTitleBar/components/left/LinkerButton.js +30 -21
- package/react/components/windowTitleBar/components/left/LinkerButton.js.map +1 -1
- package/react/hooks/useNotifications.js +8 -7
- package/react/hooks/useNotifications.js.map +1 -1
- package/react/tsconfig.tsbuildinfo +1 -1
- package/react/components/notifications/components/shared/OverflowMenu.d.ts +0 -16
- package/react/components/notifications/components/shared/OverflowMenu.js +0 -114
- package/react/components/notifications/components/shared/OverflowMenu.js.map +0 -1
- package/react/components/sdd/GettingStarted.d.ts +0 -8
- package/react/components/sdd/GettingStarted.js +0 -25
- package/react/components/sdd/GettingStarted.js.map +0 -1
- package/react/components/sdd/stories/GettingStarted.stories.d.ts +0 -11
- package/react/components/sdd/stories/GettingStarted.stories.js +0 -18
- package/react/components/sdd/stories/GettingStarted.stories.js.map +0 -1
package/react/components/notifications/components/notificationsToasts/NotificationsToasts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsToasts.js","sourceRoot":"","sources":["../../../../../src/components/notifications/components/notificationsToasts/NotificationsToasts.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,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,GAAG,EAAE,cAAc,YAAY,CAAC,EAAE,EAAE,EACpC,YAAY,EAAE,YAAY,EAC1B,gCAAgC,EAAE,oBAAoB,EACtD,wBAAwB,EAAE,wBAAwB,EAClD,cAAc,EAAE,kBAAkB,EAClC,gBAAgB,EAAE,oBAAoB,IAClC,KAAK,EACR,CACF,CAAC,CACG,CACN,CAAC;AACH,CAAC,CAAC","sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport useNotifications, {\n\tuseNotificationUI,\n\tmoveToToolbarMonitor,\n\tgetNotificationConfig,\n\tgetOS,\n} from \"../../../../hooks/useNotifications\";\nimport { NotificationCardShell } from \"../shared/NotificationCardShell\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { INotificationToastsProps } from \"../../types\";\nimport \"../../../../assets/css/notificationsCenter.css\";\nimport { services } from \"@finsemble/finsemble-api\";\n\ntype INotification = services.notification.types.INotification;\n\ntype ToastCardProps = {\n\tnotification: INotification;\n\tremoveFunction: Function;\n\tisActiveFunction: Function;\n\tinformationalNotificationTimeout: number | false;\n\tactionableTimeoutEnabled: boolean;\n\tnotificationCard?: React.ComponentType<any>;\n};\n\nconst ToastCard = (props: ToastCardProps) => {\n\tconst { notification, informationalNotificationTimeout, removeFunction, isActiveFunction, actionableTimeoutEnabled } =\n\t\tprops;\n\tconst notificationRef = useRef<INotification>(notification);\n\tconst [slideIn, setSlideIn] = useState(isActiveFunction(notification));\n\tconst [showNotification] = useState(isActiveFunction(notification));\n\tconst [timeoutId, setTimeoutId] = useState<number>();\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (timeoutId) {\n\t\t\t\tclearInterval(timeoutId);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (timeoutId) {\n\t\t\tclearInterval(timeoutId);\n\t\t}\n\n\t\tif (!notification.actions || notification.actions.length == 0 || actionableTimeoutEnabled) {\n\t\t\t// Is an informational notification or timeout enabled actionable notifications\n\t\t\tlet timeoutLength;\n\n\t\t\tif (informationalNotificationTimeout !== false) {\n\t\t\t\t// Convert to milliseconds\n\t\t\t\ttimeoutLength = informationalNotificationTimeout * 1000;\n\t\t\t\tif (notification.timeout && Number.isInteger(notification.timeout)) {\n\t\t\t\t\ttimeoutLength = notification.timeout;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (timeoutLength) {\n\t\t\t\tsetTimeoutId(\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tsetSlideIn(false);\n\t\t\t\t\t}, timeoutLength) as any\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!isActiveFunction(notificationRef.current)) {\n\t\t\tremoveFunction(notification);\n\t\t}\n\t\tsetSlideIn(isActiveFunction(notification));\n\t}, [notification]);\n\n\tconst onExited = () => {\n\t\tremoveFunction(notification);\n\t};\n\n\tconst Card = props.notificationCard ? props.notificationCard : NotificationCardShell;\n\n\treturn (\n\t\tshowNotification && (\n\t\t\t<CSSTransition in={slideIn} timeout={500} onExited={onExited} classNames=\"notifications-toast\">\n\t\t\t\t<div className=\"notifications-toast__offscreen\">\n\t\t\t\t\t<Card\n\t\t\t\t\t\tnotification={notification}\n\t\t\t\t\t\tuiContext=\"toasts\"\n\t\t\t\t\t\tremoveNotification={() => {\n\t\t\t\t\t\t\tsetSlideIn(false);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t<div className=\"divider\"> </div>\n\t\t\t\t</div>\n\t\t\t</CSSTransition>\n\t\t)\n\t);\n};\n\nexport const NotificationsToasts: React.FunctionComponent<INotificationToastsProps> = (props) => {\n\tconst { notifications, notificationIsActive, setOpaqueClassName, removeNotification, activeNotifications } =\n\t\tuseNotifications({ config: { notificationsHistory: { options: { sentAfter: \"startup\" } } } });\n\tconst notificationsRef = useRef<INotification[]>(notifications);\n\tconst [uiState] = useNotificationUI();\n\n\tconst isNotificationActive = (notification: INotification): boolean => {\n\t\tconst notificationCenterNotActive = !uiState.showCenter || uiState.poppedOut;\n\t\treturn notificationIsActive(notification) && notificationCenterNotActive;\n\t};\n\n\tconst config = getNotificationConfig();\n\tconst [isMac] = useState(getOS() === \"Mac\");\n\n\tconst [informationalTimeout, setInformationalTimeout] = useState<number | false>(false);\n\tconst [actionableTimeoutEnabled, setActionableTimeoutEnabled] = useState<boolean>(true);\n\n\tuseEffect(() => {\n\t\tasync function listenForPreferenceChange(error: any, response: any) {\n\t\t\tif (error) {\n\t\t\t\tconsole.error(\"FinsembleUserPreferencesChannel: \", error);\n\t\t\t} else {\n\t\t\t\tconst { data } = response;\n\t\t\t\tif (data.notificationPreferences) {\n\t\t\t\t\tconst { informationalNotificationToastPeriodSeconds, toastTimeoutOnActionableNotifications } =\n\t\t\t\t\t\tdata.notificationPreferences;\n\n\t\t\t\t\tif (informationalNotificationToastPeriodSeconds) {\n\t\t\t\t\t\tsetInformationalTimeout(informationalNotificationToastPeriodSeconds);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (typeof toastTimeoutOnActionableNotifications !== \"undefined\") {\n\t\t\t\t\t\tsetActionableTimeoutEnabled(toastTimeoutOnActionableNotifications);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tFSBL.Clients.RouterClient.addListener(\"FinsembleUserPreferencesChannel\", listenForPreferenceChange);\n\t\treturn () => {\n\t\t\tFSBL.Clients.RouterClient.removeListener(\"FinsembleUserPreferencesChannel\", listenForPreferenceChange);\n\t\t};\n\t}, []);\n\n\tuseEffect(() => {\n\t\tconst transparencySupported = config.isTransparent;\n\n\t\tsetOpaqueClassName(!transparencySupported);\n\n\t\tif (transparencySupported) {\n\t\t\tfinsembleWindow.show();\n\t\t}\n\n\t\tasync function getNotificationsPreferences() {\n\t\t\treturn await FSBL.Clients.NotificationClient.getPreferences();\n\t\t}\n\n\t\tgetNotificationsPreferences().then((preferences: any) => {\n\t\t\tsetInformationalTimeout(preferences.informationalNotificationToastPeriodSeconds);\n\t\t});\n\t}, []);\n\n\tuseEffect(() => {\n\t\tmoveToToolbarMonitor().then(async () => {\n\t\t\tlet forceHide = false;\n\t\t\tif (\n\t\t\t\tactiveNotifications(notifications).length === 0 &&\n\t\t\t\tactiveNotifications(notificationsRef.current).length === 0\n\t\t\t) {\n\t\t\t\t// Bug fix: Toasts flash when inActive components (partially caused by allowing notifications to animate out)\n\t\t\t\tforceHide = true;\n\t\t\t}\n\n\t\t\tnotificationsRef.current = notifications;\n\t\t\tconst rect = document.getElementById(\"notifications-toasts\")?.getBoundingClientRect();\n\t\t\tif (notifications.length === 0 || forceHide) {\n\t\t\t\tif (config.isTransparent && !isMac) {\n\t\t\t\t\tconst roundedRect = {\n\t\t\t\t\t\tx: Math.round(rect?.x as number),\n\t\t\t\t\t\ty: Math.round(rect?.y as number),\n\t\t\t\t\t\twidth: 1,\n\t\t\t\t\t\theight: 1,\n\t\t\t\t\t};\n\n\t\t\t\t\tfinsembleWindow.setShape([roundedRect]);\n\t\t\t\t}\n\n\t\t\t\tfinsembleWindow.hide();\n\t\t\t} else {\n\t\t\t\tfinsembleWindow.bringToFront();\n\t\t\t\tif (config.isTransparent && !isMac) {\n\t\t\t\t\tconst roundedRect = {\n\t\t\t\t\t\tx: Math.round(rect?.x as number),\n\t\t\t\t\t\ty: Math.round(rect?.y as number),\n\t\t\t\t\t\twidth: Math.round(rect?.width as number),\n\t\t\t\t\t\theight: Math.round(rect?.height as number),\n\t\t\t\t\t};\n\n\t\t\t\t\tawait finsembleWindow.show();\n\t\t\t\t\tfinsembleWindow.setShape([roundedRect]);\n\t\t\t\t} else {\n\t\t\t\t\tconst { err, data } = await FSBL.Clients.LauncherClient.getMonitorInfo({ monitor: \"mine\" });\n\t\t\t\t\tif (err || !data) {\n\t\t\t\t\t\tconsole.error(err);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { data: bounds } = await finsembleWindow.getBounds();\n\t\t\t\t\tconst width = (bounds?.right ?? 0) - (bounds?.left ?? 0);\n\t\t\t\t\tconst height = Math.round(rect?.height as number) + 6;\n\n\t\t\t\t\tawait finsembleWindow.setBounds({\n\t\t\t\t\t\tbounds: {\n\t\t\t\t\t\t\ttop: data[\"availableRect\"][\"top\"],\n\t\t\t\t\t\t\tleft: data[\"availableRect\"][\"right\"] - width,\n\t\t\t\t\t\t\theight: height + 10,\n\t\t\t\t\t\t\twidth: width,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\t// show the window after it bounds has been calculated\n\t\t\t\t\tawait finsembleWindow.show();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, [notifications]);\n\n\treturn (\n\t\t<div>\n\t\t\t{notifications.map((notification: INotification) => (\n\t\t\t\t<ToastCard\n\t\t\t\t\tkey={`toast-card-${notification.id}`}\n\t\t\t\t\tnotification={notification}\n\t\t\t\t\tinformationalNotificationTimeout={informationalTimeout}\n\t\t\t\t\tactionableTimeoutEnabled={actionableTimeoutEnabled}\n\t\t\t\t\tremoveFunction={removeNotification}\n\t\t\t\t\tisActiveFunction={isNotificationActive}\n\t\t\t\t\t{...props}\n\t\t\t\t/>\n\t\t\t))}\n\t\t</div>\n\t);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"NotificationsToasts.js","sourceRoot":"","sources":["../../../../../src/components/notifications/components/notificationsToasts/NotificationsToasts.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,gBAAgB,EAAE,EACxB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,GACL,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,gDAAgD,CAAC;AAcxD,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,EAAE;IAC3C,MAAM,EAAE,YAAY,EAAE,gCAAgC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,IAClC,KAAK,EACR,CACF,CAAC,CACG,CACN,CAAC;AACH,CAAC,CAAC","sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport useNotifications, {\n\tuseNotificationUI,\n\tmoveToToolbarMonitor,\n\tgetNotificationConfig,\n\tgetOS,\n} from \"../../../../hooks/useNotifications\";\nimport { NotificationCardShell } from \"../shared/NotificationCardShell\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { INotificationToastsProps } from \"../../types\";\nimport \"../../../../assets/css/notificationsCenter.css\";\nimport { services } from \"@finsemble/finsemble-api\";\n\ntype INotification = services.notification.types.INotification;\n\ntype ToastCardProps = {\n\tnotification: INotification;\n\tremoveFunction: Function;\n\tisActiveFunction: Function;\n\tinformationalNotificationTimeout: number | false;\n\tactionableTimeoutEnabled: boolean;\n\tnotificationCard?: React.ComponentType<any>;\n};\n\nconst ToastCard = (props: ToastCardProps) => {\n\tconst { notification, informationalNotificationTimeout, removeFunction, isActiveFunction, actionableTimeoutEnabled } =\n\t\tprops;\n\tconst notificationRef = useRef<INotification>(notification);\n\tconst [slideIn, setSlideIn] = useState(isActiveFunction(notification));\n\tconst [showNotification] = useState(isActiveFunction(notification));\n\tconst [timeoutId, setTimeoutId] = useState<number>();\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (timeoutId) {\n\t\t\t\tclearInterval(timeoutId);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (timeoutId) {\n\t\t\tclearInterval(timeoutId);\n\t\t}\n\n\t\tif (!notification.actions || notification.actions.length == 0 || actionableTimeoutEnabled) {\n\t\t\t// Is an informational notification or timeout enabled actionable notifications\n\t\t\tlet timeoutLength;\n\n\t\t\tif (informationalNotificationTimeout !== false) {\n\t\t\t\t// Convert to milliseconds\n\t\t\t\ttimeoutLength = informationalNotificationTimeout * 1000;\n\t\t\t\tif (notification.timeout && Number.isInteger(notification.timeout)) {\n\t\t\t\t\ttimeoutLength = notification.timeout;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (timeoutLength) {\n\t\t\t\tsetTimeoutId(\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tsetSlideIn(false);\n\t\t\t\t\t}, timeoutLength) as any\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!isActiveFunction(notificationRef.current)) {\n\t\t\tremoveFunction(notification);\n\t\t}\n\t\tsetSlideIn(isActiveFunction(notification));\n\t}, [notification]);\n\n\tconst onExited = () => {\n\t\tremoveFunction(notification);\n\t};\n\n\tconst Card = props.notificationCard ? props.notificationCard : NotificationCardShell;\n\n\treturn (\n\t\tshowNotification && (\n\t\t\t<CSSTransition in={slideIn} timeout={500} onExited={onExited} classNames=\"notifications-toast\">\n\t\t\t\t<div className=\"notifications-toast__offscreen\">\n\t\t\t\t\t<Card\n\t\t\t\t\t\tnotification={notification}\n\t\t\t\t\t\tuiContext=\"toasts\"\n\t\t\t\t\t\tremoveNotification={() => {\n\t\t\t\t\t\t\tsetSlideIn(false);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t<div className=\"divider\"> </div>\n\t\t\t\t</div>\n\t\t\t</CSSTransition>\n\t\t)\n\t);\n};\n\nexport const NotificationsToasts: React.FunctionComponent<INotificationToastsProps> = (props) => {\n\tconst { notifications, notificationIsActive, setOpaqueClassName, removeNotification, activeNotifications } =\n\t\tuseNotifications({ config: { notificationsHistory: { options: { sentAfter: \"startup\" } } } });\n\tconst notificationsRef = useRef<INotification[]>(notifications);\n\tconst [uiState] = useNotificationUI();\n\n\tconst isNotificationActive = (notification: INotification): boolean => {\n\t\tconst notificationCenterNotActive = !uiState.showCenter || uiState.poppedOut;\n\t\treturn notificationIsActive(notification) && notificationCenterNotActive;\n\t};\n\n\tconst config = getNotificationConfig();\n\tconst [isMac] = useState(getOS() === \"Mac\");\n\n\tconst [informationalTimeout, setInformationalTimeout] = useState<number | false>(false);\n\tconst [actionableTimeoutEnabled, setActionableTimeoutEnabled] = useState<boolean>(true);\n\n\tuseEffect(() => {\n\t\tasync function listenForPreferenceChange(error: any, response: any) {\n\t\t\tif (error) {\n\t\t\t\tconsole.error(\"FinsembleUserPreferencesChannel: \", error);\n\t\t\t\tFSBL.Clients.Logger.system.error(\"FinsembleUserPreferencesChannel: \", error);\n\t\t\t} else {\n\t\t\t\tconst { data } = response;\n\t\t\t\tif (data.notificationPreferences) {\n\t\t\t\t\tconst { informationalNotificationToastPeriodSeconds, toastTimeoutOnActionableNotifications } =\n\t\t\t\t\t\tdata.notificationPreferences;\n\n\t\t\t\t\tif (informationalNotificationToastPeriodSeconds) {\n\t\t\t\t\t\tsetInformationalTimeout(informationalNotificationToastPeriodSeconds);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (typeof toastTimeoutOnActionableNotifications !== \"undefined\") {\n\t\t\t\t\t\tsetActionableTimeoutEnabled(toastTimeoutOnActionableNotifications);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tFSBL.Clients.RouterClient.addListener(\"FinsembleUserPreferencesChannel\", listenForPreferenceChange);\n\t\treturn () => {\n\t\t\tFSBL.Clients.RouterClient.removeListener(\"FinsembleUserPreferencesChannel\", listenForPreferenceChange);\n\t\t};\n\t}, []);\n\n\tuseEffect(() => {\n\t\tconst transparencySupported = config.isTransparent;\n\n\t\tsetOpaqueClassName(!transparencySupported);\n\n\t\tif (transparencySupported) {\n\t\t\tfinsembleWindow.show();\n\t\t}\n\n\t\tasync function getNotificationsPreferences() {\n\t\t\treturn await FSBL.Clients.NotificationClient.getPreferences();\n\t\t}\n\n\t\tgetNotificationsPreferences().then((preferences: any) => {\n\t\t\tsetInformationalTimeout(preferences.informationalNotificationToastPeriodSeconds);\n\t\t});\n\t}, []);\n\n\tuseEffect(() => {\n\t\tmoveToToolbarMonitor().then(async () => {\n\t\t\tlet forceHide = false;\n\t\t\tif (\n\t\t\t\tactiveNotifications(notifications).length === 0 &&\n\t\t\t\tactiveNotifications(notificationsRef.current).length === 0\n\t\t\t) {\n\t\t\t\t// Bug fix: Toasts flash when inActive components (partially caused by allowing notifications to animate out)\n\t\t\t\tforceHide = true;\n\t\t\t}\n\n\t\t\tnotificationsRef.current = notifications;\n\t\t\tconst rect = document.getElementById(\"notifications-toasts\")?.getBoundingClientRect();\n\t\t\tif (notifications.length === 0 || forceHide) {\n\t\t\t\tif (config.isTransparent && !isMac) {\n\t\t\t\t\tconst roundedRect = {\n\t\t\t\t\t\tx: Math.round(rect?.x as number),\n\t\t\t\t\t\ty: Math.round(rect?.y as number),\n\t\t\t\t\t\twidth: 1,\n\t\t\t\t\t\theight: 1,\n\t\t\t\t\t};\n\n\t\t\t\t\tfinsembleWindow.setShape([roundedRect]);\n\t\t\t\t}\n\n\t\t\t\tfinsembleWindow.hide();\n\t\t\t} else {\n\t\t\t\tfinsembleWindow.bringToFront();\n\t\t\t\tif (config.isTransparent && !isMac) {\n\t\t\t\t\tconst roundedRect = {\n\t\t\t\t\t\tx: Math.round(rect?.x as number),\n\t\t\t\t\t\ty: Math.round(rect?.y as number),\n\t\t\t\t\t\twidth: Math.round(rect?.width as number),\n\t\t\t\t\t\theight: Math.round(rect?.height as number),\n\t\t\t\t\t};\n\n\t\t\t\t\tawait finsembleWindow.show();\n\t\t\t\t\tfinsembleWindow.setShape([roundedRect]);\n\t\t\t\t} else {\n\t\t\t\t\tconst { err, data } = await FSBL.Clients.LauncherClient.getMonitorInfo({ monitor: \"mine\" });\n\t\t\t\t\tif (err || !data) {\n\t\t\t\t\t\tconsole.error(err);\n\t\t\t\t\t\tFSBL.Clients.Logger.system.error(err);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { data: bounds } = await finsembleWindow.getBounds();\n\t\t\t\t\tconst width = (bounds?.right ?? 0) - (bounds?.left ?? 0);\n\t\t\t\t\tconst height = Math.round(rect?.height as number) + 6;\n\n\t\t\t\t\tawait finsembleWindow.setBounds({\n\t\t\t\t\t\tbounds: {\n\t\t\t\t\t\t\ttop: data[\"availableRect\"][\"top\"],\n\t\t\t\t\t\t\tleft: data[\"availableRect\"][\"right\"] - width,\n\t\t\t\t\t\t\theight: height + 10,\n\t\t\t\t\t\t\twidth: width,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\t// show the window after it bounds has been calculated\n\t\t\t\t\tawait finsembleWindow.show();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}, [notifications]);\n\n\treturn (\n\t\t<div>\n\t\t\t{notifications.map((notification: INotification) => (\n\t\t\t\t<ToastCard\n\t\t\t\t\tkey={`toast-card-${notification.id}`}\n\t\t\t\t\tnotification={notification}\n\t\t\t\t\tinformationalNotificationTimeout={informationalTimeout}\n\t\t\t\t\tactionableTimeoutEnabled={actionableTimeoutEnabled}\n\t\t\t\t\tremoveFunction={removeNotification}\n\t\t\t\t\tisActiveFunction={isNotificationActive}\n\t\t\t\t\t{...props}\n\t\t\t\t/>\n\t\t\t))}\n\t\t</div>\n\t);\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
const IconButton = ({ clickHandler = () => { }, tooltip, iconName = "ff-finsemble", classNames, children, }) => (React.createElement("div", { className: `finsemble-icon__btn ${classNames ? classNames : ""}`, title: tooltip ? tooltip : "", onClick: () => clickHandler(), tabIndex: 0, onKeyDown: (e) => {
|
|
3
|
-
if (e.
|
|
3
|
+
if (e.code === "Space" || e.code === "Enter") {
|
|
4
|
+
e.stopPropagation();
|
|
4
5
|
clickHandler();
|
|
5
6
|
}
|
|
6
7
|
} },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../../../../../src/components/notifications/components/shared/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,UAAU,GAAuD,CAAC,EACvE,YAAY,GAAG,GAAG,EAAE,GAAE,CAAC,EACvB,OAAO,EACP,QAAQ,GAAG,cAAc,EACzB,UAAU,EACV,QAAQ,GACmB,EAAE,EAAE,CAAC,CAChC,6BACC,SAAS,EAAE,uBAAuB,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAChE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAC7B,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,EAC7B,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;QAChB,IAAI,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../../../../../src/components/notifications/components/shared/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,UAAU,GAAuD,CAAC,EACvE,YAAY,GAAG,GAAG,EAAE,GAAE,CAAC,EACvB,OAAO,EACP,QAAQ,GAAG,cAAc,EACzB,UAAU,EACV,QAAQ,GACmB,EAAE,EAAE,CAAC,CAChC,6BACC,SAAS,EAAE,uBAAuB,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAChE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAC7B,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,EAC7B,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;QAChB,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE;YAC7C,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,YAAY,EAAE,CAAC;SACf;IACF,CAAC;IAED,2BAAG,SAAS,EAAE,QAAQ,GAAI;IACzB,QAAQ,CACJ,CACN,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import React from \"react\";\n\nexport interface IFinsembleIconButtonProps {\n\ttooltip?: string;\n\tclickHandler?: Function;\n\ticonName?: string;\n\tclassNames?: string;\n\tchildren?: React.ReactNode;\n}\n\nconst IconButton: React.FunctionComponent<IFinsembleIconButtonProps> = ({\n\tclickHandler = () => {},\n\ttooltip,\n\ticonName = \"ff-finsemble\",\n\tclassNames,\n\tchildren,\n}: IFinsembleIconButtonProps) => (\n\t<div\n\t\tclassName={`finsemble-icon__btn ${classNames ? classNames : \"\"}`}\n\t\ttitle={tooltip ? tooltip : \"\"}\n\t\tonClick={() => clickHandler()}\n\t\ttabIndex={0}\n\t\tonKeyDown={(e) => {\n\t\t\tif (e.code === \"Space\" || e.code === \"Enter\") {\n\t\t\t\te.stopPropagation();\n\t\t\t\tclickHandler();\n\t\t\t}\n\t\t}}\n\t>\n\t\t<i className={iconName} />\n\t\t{children}\n\t</div>\n);\n\nexport default IconButton;\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { services } from "@finsemble/finsemble-api";
|
|
3
|
+
import "../../css/notification-card.css";
|
|
3
4
|
declare type INotification = services.notification.types.INotification;
|
|
4
5
|
export declare type NotificationCardPropType = {
|
|
5
6
|
/**
|
|
@@ -14,6 +15,7 @@ export declare type NotificationCardPropType = {
|
|
|
14
15
|
* The internal function that will be called on toasts when dismissed or marked as read
|
|
15
16
|
*/
|
|
16
17
|
removeNotification: Function;
|
|
18
|
+
preferences?: any;
|
|
17
19
|
};
|
|
18
20
|
export declare const NotificationCardShell: React.FunctionComponent<NotificationCardPropType>;
|
|
19
21
|
export {};
|
|
@@ -4,45 +4,70 @@ import { isNewNotification, isReNotification, getMostRecentAction } from "../../
|
|
|
4
4
|
import { NotificationCardHeaderShell } from "./notificationCard/NotificationCardHeaderShell";
|
|
5
5
|
import { NotificationCardBodyShell } from "./notificationCard/NotificationCardBodyShell";
|
|
6
6
|
import { ErrorBoundary } from "../../../common/ErrorBoundary";
|
|
7
|
-
|
|
7
|
+
import "../../css/notification-card.css";
|
|
8
|
+
export const NotificationCardShell = ({ notification, uiContext = "center", removeNotification, children, }) => {
|
|
8
9
|
const { isRead } = notification;
|
|
9
10
|
const [newNotificationHaloPeriodSeconds, setNotificationHaloPeriodSeconds] = useState(0);
|
|
10
11
|
const [isNew, setIsNew] = useState(isNewNotification(notification, newNotificationHaloPeriodSeconds));
|
|
11
12
|
const [componentUnmounted, setComponentUnmounted] = useState(false);
|
|
12
13
|
const [wokeFromSnooze, setWokeFromSnooze] = useState(isReNotification(notification, newNotificationHaloPeriodSeconds));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
14
|
+
if (uiContext == "center") {
|
|
15
|
+
// Sets the current default preference
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const getNotificationsPreferences = async () => {
|
|
18
|
+
var _a;
|
|
19
|
+
const preferences = await FSBL.Clients.NotificationClient.getPreferences();
|
|
20
|
+
const haloPeriod = (_a = preferences === null || preferences === void 0 ? void 0 : preferences.newNotificationHaloPeriodSeconds) !== null && _a !== void 0 ? _a : 0;
|
|
21
|
+
setNotificationHaloPeriodSeconds(haloPeriod);
|
|
22
|
+
if (!componentUnmounted) {
|
|
23
|
+
setIsNew(isNewNotification(notification, haloPeriod));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
18
26
|
if (!componentUnmounted) {
|
|
19
|
-
|
|
27
|
+
getNotificationsPreferences();
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return () => {
|
|
30
|
+
setComponentUnmounted(true);
|
|
31
|
+
};
|
|
32
|
+
}, []);
|
|
33
|
+
// Listens for preferences change
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
function listenForPreferenceChange(error, response) {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
if (error) {
|
|
38
|
+
console.error("FinsembleUserPreferencesChannel: ", error);
|
|
39
|
+
FSBL.Clients.Logger.system.error("FinsembleUserPreferencesChannel: ", error);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const { data } = response;
|
|
43
|
+
setNotificationHaloPeriodSeconds((_b = (_a = data === null || data === void 0 ? void 0 : data.notificationPreferences) === null || _a === void 0 ? void 0 : _a.newNotificationHaloPeriodSeconds) !== null && _b !== void 0 ? _b : 0);
|
|
44
|
+
}
|
|
32
45
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
FSBL.Clients.RouterClient.addListener("FinsembleUserPreferencesChannel", listenForPreferenceChange);
|
|
47
|
+
return () => {
|
|
48
|
+
FSBL.Clients.RouterClient.removeListener("FinsembleUserPreferencesChannel", listenForPreferenceChange);
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
let isRenotificationTimerId;
|
|
53
|
+
if (isReNotification(notification, newNotificationHaloPeriodSeconds)) {
|
|
54
|
+
const mostRecentAction = getMostRecentAction(notification);
|
|
55
|
+
if (mostRecentAction) {
|
|
56
|
+
setWokeFromSnooze(true);
|
|
57
|
+
isRenotificationTimerId = setTimeout(() => {
|
|
58
|
+
setWokeFromSnooze(false);
|
|
59
|
+
}, differenceInMilliseconds(addSeconds(parseISO(mostRecentAction.datePerformed), newNotificationHaloPeriodSeconds), Date.now()));
|
|
38
60
|
}
|
|
39
61
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
else {
|
|
63
|
+
setWokeFromSnooze(false);
|
|
64
|
+
clearTimeout(isRenotificationTimerId);
|
|
65
|
+
}
|
|
66
|
+
return () => {
|
|
67
|
+
clearTimeout(isRenotificationTimerId);
|
|
68
|
+
};
|
|
69
|
+
}, [newNotificationHaloPeriodSeconds, notification]);
|
|
70
|
+
}
|
|
46
71
|
useEffect(() => {
|
|
47
72
|
let isNewTimerId;
|
|
48
73
|
if (isNew) {
|
|
@@ -60,27 +85,8 @@ export const NotificationCardShell = ({ notification, uiContext, removeNotificat
|
|
|
60
85
|
clearTimeout(isNewTimerId);
|
|
61
86
|
};
|
|
62
87
|
}, [isNew, notification]);
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
let isRenotificationTimerId;
|
|
65
|
-
if (isReNotification(notification, newNotificationHaloPeriodSeconds)) {
|
|
66
|
-
const mostRecentAction = getMostRecentAction(notification);
|
|
67
|
-
if (mostRecentAction) {
|
|
68
|
-
setWokeFromSnooze(true);
|
|
69
|
-
isRenotificationTimerId = setTimeout(() => {
|
|
70
|
-
setWokeFromSnooze(false);
|
|
71
|
-
}, differenceInMilliseconds(addSeconds(parseISO(mostRecentAction.datePerformed), newNotificationHaloPeriodSeconds), Date.now()));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
setWokeFromSnooze(false);
|
|
76
|
-
clearTimeout(isRenotificationTimerId);
|
|
77
|
-
}
|
|
78
|
-
return () => {
|
|
79
|
-
clearTimeout(isRenotificationTimerId);
|
|
80
|
-
};
|
|
81
|
-
}, [newNotificationHaloPeriodSeconds, notification]);
|
|
82
88
|
return (React.createElement("div", { className: `notification-card ${isRead ? "read" : ""} ${isNew || wokeFromSnooze ? "new" : ""}
|
|
83
|
-
${notification.cssClassName ? notification.cssClassName : ""}` }, children ? (React.createElement(ErrorBoundary, null, children)) : (React.createElement(React.Fragment, null,
|
|
89
|
+
${notification.cssClassName ? notification.cssClassName : ""} js-${uiContext}` }, children ? (React.createElement(ErrorBoundary, null, children)) : (React.createElement(React.Fragment, null,
|
|
84
90
|
React.createElement(NotificationCardHeaderShell, { notification: notification, removeNotification: removeNotification, uiContext: uiContext }),
|
|
85
91
|
React.createElement(NotificationCardBodyShell, { notification: notification })))));
|
|
86
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationCardShell.js","sourceRoot":"","sources":["../../../../../src/components/notifications/components/shared/NotificationCardShell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAEzF,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"NotificationCardShell.js","sourceRoot":"","sources":["../../../../../src/components/notifications/components/shared/NotificationCardShell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAEzF,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,iCAAiC,CAAC;AAuBzC,MAAM,CAAC,MAAM,qBAAqB,GAAsD,CAAC,EACxF,YAAY,EACZ,SAAS,GAAG,QAAQ,EACpB,kBAAkB,EAClB,QAAQ,GACR,EAAE,EAAE;IACJ,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC;IAEhC,MAAM,CAAC,gCAAgC,EAAE,gCAAgC,CAAC,GAAG,QAAQ,CA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Seconds } from \"date-fns\";\nimport { isNewNotification, isReNotification, getMostRecentAction } from \"../../utils\";\nimport { NotificationCardHeaderShell } from \"./notificationCard/NotificationCardHeaderShell\";\nimport { NotificationCardBodyShell } from \"./notificationCard/NotificationCardBodyShell\";\nimport { services } from \"@finsemble/finsemble-api\";\nimport { ErrorBoundary } from \"../../../common/ErrorBoundary\";\nimport \"../../css/notification-card.css\";\n\ntype INotification = services.notification.types.INotification;\ntype IPerformedAction = services.notification.types.IPerformedAction;\n\nexport type NotificationCardPropType = {\n\t/**\n\t * The Notification to be displayed\n\t */\n\tnotification: INotification;\n\n\t/**\n\t * Which UI context the Card is being used in\n\t */\n\tuiContext: \"toasts\" | \"center\";\n\n\t/**\n\t * The internal function that will be called on toasts when dismissed or marked as read\n\t */\n\tremoveNotification: Function;\n\tpreferences?: any;\n};\n\nexport const NotificationCardShell: React.FunctionComponent<NotificationCardPropType> = ({\n\tnotification,\n\tuiContext = \"center\",\n\tremoveNotification,\n\tchildren,\n}) => {\n\tconst { isRead } = notification;\n\n\tconst [newNotificationHaloPeriodSeconds, setNotificationHaloPeriodSeconds] = useState(0);\n\n\tconst [isNew, setIsNew] = useState(isNewNotification(notification, newNotificationHaloPeriodSeconds));\n\tconst [componentUnmounted, setComponentUnmounted] = useState<boolean>(false);\n\tconst [wokeFromSnooze, setWokeFromSnooze] = useState(\n\t\tisReNotification(notification, newNotificationHaloPeriodSeconds)\n\t);\n\n\tif (uiContext == \"center\") {\n\t\t// Sets the current default preference\n\t\tuseEffect(() => {\n\t\t\tconst getNotificationsPreferences = async () => {\n\t\t\t\tconst preferences: any = await FSBL.Clients.NotificationClient.getPreferences();\n\t\t\t\tconst haloPeriod = preferences?.newNotificationHaloPeriodSeconds ?? 0;\n\t\t\t\tsetNotificationHaloPeriodSeconds(haloPeriod);\n\t\t\t\tif (!componentUnmounted) {\n\t\t\t\t\tsetIsNew(isNewNotification(notification, haloPeriod));\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (!componentUnmounted) {\n\t\t\t\tgetNotificationsPreferences();\n\t\t\t}\n\t\t\treturn () => {\n\t\t\t\tsetComponentUnmounted(true);\n\t\t\t};\n\t\t}, []);\n\n\t\t// Listens for preferences change\n\t\tuseEffect(() => {\n\t\t\tfunction listenForPreferenceChange(error: any, response: any) {\n\t\t\t\tif (error) {\n\t\t\t\t\tconsole.error(\"FinsembleUserPreferencesChannel: \", error);\n\t\t\t\t\tFSBL.Clients.Logger.system.error(\"FinsembleUserPreferencesChannel: \", error);\n\t\t\t\t} else {\n\t\t\t\t\tconst { data } = response;\n\t\t\t\t\tsetNotificationHaloPeriodSeconds(data?.notificationPreferences?.newNotificationHaloPeriodSeconds ?? 0);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tFSBL.Clients.RouterClient.addListener(\"FinsembleUserPreferencesChannel\", listenForPreferenceChange);\n\t\t\treturn () => {\n\t\t\t\tFSBL.Clients.RouterClient.removeListener(\"FinsembleUserPreferencesChannel\", listenForPreferenceChange);\n\t\t\t};\n\t\t}, []);\n\n\t\tuseEffect(() => {\n\t\t\tlet isRenotificationTimerId: any;\n\t\t\tif (isReNotification(notification, newNotificationHaloPeriodSeconds)) {\n\t\t\t\tconst mostRecentAction: IPerformedAction | null = getMostRecentAction(notification);\n\t\t\t\tif (mostRecentAction) {\n\t\t\t\t\tsetWokeFromSnooze(true);\n\t\t\t\t\tisRenotificationTimerId = setTimeout(() => {\n\t\t\t\t\t\tsetWokeFromSnooze(false);\n\t\t\t\t\t}, differenceInMilliseconds(addSeconds(parseISO(mostRecentAction.datePerformed), newNotificationHaloPeriodSeconds), Date.now()));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsetWokeFromSnooze(false);\n\t\t\t\tclearTimeout(isRenotificationTimerId);\n\t\t\t}\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(isRenotificationTimerId);\n\t\t\t};\n\t\t}, [newNotificationHaloPeriodSeconds, notification]);\n\t}\n\n\tuseEffect(() => {\n\t\tlet isNewTimerId: any;\n\t\tif (isNew) {\n\t\t\tif (notification.isRead) {\n\t\t\t\tsetIsNew(false);\n\t\t\t\tclearTimeout(isNewTimerId);\n\t\t\t} else {\n\t\t\t\tisNewTimerId = setTimeout(() => {\n\t\t\t\t\tsetIsNew(false);\n\t\t\t\t}, differenceInMilliseconds(addSeconds(parseISO(notification.issuedAt), newNotificationHaloPeriodSeconds), Date.now()));\n\t\t\t}\n\t\t}\n\t\treturn () => {\n\t\t\tclearTimeout(isNewTimerId);\n\t\t};\n\t}, [isNew, notification]);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={`notification-card ${isRead ? \"read\" : \"\"} ${isNew || wokeFromSnooze ? \"new\" : \"\"} \n\t\t\t${notification.cssClassName ? notification.cssClassName : \"\"} js-${uiContext}`}\n\t\t>\n\t\t\t{children ? (\n\t\t\t\t<ErrorBoundary>{children}</ErrorBoundary>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<NotificationCardHeaderShell\n\t\t\t\t\t\tnotification={notification}\n\t\t\t\t\t\tremoveNotification={removeNotification}\n\t\t\t\t\t\tuiContext={uiContext}\n\t\t\t\t\t/>\n\t\t\t\t\t<NotificationCardBodyShell notification={notification} />\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"]}
|
|
@@ -3,9 +3,8 @@ import { NotificationCardBodyActions } from "./NotificationCardBodyActions";
|
|
|
3
3
|
import { NotificationCardBodyContentLogo } from "./NotificationCardBodyContentLogo";
|
|
4
4
|
import { ErrorBoundary } from "../../../../common/ErrorBoundary";
|
|
5
5
|
export const NotificationCardBodyShell = ({ notification, children, }) => {
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
return (React.createElement("div", { className: `notification-card__body ${hasActions ? "actions" : ""}` },
|
|
6
|
+
const { details, contentLogo } = notification;
|
|
7
|
+
return (React.createElement("div", { className: "notification-card__body" },
|
|
9
8
|
children ? (React.createElement(ErrorBoundary, null, children)) : (React.createElement(React.Fragment, null,
|
|
10
9
|
React.createElement(NotificationCardBodyContentLogo, { contentLogo: contentLogo }),
|
|
11
10
|
React.createElement("div", { className: "notification-card__body_text" }, details))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationCardBodyShell.js","sourceRoot":"","sources":["../../../../../../src/components/notifications/components/shared/notificationCard/NotificationCardBodyShell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAIjE,MAAM,CAAC,MAAM,yBAAyB,GAA6D,CAAC,EACnG,YAAY,EACZ,QAAQ,GACR,EAAE,EAAE;IACJ,MAAM,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"NotificationCardBodyShell.js","sourceRoot":"","sources":["../../../../../../src/components/notifications/components/shared/notificationCard/NotificationCardBodyShell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAIjE,MAAM,CAAC,MAAM,yBAAyB,GAA6D,CAAC,EACnG,YAAY,EACZ,QAAQ,GACR,EAAE,EAAE;IACJ,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,YAAY,CAAC;IAE9C,OAAO,CACN,6BAAK,SAAS,EAAC,yBAAyB;QACtC,QAAQ,CAAC,CAAC,CAAC,CACX,oBAAC,aAAa,QAAE,QAAQ,CAAiB,CACzC,CAAC,CAAC,CAAC,CACH;YACC,oBAAC,+BAA+B,IAAC,WAAW,EAAE,WAAW,GAAI;YAC7D,6BAAK,SAAS,EAAC,8BAA8B,IAAE,OAAO,CAAO,CAC3D,CACH;QACD,oBAAC,2BAA2B,IAAC,YAAY,EAAE,YAAY,GAAI,CACtD,CACN,CAAC;AACH,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport { NotificationCardBodyActions } from \"./NotificationCardBodyActions\";\nimport { NotificationCardBodyContentLogo } from \"./NotificationCardBodyContentLogo\";\nimport { services } from \"@finsemble/finsemble-api\";\nimport { ErrorBoundary } from \"../../../../common/ErrorBoundary\";\n\ntype INotification = services.notification.types.INotification;\n\nexport const NotificationCardBodyShell: React.FunctionComponent<{ notification: INotification }> = ({\n\tnotification,\n\tchildren,\n}) => {\n\tconst { details, contentLogo } = notification;\n\n\treturn (\n\t\t<div className=\"notification-card__body\">\n\t\t\t{children ? (\n\t\t\t\t<ErrorBoundary>{children}</ErrorBoundary>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<NotificationCardBodyContentLogo contentLogo={contentLogo} />\n\t\t\t\t\t<div className=\"notification-card__body_text\">{details}</div>\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t<NotificationCardBodyActions notification={notification} />\n\t\t</div>\n\t);\n};\n"]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { services } from "@finsemble/finsemble-api";
|
|
3
|
+
import { ContextMenuAction } from "../../../types";
|
|
3
4
|
declare type INotification = services.notification.types.INotification;
|
|
5
|
+
export declare const ContextMenuActions: {
|
|
6
|
+
[key: string]: ContextMenuAction;
|
|
7
|
+
};
|
|
4
8
|
export declare const NotificationCardHeaderControls: React.FunctionComponent<{
|
|
5
9
|
notification: INotification;
|
|
6
10
|
uiContext?: string;
|
|
@@ -1,12 +1,84 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useState } from "react";
|
|
2
|
-
import
|
|
3
|
-
import OverflowMenu, { OverflowMenuActions, renderOverflowMenuAction } from "../OverflowMenu";
|
|
2
|
+
import ContextMenuToggle from "../../../../common/ContextMenu";
|
|
4
3
|
import { NotificationsContext } from "../../../notificationsContext";
|
|
5
4
|
import { formatDistanceToNow } from "date-fns";
|
|
5
|
+
import { markNotificationsRead, markNotificationsUnread, snoozeNotifications, } from "../../../../../hooks/useNotifications";
|
|
6
|
+
// Icons
|
|
7
|
+
import EnvelopeCloseIcon from "../../../../notifications/icons/EnvelopeClose";
|
|
8
|
+
import EnvelopeOpenIcon from "../../../../notifications/icons/EnvelopeOpen";
|
|
9
|
+
import SnoozeIcon from "../../../../notifications/icons/SnoozeIcon";
|
|
10
|
+
import IconButton from "../IconButton";
|
|
11
|
+
export const ContextMenuActions = {
|
|
12
|
+
MARK_AS_UNREAD: {
|
|
13
|
+
name: "MARK_AS_UNREAD",
|
|
14
|
+
icon: React.createElement(EnvelopeCloseIcon, null),
|
|
15
|
+
label: "Mark Unread",
|
|
16
|
+
action: (notification) => markNotificationsUnread([notification]),
|
|
17
|
+
display: true,
|
|
18
|
+
},
|
|
19
|
+
MARK_AS_READ: {
|
|
20
|
+
name: "MARK_AS_READ",
|
|
21
|
+
icon: React.createElement(EnvelopeOpenIcon, null),
|
|
22
|
+
label: "Mark Read",
|
|
23
|
+
action: (notification) => markNotificationsRead([notification]),
|
|
24
|
+
display: true,
|
|
25
|
+
},
|
|
26
|
+
SNOOZE: {
|
|
27
|
+
name: "SNOOZE",
|
|
28
|
+
icon: React.createElement(SnoozeIcon, null),
|
|
29
|
+
label: "Snooze",
|
|
30
|
+
action: (notification) => snoozeNotifications([notification]),
|
|
31
|
+
display: true,
|
|
32
|
+
},
|
|
33
|
+
DISMISS: {
|
|
34
|
+
name: "DISMISS",
|
|
35
|
+
icon: (React.createElement("div", { className: "finsemble-icon" },
|
|
36
|
+
React.createElement("i", { className: "ff-close" }))),
|
|
37
|
+
label: "Dismiss",
|
|
38
|
+
action: () => {
|
|
39
|
+
// Empty - filled in later
|
|
40
|
+
},
|
|
41
|
+
display: true,
|
|
42
|
+
},
|
|
43
|
+
SETTINGS: {
|
|
44
|
+
name: "SETTINGS",
|
|
45
|
+
icon: (React.createElement("div", { className: "finsemble-icon" },
|
|
46
|
+
React.createElement("i", { className: "ff-settings" }))),
|
|
47
|
+
label: "Settings",
|
|
48
|
+
action: (notification) => {
|
|
49
|
+
FSBL.Clients.LauncherClient.showWindow({
|
|
50
|
+
componentType: "UserPreferences",
|
|
51
|
+
}, {
|
|
52
|
+
monitor: "mine",
|
|
53
|
+
left: "center",
|
|
54
|
+
top: "center",
|
|
55
|
+
}, () => {
|
|
56
|
+
FSBL.Clients.RouterClient.transmit("FinsembleUserPreferencesChannel", {
|
|
57
|
+
preferencesTab: "Notifications",
|
|
58
|
+
notification,
|
|
59
|
+
});
|
|
60
|
+
// we need this timeout otherwise the UserPreferences screen does not detect the message being transmited
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
FSBL.Clients.RouterClient.transmit("FinsembleNotificationsNavigationChannel", { notification });
|
|
63
|
+
}, 50);
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
display: true,
|
|
67
|
+
},
|
|
68
|
+
DETAILS: {
|
|
69
|
+
name: "DETAILS",
|
|
70
|
+
icon: (React.createElement("div", { className: "finsemble-icon" },
|
|
71
|
+
React.createElement("i", { className: "ff-dots-horz" }))),
|
|
72
|
+
label: "Details",
|
|
73
|
+
action: () => {
|
|
74
|
+
// Empty - filled in later
|
|
75
|
+
},
|
|
76
|
+
display: true,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
6
79
|
export const NotificationCardHeaderControls = ({ notification, removeNotification, uiContext = "center" }) => {
|
|
7
80
|
const notificationsContext = useContext(NotificationsContext);
|
|
8
81
|
const { setSelectedNotification, muteFilters } = notificationsContext;
|
|
9
|
-
const [overflowMenuOpen, setOverflowMenuOpen] = useState(false);
|
|
10
82
|
const [isMuteFilterApplied, setIsMuteFilterApplied] = useState(muteFilters
|
|
11
83
|
? muteFilters.some((filter) => filter.source === notification.source && filter.type === notification.type)
|
|
12
84
|
: false);
|
|
@@ -14,22 +86,23 @@ export const NotificationCardHeaderControls = ({ notification, removeNotificatio
|
|
|
14
86
|
includeSeconds: true,
|
|
15
87
|
}));
|
|
16
88
|
useEffect(() => {
|
|
89
|
+
var _a;
|
|
17
90
|
const id = setInterval(() => {
|
|
18
91
|
setTime(formatDistanceToNow(new Date(notification.issuedAt), {
|
|
19
92
|
includeSeconds: true,
|
|
20
93
|
}));
|
|
21
94
|
}, 60000);
|
|
95
|
+
// when running unit tests in node.js, node does not exit until timeouts and intervals are done
|
|
96
|
+
// Calling this allows node to exit without waiting for setInterval to complete.
|
|
97
|
+
(_a = id.unref) === null || _a === void 0 ? void 0 : _a.call(id);
|
|
22
98
|
return () => clearInterval(id);
|
|
23
99
|
});
|
|
24
|
-
const
|
|
25
|
-
setOverflowMenuOpen(!overflowMenuOpen);
|
|
26
|
-
};
|
|
27
|
-
const overFlowActions = Object.assign({}, OverflowMenuActions);
|
|
100
|
+
const overFlowActions = Object.assign({}, ContextMenuActions);
|
|
28
101
|
let optionsToggleClassName = "notification-card__more-options__toggle";
|
|
29
102
|
if (uiContext === "center") {
|
|
30
103
|
delete overFlowActions.DISMISS;
|
|
31
|
-
overFlowActions.DETAILS.action = (
|
|
32
|
-
setSelectedNotification(
|
|
104
|
+
overFlowActions.DETAILS.action = (contextNotification) => {
|
|
105
|
+
setSelectedNotification(contextNotification);
|
|
33
106
|
};
|
|
34
107
|
}
|
|
35
108
|
else {
|
|
@@ -39,10 +112,17 @@ export const NotificationCardHeaderControls = ({ notification, removeNotificatio
|
|
|
39
112
|
delete overFlowActions.DETAILS;
|
|
40
113
|
delete overFlowActions.DISMISS;
|
|
41
114
|
}
|
|
115
|
+
// Don't display read if notification is read
|
|
116
|
+
if (overFlowActions.MARK_AS_READ)
|
|
117
|
+
overFlowActions.MARK_AS_READ.display = !notification.isRead;
|
|
118
|
+
// Don't display unread if notification is unread
|
|
119
|
+
if (overFlowActions.MARK_AS_UNREAD)
|
|
120
|
+
overFlowActions.MARK_AS_UNREAD.display = notification.isRead;
|
|
42
121
|
useEffect(() => {
|
|
43
122
|
function listenMuteStateChanged(error, response) {
|
|
44
123
|
if (error) {
|
|
45
124
|
console.error("FinsembleNotificationsMuteStateChannel: ", error);
|
|
125
|
+
FSBL.Clients.Logger.system.error("FinsembleNotificationsMuteStateChannel: ", error);
|
|
46
126
|
}
|
|
47
127
|
else {
|
|
48
128
|
const { data } = response;
|
|
@@ -56,10 +136,9 @@ export const NotificationCardHeaderControls = ({ notification, removeNotificatio
|
|
|
56
136
|
FSBL.Clients.RouterClient.removeListener("FinsembleNotificationsMuteStateChannel", listenMuteStateChanged);
|
|
57
137
|
};
|
|
58
138
|
}, []);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
React.createElement(IconButton, { iconName: "ff-dots-vert", tooltip: "Options", clickHandler: toggleOverflowMenu }, overflowMenuOpen ? React.createElement(OverflowMenu, { closeSelf: setOverflowMenuOpen }, menuActions) : null)),
|
|
139
|
+
return (React.createElement("div", { className: optionsToggleClassName },
|
|
140
|
+
React.createElement("span", { className: "notification-card_context_menu" },
|
|
141
|
+
React.createElement(ContextMenuToggle, { menuActions: overFlowActions, message: notification, isMuteFilterApplied: isMuteFilterApplied })),
|
|
63
142
|
uiContext == "toasts" && (React.createElement(IconButton, { iconName: "ff-close", classNames: "notification-card__dismiss no-hover", tooltip: "Dismiss", clickHandler: removeNotification })),
|
|
64
143
|
uiContext == "center" && React.createElement("span", { className: "notification-card_timestamp" }, time)));
|
|
65
144
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationCardHeaderControls.js","sourceRoot":"","sources":["../../../../../../src/components/notifications/components/shared/notificationCard/NotificationCardHeaderControls.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,YAAY,EAAE,EAAE,mBAAmB,EAAE,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B,CAAC,CAAC;QAC5G,CAAC,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAChE,wBAAwB,CAAC,YAAY,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAClE,CAAC;IAEF,OAAO,CACN,6BAAK,SAAS,EAAE,sBAAsB,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC;QACrF,8BAAM,SAAS,EAAC,iCAAiC;YAChD,oBAAC,UAAU,IAAC,QAAQ,EAAC,cAAc,EAAC,OAAO,EAAC,SAAS,EAAC,YAAY,EAAE,kBAAkB,IACpF,gBAAgB,CAAC,CAAC,CAAC,oBAAC,YAAY,IAAC,SAAS,EAAE,mBAAmB,IAAG,WAAW,CAAgB,CAAC,CAAC,CAAC,IAAI,CACzF,CACP;QACN,SAAS,IAAI,QAAQ,IAAI,CACzB,oBAAC,UAAU,IACV,QAAQ,EAAC,UAAU,EACnB,UAAU,EAAE,qCAAqC,EACjD,OAAO,EAAC,SAAS,EACjB,YAAY,EAAE,kBAAkB,GAC/B,CACF;QACA,SAAS,IAAI,QAAQ,IAAI,8BAAM,SAAS,EAAC,6BAA6B,IAAE,IAAI,CAAQ,CAChF,CACN,CAAC;AACH,CAAC,CAAC","sourcesContent":["import React, { useContext, useEffect, useState } from \"react\";\nimport IconButton from \"../IconButton\";\nimport OverflowMenu, { OverflowMenuActions, renderOverflowMenuAction } from \"../OverflowMenu\";\nimport { NotificationsContext } from \"../../../notificationsContext\";\nimport { formatDistanceToNow } from \"date-fns\";\nimport { services } from \"@finsemble/finsemble-api\";\n\ntype INotification = services.notification.types.INotification;\n\nexport const NotificationCardHeaderControls: React.FunctionComponent<{\n\tnotification: INotification;\n\tuiContext?: string;\n\tremoveNotification?: Function;\n}> = ({ notification, removeNotification, uiContext = \"center\" }) => {\n\tconst notificationsContext = useContext(NotificationsContext);\n\tconst { setSelectedNotification, muteFilters } = notificationsContext;\n\n\tconst [overflowMenuOpen, setOverflowMenuOpen] = useState(false);\n\tconst [isMuteFilterApplied, setIsMuteFilterApplied] = useState(\n\t\tmuteFilters\n\t\t\t? muteFilters.some((filter) => filter.source === notification.source && filter.type === notification.type)\n\t\t\t: false\n\t);\n\n\tconst [time, setTime] = useState(\n\t\tformatDistanceToNow(new Date(notification.issuedAt), {\n\t\t\tincludeSeconds: true,\n\t\t})\n\t);\n\n\tuseEffect(() => {\n\t\tconst id = setInterval(() => {\n\t\t\tsetTime(\n\t\t\t\tformatDistanceToNow(new Date(notification.issuedAt), {\n\t\t\t\t\tincludeSeconds: true,\n\t\t\t\t})\n\t\t\t);\n\t\t}, 60000);\n\t\treturn () => clearInterval(id);\n\t});\n\n\tconst toggleOverflowMenu = () => {\n\t\tsetOverflowMenuOpen(!overflowMenuOpen);\n\t};\n\n\tconst overFlowActions = Object.assign({}, OverflowMenuActions);\n\tlet optionsToggleClassName = \"notification-card__more-options__toggle\";\n\n\tif (uiContext === \"center\") {\n\t\tdelete overFlowActions.DISMISS;\n\t\toverFlowActions.DETAILS.action = (overflowNotification: INotification) => {\n\t\t\tsetSelectedNotification(overflowNotification);\n\t\t};\n\t} else {\n\t\toptionsToggleClassName = \"notification-card__more-options__no-toggle\";\n\t\tdelete overFlowActions.MARK_AS_READ;\n\t\tdelete overFlowActions.MARK_AS_UNREAD;\n\t\tdelete overFlowActions.DETAILS;\n\t\tdelete overFlowActions.DISMISS;\n\t}\n\n\tuseEffect(() => {\n\t\tfunction listenMuteStateChanged(error: any, response: any) {\n\t\t\tif (error) {\n\t\t\t\tconsole.error(\"FinsembleNotificationsMuteStateChannel: \", error);\n\t\t\t} else {\n\t\t\t\tconst { data } = response;\n\t\t\t\tif (notification.source === data.source && notification.type === data.type) {\n\t\t\t\t\tsetIsMuteFilterApplied(data.isMuted);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tFSBL.Clients.RouterClient.addListener(\"FinsembleNotificationsMuteStateChannel\", listenMuteStateChanged);\n\t\treturn () => {\n\t\t\tFSBL.Clients.RouterClient.removeListener(\"FinsembleNotificationsMuteStateChannel\", listenMuteStateChanged);\n\t\t};\n\t}, []);\n\n\tconst menuActions = Object.values(overFlowActions).map((value) =>\n\t\trenderOverflowMenuAction(notification, value, isMuteFilterApplied)\n\t);\n\n\treturn (\n\t\t<div className={optionsToggleClassName} onMouseLeave={() => setOverflowMenuOpen(false)}>\n\t\t\t<span className=\"notification-card_overflow_menu\">\n\t\t\t\t<IconButton iconName=\"ff-dots-vert\" tooltip=\"Options\" clickHandler={toggleOverflowMenu}>\n\t\t\t\t\t{overflowMenuOpen ? <OverflowMenu closeSelf={setOverflowMenuOpen}>{menuActions}</OverflowMenu> : null}\n\t\t\t\t</IconButton>\n\t\t\t</span>\n\t\t\t{uiContext == \"toasts\" && (\n\t\t\t\t<IconButton\n\t\t\t\t\ticonName=\"ff-close\"\n\t\t\t\t\tclassNames={\"notification-card__dismiss no-hover\"}\n\t\t\t\t\ttooltip=\"Dismiss\"\n\t\t\t\t\tclickHandler={removeNotification}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{uiContext == \"center\" && <span className=\"notification-card_timestamp\">{time}</span>}\n\t\t</div>\n\t);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"NotificationCardHeaderControls.js","sourceRoot":"","sources":["../../../../../../src/components/notifications/components/shared/notificationCard/NotificationCardHeaderControls.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAI/C,OAAO,EACN,qBAAqB,EACrB,uBAAuB,EACvB,mBA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O,EAAE,YAAY,EACrB,mBAAmB,EAAE,mBAAmB,GACvC,CACI;QACN,SAAS,IAAI,QAAQ,IAAI,CACzB,oBAAC,UAAU,IACV,QAAQ,EAAC,UAAU,EACnB,UAAU,EAAE,qCAAqC,EACjD,OAAO,EAAC,SAAS,EACjB,YAAY,EAAE,kBAAkB,GAC/B,CACF;QACA,SAAS,IAAI,QAAQ,IAAI,8BAAM,SAAS,EAAC,6BAA6B,IAAE,IAAI,CAAQ,CAChF,CACN,CAAC;AACH,CAAC,CAAC","sourcesContent":["import React, { useContext, useEffect, useState } from \"react\";\nimport ContextMenuToggle from \"../../../../common/ContextMenu\";\nimport { NotificationsContext } from \"../../../notificationsContext\";\nimport { formatDistanceToNow } from \"date-fns\";\nimport { services } from \"@finsemble/finsemble-api\";\nimport { ContextMenuAction } from \"../../../types\";\n\nimport {\n\tmarkNotificationsRead,\n\tmarkNotificationsUnread,\n\tsnoozeNotifications,\n} from \"../../../../../hooks/useNotifications\";\n\n// Icons\nimport EnvelopeCloseIcon from \"../../../../notifications/icons/EnvelopeClose\";\nimport EnvelopeOpenIcon from \"../../../../notifications/icons/EnvelopeOpen\";\nimport SnoozeIcon from \"../../../../notifications/icons/SnoozeIcon\";\nimport IconButton from \"../IconButton\";\n\ntype INotification = services.notification.types.INotification;\n\nexport const ContextMenuActions: { [key: string]: ContextMenuAction } = {\n\tMARK_AS_UNREAD: {\n\t\tname: \"MARK_AS_UNREAD\",\n\t\ticon: <EnvelopeCloseIcon />,\n\t\tlabel: \"Mark Unread\",\n\t\taction: (notification: INotification) => markNotificationsUnread([notification]),\n\t\tdisplay: true,\n\t},\n\tMARK_AS_READ: {\n\t\tname: \"MARK_AS_READ\",\n\t\ticon: <EnvelopeOpenIcon />,\n\t\tlabel: \"Mark Read\",\n\t\taction: (notification: INotification) => markNotificationsRead([notification]),\n\t\tdisplay: true,\n\t},\n\tSNOOZE: {\n\t\tname: \"SNOOZE\",\n\t\ticon: <SnoozeIcon />,\n\t\tlabel: \"Snooze\",\n\t\taction: (notification: INotification) => snoozeNotifications([notification]),\n\t\tdisplay: true,\n\t},\n\tDISMISS: {\n\t\tname: \"DISMISS\",\n\t\ticon: (\n\t\t\t<div className=\"finsemble-icon\">\n\t\t\t\t<i className=\"ff-close\" />\n\t\t\t</div>\n\t\t),\n\t\tlabel: \"Dismiss\",\n\t\taction: () => {\n\t\t\t// Empty - filled in later\n\t\t},\n\t\tdisplay: true,\n\t},\n\tSETTINGS: {\n\t\tname: \"SETTINGS\",\n\t\ticon: (\n\t\t\t<div className=\"finsemble-icon\">\n\t\t\t\t<i className=\"ff-settings\" />\n\t\t\t</div>\n\t\t),\n\t\tlabel: \"Settings\",\n\t\taction: (notification: INotification) => {\n\t\t\tFSBL.Clients.LauncherClient.showWindow(\n\t\t\t\t{\n\t\t\t\t\tcomponentType: \"UserPreferences\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmonitor: \"mine\",\n\t\t\t\t\tleft: \"center\",\n\t\t\t\t\ttop: \"center\",\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tFSBL.Clients.RouterClient.transmit(\"FinsembleUserPreferencesChannel\", {\n\t\t\t\t\t\tpreferencesTab: \"Notifications\",\n\t\t\t\t\t\tnotification,\n\t\t\t\t\t});\n\t\t\t\t\t// we need this timeout otherwise the UserPreferences screen does not detect the message being transmited\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tFSBL.Clients.RouterClient.transmit(\"FinsembleNotificationsNavigationChannel\", { notification });\n\t\t\t\t\t}, 50);\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\tdisplay: true,\n\t},\n\tDETAILS: {\n\t\tname: \"DETAILS\",\n\t\ticon: (\n\t\t\t<div className=\"finsemble-icon\">\n\t\t\t\t<i className=\"ff-dots-horz\" />\n\t\t\t</div>\n\t\t),\n\t\tlabel: \"Details\",\n\t\taction: () => {\n\t\t\t// Empty - filled in later\n\t\t},\n\t\tdisplay: true,\n\t},\n};\n\nexport const NotificationCardHeaderControls: React.FunctionComponent<{\n\tnotification: INotification;\n\tuiContext?: string;\n\tremoveNotification?: Function;\n}> = ({ notification, removeNotification, uiContext = \"center\" }) => {\n\tconst notificationsContext = useContext(NotificationsContext);\n\tconst { setSelectedNotification, muteFilters } = notificationsContext;\n\n\tconst [isMuteFilterApplied, setIsMuteFilterApplied] = useState(\n\t\tmuteFilters\n\t\t\t? muteFilters.some((filter) => filter.source === notification.source && filter.type === notification.type)\n\t\t\t: false\n\t);\n\n\tconst [time, setTime] = useState(\n\t\tformatDistanceToNow(new Date(notification.issuedAt), {\n\t\t\tincludeSeconds: true,\n\t\t})\n\t);\n\n\tuseEffect(() => {\n\t\tconst id = setInterval(() => {\n\t\t\tsetTime(\n\t\t\t\tformatDistanceToNow(new Date(notification.issuedAt), {\n\t\t\t\t\tincludeSeconds: true,\n\t\t\t\t})\n\t\t\t);\n\t\t}, 60000);\n\n\t\t// when running unit tests in node.js, node does not exit until timeouts and intervals are done\n\t\t// Calling this allows node to exit without waiting for setInterval to complete.\n\t\tid.unref?.();\n\n\t\treturn () => clearInterval(id);\n\t});\n\n\tconst overFlowActions = Object.assign({}, ContextMenuActions);\n\tlet optionsToggleClassName = \"notification-card__more-options__toggle\";\n\n\tif (uiContext === \"center\") {\n\t\tdelete overFlowActions.DISMISS;\n\t\toverFlowActions.DETAILS.action = (contextNotification: INotification) => {\n\t\t\tsetSelectedNotification(contextNotification);\n\t\t};\n\t} else {\n\t\toptionsToggleClassName = \"notification-card__more-options__no-toggle\";\n\t\tdelete overFlowActions.MARK_AS_READ;\n\t\tdelete overFlowActions.MARK_AS_UNREAD;\n\t\tdelete overFlowActions.DETAILS;\n\t\tdelete overFlowActions.DISMISS;\n\t}\n\n\t// Don't display read if notification is read\n\tif (overFlowActions.MARK_AS_READ) overFlowActions.MARK_AS_READ.display = !notification.isRead;\n\t// Don't display unread if notification is unread\n\tif (overFlowActions.MARK_AS_UNREAD) overFlowActions.MARK_AS_UNREAD.display = notification.isRead;\n\n\tuseEffect(() => {\n\t\tfunction listenMuteStateChanged(error: any, response: any) {\n\t\t\tif (error) {\n\t\t\t\tconsole.error(\"FinsembleNotificationsMuteStateChannel: \", error);\n\t\t\t\tFSBL.Clients.Logger.system.error(\"FinsembleNotificationsMuteStateChannel: \", error);\n\t\t\t} else {\n\t\t\t\tconst { data } = response;\n\t\t\t\tif (notification.source === data.source && notification.type === data.type) {\n\t\t\t\t\tsetIsMuteFilterApplied(data.isMuted);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tFSBL.Clients.RouterClient.addListener(\"FinsembleNotificationsMuteStateChannel\", listenMuteStateChanged);\n\t\treturn () => {\n\t\t\tFSBL.Clients.RouterClient.removeListener(\"FinsembleNotificationsMuteStateChannel\", listenMuteStateChanged);\n\t\t};\n\t}, []);\n\n\treturn (\n\t\t<div className={optionsToggleClassName}>\n\t\t\t<span className=\"notification-card_context_menu\">\n\t\t\t\t<ContextMenuToggle\n\t\t\t\t\tmenuActions={overFlowActions}\n\t\t\t\t\tmessage={notification}\n\t\t\t\t\tisMuteFilterApplied={isMuteFilterApplied}\n\t\t\t\t/>\n\t\t\t</span>\n\t\t\t{uiContext == \"toasts\" && (\n\t\t\t\t<IconButton\n\t\t\t\t\ticonName=\"ff-close\"\n\t\t\t\t\tclassNames={\"notification-card__dismiss no-hover\"}\n\t\t\t\t\ttooltip=\"Dismiss\"\n\t\t\t\t\tclickHandler={removeNotification}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{uiContext == \"center\" && <span className=\"notification-card_timestamp\">{time}</span>}\n\t\t</div>\n\t);\n};\n"]}
|
|
@@ -3,9 +3,9 @@ import { format, differenceInMilliseconds, parseISO, addSeconds } from "date-fns
|
|
|
3
3
|
// Context
|
|
4
4
|
import { NotificationsContext } from "../../notificationsContext";
|
|
5
5
|
// Components
|
|
6
|
-
import IconButton from "../shared/IconButton";
|
|
7
6
|
import NoNotifications from "../NoNotifications";
|
|
8
|
-
import
|
|
7
|
+
import ContextMenuToggle from "../../../common/ContextMenu";
|
|
8
|
+
import { ContextMenuActions } from "../../../notifications/components/shared/notificationCard/NotificationCardHeaderControls";
|
|
9
9
|
import { CheckButton } from "../shared/CheckButton";
|
|
10
10
|
// Utils
|
|
11
11
|
import { getActiveFilter, getMostRecentAction, isNewNotification, isReNotification, searchNotifications, } from "../../utils";
|
|
@@ -21,10 +21,6 @@ const ListHeaderComponent = () => (React.createElement("div", { className: "list
|
|
|
21
21
|
export const NotificationListRowShell = ({ notification, newNotificationHaloPeriodSeconds, children, }) => {
|
|
22
22
|
const notificationsContext = useContext(NotificationsContext);
|
|
23
23
|
const { setSelectedNotification, muteFilters, selectionMode } = notificationsContext;
|
|
24
|
-
const [overflowMenuOpen, setOverflowMenuOpen] = useState(false);
|
|
25
|
-
const toggleOverflowMenu = () => {
|
|
26
|
-
setOverflowMenuOpen(!overflowMenuOpen);
|
|
27
|
-
};
|
|
28
24
|
const [isNew, setIsNew] = useState(isNewNotification(notification, newNotificationHaloPeriodSeconds));
|
|
29
25
|
const [wokeFromSnooze, setWokeFromSnooze] = useState(isReNotification(notification, newNotificationHaloPeriodSeconds));
|
|
30
26
|
const [isMuteFilterApplied, setIsMuteFilterApplied] = useState(muteFilters
|
|
@@ -72,7 +68,7 @@ export const NotificationListRowShell = ({ notification, newNotificationHaloPeri
|
|
|
72
68
|
clearTimeout(isRenotificationTimerId);
|
|
73
69
|
};
|
|
74
70
|
}, [newNotificationHaloPeriodSeconds, notification]);
|
|
75
|
-
const overFlowActions = Object.assign({},
|
|
71
|
+
const overFlowActions = Object.assign({}, ContextMenuActions);
|
|
76
72
|
overFlowActions.DETAILS.action = (detailNotification) => {
|
|
77
73
|
setSelectedNotification(detailNotification);
|
|
78
74
|
};
|
|
@@ -81,6 +77,7 @@ export const NotificationListRowShell = ({ notification, newNotificationHaloPeri
|
|
|
81
77
|
function listenMuteStateChanged(error, response) {
|
|
82
78
|
if (error) {
|
|
83
79
|
console.error("FinsembleNotificationsMuteStateChannel: ", error);
|
|
80
|
+
FSBL.Clients.Logger.system.error("FinsembleNotificationsMuteStateChannel: ", error);
|
|
84
81
|
}
|
|
85
82
|
else {
|
|
86
83
|
const { data } = response;
|
|
@@ -94,7 +91,6 @@ export const NotificationListRowShell = ({ notification, newNotificationHaloPeri
|
|
|
94
91
|
FSBL.Clients.RouterClient.removeListener("FinsembleNotificationsMuteStateChannel", listenMuteStateChanged);
|
|
95
92
|
};
|
|
96
93
|
}, []);
|
|
97
|
-
const menuActions = Object.values(overFlowActions).map((value) => renderOverflowMenuAction(notification, value, isMuteFilterApplied));
|
|
98
94
|
return (React.createElement("div", { className: `list-row__container notification-item ${notification.isRead ? "is-read" : ""} ${isNew || wokeFromSnooze ? "new" : ""}
|
|
99
95
|
${notification.cssClassName ? notification.cssClassName : ""}` },
|
|
100
96
|
children ? (React.createElement(React.Fragment, null,
|
|
@@ -107,7 +103,7 @@ export const NotificationListRowShell = ({ notification, newNotificationHaloPeri
|
|
|
107
103
|
React.createElement("div", { className: "list-row__cell" }, `${notification.title} - ${notification.details}`))),
|
|
108
104
|
React.createElement("div", { className: "list-row__cell" },
|
|
109
105
|
React.createElement("span", null,
|
|
110
|
-
React.createElement(
|
|
106
|
+
React.createElement(ContextMenuToggle, { menuActions: overFlowActions, message: notification, isMuteFilterApplied: false })))));
|
|
111
107
|
};
|
|
112
108
|
const ListView = ({ notificationHeaderRow, notificationListRow, notifications, }) => {
|
|
113
109
|
var _a;
|