@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotifications.js","sourceRoot":"","sources":["../../src/hooks/useNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,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AED,0DAA0D;IAC1D,SAAS,CAAC,GAAG,EAAE;QACd,MAAM,SAAS,GAAG,IAAI,EAAE,CAAC;QACzB,OAAO,GAAG,EAAE;YACX,wCAAwC;YACxC,CAAC,KAAK,IAAI,EAAE;gBACX,MAAM,eAAe,GAAG,MAAM,SAAS,CAAC;gBACxC,IAAI,eAAe,EAAE;oBACpB,MAAM,kBAAkB,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;iBACzD;YACF,CAAC,CAAC,EAAE,CAAC;QACN,CAAC,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACN,mBAAmB;QACnB,eAAe;QACf,oBAAoB;QACpB,sBAAsB;QACtB,wBAAwB;QACxB,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,kBAAkB;QAClB,kBAAkB;KAClB,CAAC;AACH,CAAC","sourcesContent":["import { useEffect, useReducer } from \"react\";\nimport { WindowConfig, NotificationsConfig } from \"../components/notifications/types\";\nimport { usePubSub } from \"./usePubSub\";\nimport { NOTIFICATIONS_PUBSUB_TOPIC } from \"../components/notifications/constants\";\nimport { services } from \"@finsemble/finsemble-api\";\nimport { FEA } from \"@finsemble/finsemble-api\";\ntype NotificationServiceState = services.notification.types.NotificationServiceState;\n\ntype IFilter = services.notification.types.IFilter;\ntype IMuteFilter = services.notification.types.IMuteFilter;\ntype INotification = services.notification.types.INotification;\ntype INotificationHistoryOptions = services.notification.types.INotificationHistoryOptions;\ntype MonitorInfoDetail = FEA.MonitorInfoDetail;\n\nconst { WindowClient, NotificationClient } = FSBL.Clients;\n\nconst initialState: any = { notifications: [] };\n\n/*\nAction Types\n*/\nconst CREATE_MULTIPLE = \"CREATE_MULTIPLE\";\nconst UPDATE = \"UPDATE\";\nconst REMOVE = \"REMOVE\";\n\n/*\n\tReducer\n\t*/\nfunction reducer(state: { notifications: INotification[] }, action: { type: string; payload: any }) {\n\tswitch (action.type) {\n\t\tcase CREATE_MULTIPLE:\n\t\t\treturn {\n\t\t\t\tnotifications: [...state.notifications, ...action.payload],\n\t\t\t};\n\t\tcase UPDATE: {\n\t\t\t// check to see if the notification exists if so update the values\n\t\t\tconst notificationExistsInArray = state.notifications.find(\n\t\t\t\t(notification: INotification) => notification.id === action.payload.id\n\t\t\t);\n\n\t\t\t//if the notification exists then do nothing and return the current state else add the the new notification to the state\n\t\t\tconst notifications = notificationExistsInArray\n\t\t\t\t? state.notifications.map((notification: INotification) =>\n\t\t\t\t\t\tnotification.id === action.payload.id ? action.payload : notification\n\t\t\t\t )\n\t\t\t\t: [action.payload, ...state.notifications];\n\n\t\t\treturn { notifications };\n\t\t}\n\t\tcase REMOVE:\n\t\t\treturn {\n\t\t\t\tnotifications: state.notifications.filter((notification) => notification.id !== action.payload.id),\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new Error();\n\t}\n}\n\ntype NotificationUIStatePublish = (state: NotificationServiceState) => void;\n\n/**\n * Thin wrapper around usePubSub to give us typesafety for the notification service's UI state.\n * Automatically appends this client's windowName which is used by the notification service to\n * display the notification center on an appropriate monitor.\n */\nexport const useNotificationUI = (): [state: NotificationServiceState, setState: NotificationUIStatePublish] => {\n\tconst [state, setState] = usePubSub(NOTIFICATIONS_PUBSUB_TOPIC);\n\n\tconst setStateAndAddWindowName = (newState: NotificationServiceState) => {\n\t\tsetState({\n\t\t\t...newState,\n\t\t\tmostRecentWindowName: finsembleWindow.name,\n\t\t});\n\t};\n\treturn [state as NotificationServiceState, setStateAndAddWindowName];\n};\n\nconst getActiveDescriptorsByType = (componentType: string): Promise<any[]> =>\n\tnew Promise(async (resolve, reject) => {\n\t\tFSBL.Clients.LauncherClient.getActiveDescriptors((err: any, data: any) => {\n\t\t\tconst activeDescriptors: any[] = [];\n\t\t\tif (err) {\n\t\t\t\treject(err);\n\t\t\t} else {\n\t\t\t\tfor (const key in data) {\n\t\t\t\t\tif (data.hasOwnProperty(key) && data[key]?.componentType === componentType) {\n\t\t\t\t\t\tactiveDescriptors.push(data[key]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tresolve(activeDescriptors);\n\t\t});\n\t});\n\nlet toolbarWindowName: string;\n\nexport const moveToToolbarMonitor = async () => {\n\tconst getToolbarMonitorData = async () =>\n\t\tnew Promise<MonitorInfoDetail | undefined>(async (resolve, reject) => {\n\t\t\tif (!toolbarWindowName) {\n\t\t\t\tconst activeDescriptors = await getActiveDescriptorsByType(\"Toolbar\");\n\t\t\t\ttoolbarWindowName = activeDescriptors[0]?.name;\n\t\t\t}\n\t\t\tconst { err, data } = await FSBL.Clients.LauncherClient.getMonitorInfo({\n\t\t\t\twindowIdentifier: { windowName: toolbarWindowName },\n\t\t\t});\n\n\t\t\tif (err) {\n\t\t\t\tFSBL.Clients.Logger.system.error(\"Could not get Monitor info\", err);\n\t\t\t\treject(err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve(data);\n\t\t});\n\n\tconst data = await getToolbarMonitorData();\n\tconst { data: windowMonitor } = await FSBL.Clients.LauncherClient.getMonitorInfo({\n\t\twindowIdentifier: { windowName: finsembleWindow.name },\n\t});\n\n\tconst { data: bounds } = await finsembleWindow.getBounds();\n\tconst width = (bounds?.right ?? 0) - (bounds?.left ?? 0);\n\n\t/**\n\t * It's been reported that on docked laptops and some curved monitors that getMonitorInfo returns undefined.\n\t * The root cause of this has not been determined.\n\t *\n\t * The second condition prevents execution if toolbar and window on the same monitor\n\t */\n\tif (!data || data.deviceId === windowMonitor?.deviceId) return;\n\n\t// notifications-toasts window shouldn't have a full monitor height to prevent flickering\n\tconst height = finsembleWindow.name === \"notifications-toasts\" ? 0 : data[\"availableRect\"][\"height\"];\n\tfinsembleWindow.setBounds(\n\t\t{\n\t\t\tbounds: {\n\t\t\t\ttop: data[\"availableRect\"][\"top\"],\n\t\t\t\tleft: data[\"availableRect\"][\"right\"] - width,\n\t\t\t\theight: height,\n\t\t\t\twidth: width,\n\t\t\t},\n\t\t},\n\t\t(err: any) => {\n\t\t\tif (err) {\n\t\t\t\tFSBL.Clients.Logger.system.error(\"Could not update position\", err);\n\t\t\t}\n\t\t}\n\t);\n};\n\nexport const getOS = () => {\n\tif (navigator.platform.indexOf(\"Win\") != -1) {\n\t\treturn \"Windows\";\n\t} else if (navigator.platform.indexOf(\"Linux\") != -1) {\n\t\treturn \"Linux\";\n\t} else if (navigator.platform.indexOf(\"Mac\") != -1) {\n\t\treturn \"Mac\";\n\t}\n};\n\n/**\n * Example for setting up button clicks\n *\n * @param notification\n * @param action\n */\nexport const doAction = (notification: INotification, action: any) => {\n\ttry {\n\t\tNotificationClient.performAction([notification], action).then(() => {\n\t\t\t// NOTE: The request to perform the action has be sent to the notifications service successfully\n\t\t\t// The action itself has not necessarily been perform successfully\n\t\t\t// 1) alert user notification has been sent (action may not have completed)\n\t\t});\n\t} catch (e) {\n\t\t// NOTE: The request to perform the action has failed\n\t\tconsole.error(\"could not create a notification client\", e);\n\t\tFSBL.Clients.Logger.system.error(\"could not create a notification client\", e);\n\t}\n};\n\n/**\n * Example for setting up button clicks\n *\n * @param filter\n */\nexport const mute = async (filter: IMuteFilter) => {\n\ttry {\n\t\tawait NotificationClient.mute(filter);\n\t} catch (e) {\n\t\t// NOTE: The request to perform the action has failed\n\t\tconsole.error(\"Could not save mute preferences\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not save mute preferences\", e);\n\t}\n};\n\n/**\n * Example for setting up button clicks\n *\n * @param filter\n */\nexport const unmute = async (filter: IMuteFilter) => {\n\ttry {\n\t\tawait NotificationClient.unmute(filter);\n\t} catch (e) {\n\t\t// NOTE: The request to perform the action has failed\n\t\tconsole.error(\"Could not save mute preferences\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not save mute preferences\", e);\n\t}\n};\n\n/**\n * Snooze a notification\n *\n * @param {INotification[]} notifications\n */\nexport const snoozeNotifications = async (notifications: INotification[]) => {\n\tconst preferences: any = await FSBL.Clients.NotificationClient.getPreferences();\n\tconst snoozeAction = new FSBL.Clients.NotificationClient.Action();\n\tsnoozeAction.type = FSBL.Clients.NotificationClient.ActionTypes.SNOOZE;\n\tif (preferences && preferences.defaultSnoozePeriodSeconds) {\n\t\tsnoozeAction.milliseconds = preferences.defaultSnoozePeriodSeconds * 1000;\n\t}\n\tsnoozeAction.buttonText = \"Snooze\";\n\n\tfor (let i = 0; i < notifications.length; i++) {\n\t\tdoAction(notifications[i], snoozeAction);\n\t}\n};\n\n/**\n * Marks a notification as read\n *\n * @param {INotification[]} notifications\n */\nexport const markNotificationsUnread = (notifications: INotification[]) => {\n\ttry {\n\t\tNotificationClient.markUnread(notifications).then(() => {\n\t\t\t// NOTE: The request to perform the action has be sent to the notifications service successfully\n\t\t\t// The action itself has not necessarily been perform successfully\n\t\t});\n\t} catch (e) {\n\t\tconsole.error(\"Error marking messages as unread\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not mark notification as unread\", e);\n\t}\n};\n\n/**\n * Marks a notification as read\n *\n * @param {INotification[]} notifications\n */\nexport const markNotificationsRead = (notifications: INotification[]) => {\n\ttry {\n\t\tNotificationClient.markRead(notifications).then(() => {\n\t\t\t// NOTE: The request to perform the action has be sent to the notifications service successfully\n\t\t\t// The action itself has not necessarily been perform successfully\n\t\t});\n\t} catch (e) {\n\t\tconsole.error(\"Error marking messages as read\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not mark notification as read\", e);\n\t}\n};\n\n/**\n * Dismisses a notification\n *\n * @param {INotification[]} notifications\n */\nexport const dismissNotification = (notifications: INotification[]) => {\n\ttry {\n\t\tNotificationClient.deleteNotifications(notifications).then(() => {\n\t\t\t// NOTE: The request to perform the action has be sent to the notifications service successfully\n\t\t\t// The action itself has not necessarily been perform successfully\n\t\t});\n\t} catch (e) {\n\t\tconsole.error(\"Error marking messages as read\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not mark notification as read\", e);\n\t}\n};\n\nexport const initializeCenterToggle = () => {\n\tconst [uiState, setUIState] = useNotificationUI();\n\n\tconst toggleCenter = () => {\n\t\tsetUIState({\n\t\t\t...uiState,\n\t\t\tshowCenter: !uiState.showCenter,\n\t\t});\n\t};\n\n\treturn {\n\t\ttoggleCenter,\n\t};\n};\n\n/**\n * Get Notification's config from\n */\nexport const getNotificationConfig = (): NotificationsConfig => {\n\tconst config: WindowConfig = WindowClient.options.customData;\n\n\treturn Object.assign(config?.window?.data?.notifications || {}, {\n\t\tisTransparent: config?.window?.options?.transparent || false,\n\t});\n};\n\nexport const getFetchHistoryParams = (config: any, params: any) => {\n\tconst notificationsHistory = config?.notificationsHistory || params?.config?.notificationsHistory;\n\n\t// Backwards compatibility - `since` replaced with `options` object\n\tlet options = notificationsHistory.since ? notificationsHistory.since : null;\n\n\t// Use options object if it's been set in the component config\n\tif (!options) {\n\t\toptions = notificationsHistory?.options;\n\t}\n\n\t// If no options object set and notificationsHistory is true set in config, use the params\n\tif (!options && typeof notificationsHistory === \"boolean\" && notificationsHistory) {\n\t\toptions = params?.config?.notificationsHistory.options;\n\t}\n\n\tconst filter = notificationsHistory.filter ? notificationsHistory.filter : null;\n\n\treturn [options, filter];\n};\n\nexport default function useNotifications(params: any = {}) {\n\tconst [state, dispatch] = useReducer(reducer, initialState);\n\n\t/*\n\t\tAction Creators\n\t*/\n\tconst removeNotification = (notification: INotification) => {\n\t\tdispatch({ type: REMOVE, payload: notification });\n\t};\n\n\tconst addNotification = (notification: INotification) => {\n\t\tdispatch({ type: UPDATE, payload: notification });\n\t};\n\n\tconst addMultipleNotifications = (notifications: INotification[]) => {\n\t\tdispatch({ type: CREATE_MULTIPLE, payload: notifications });\n\t};\n\n\t/**\n\t * Group Notifications by Type\n\t * @param notifications\n\t */\n\tconst groupNotificationsByType = (notifications: INotification[]) => {\n\t\tconst groupBy = (arr: INotification[]) =>\n\t\t\tarr\n\t\t\t\t.map((notification: INotification): string => notification.type ?? \"unknown\")\n\t\t\t\t.reduce((acc: { [x: string]: any }, notificationType: string, index: number) => {\n\t\t\t\t\tacc[notificationType] = [...(acc[notificationType] || []), arr[index]];\n\t\t\t\t\treturn acc;\n\t\t\t\t}, {});\n\n\t\treturn groupBy(notifications);\n\t};\n\n\t/**\n\t * \t * get the past notifications\n\t * WARNING - The default will get all notifications all the way back from 1969!!!\n\t * @param since\n\t * @param filter\n\t */\n\tconst getNotificationHistory = (\n\t\tsince: INotificationHistoryOptions = { sentAfter: \"1969-12-31T23:59:59.999Z\" },\n\t\tfilter: null | IFilter = null\n\t): Promise<INotification[]> => NotificationClient.fetchHistory(since, filter as IFilter);\n\n\tconst notificationIsActive = (notification: INotification, applyMuteFilterOverride?: boolean | undefined) => {\n\t\tlet applyMuteFilters = applyMuteFilterOverride;\n\n\t\tif (typeof applyMuteFilterOverride === \"undefined\") {\n\t\t\tconst config = getNotificationConfig();\n\t\t\tapplyMuteFilters = config?.applyMuteFilters ? config.applyMuteFilters : false;\n\t\t}\n\n\t\treturn (\n\t\t\t!notification.isSnoozed &&\n\t\t\t!notification.isRead &&\n\t\t\t!notification.isDeleted &&\n\t\t\t(applyMuteFilters ? !notification.isMuted : true)\n\t\t);\n\t};\n\n\tconst activeNotifications = (notifications: INotification[], applyMuteFilterOverride?: boolean | undefined) =>\n\t\tnotifications.filter((notification) => notificationIsActive(notification, applyMuteFilterOverride));\n\n\t/**\n\t * Main init function to start the subscription\n\t */\n\tasync function init() {\n\t\ttry {\n\t\t\tconst subscription = new NotificationClient.Subscription();\n\n\t\t\tconst notificationConfig: NotificationsConfig = getNotificationConfig();\n\n\t\t\tconst filter: IFilter = new NotificationClient.Filter();\n\n\t\t\t// make filters from the config\n\t\t\tif (notificationConfig) {\n\t\t\t\tnotificationConfig.filter?.include && filter.include?.push(...notificationConfig.filter.include);\n\t\t\t\tnotificationConfig.filter?.exclude && filter.exclude?.push(...notificationConfig.filter.exclude);\n\t\t\t}\n\n\t\t\tsubscription.filter = filter;\n\n\t\t\tconst notificationsHistory = notificationConfig?.notificationsHistory || params?.config?.notificationsHistory;\n\n\t\t\tif (notificationsHistory) {\n\t\t\t\tconst [options, historyFilter] = getFetchHistoryParams(notificationConfig, params);\n\n\t\t\t\tconst pastNotifications = await getNotificationHistory(options, historyFilter);\n\t\t\t\taddMultipleNotifications(pastNotifications);\n\t\t\t}\n\t\t\tconst onNotification = function (notification: INotification) {\n\t\t\t\t// This function will be called when a notification arrives\n\t\t\t\tif (notification.isDeleted) {\n\t\t\t\t\tremoveNotification(notification);\n\t\t\t\t} else {\n\t\t\t\t\taddNotification(notification);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\treturn NotificationClient.subscribe(subscription, onNotification);\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n\n\t/**\n\t * Set opaque class to html element\n\t */\n\tfunction setOpaqueClassName(isOpaque: boolean) {\n\t\tif (isOpaque) {\n\t\t\tconst htmlElement = document.getElementsByTagName(\"html\")[0];\n\t\t\tif (!htmlElement.className.includes(\"opaque\")) {\n\t\t\t\thtmlElement.className = `${htmlElement.className} opaque`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// start receiving Notifications and putting them in state\n\tuseEffect(() => {\n\t\tconst subscribe = init();\n\t\treturn () => {\n\t\t\t// Unsubscribe using the subscription ID\n\t\t\t(async () => {\n\t\t\t\tconst subscribeObject = await subscribe;\n\t\t\t\tif (subscribeObject) {\n\t\t\t\t\tawait NotificationClient.unsubscribe(subscribeObject.id);\n\t\t\t\t}\n\t\t\t})();\n\t\t};\n\t}, []);\n\n\treturn {\n\t\tactiveNotifications,\n\t\taddNotification,\n\t\tnotificationIsActive,\n\t\tgetNotificationHistory,\n\t\tgroupNotificationsByType,\n\t\tnotifications: state.notifications,\n\t\tremoveNotification,\n\t\tsetOpaqueClassName,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useNotifications.js","sourceRoot":"","sources":["../../src/hooks/useNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa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G,EAAE;YACX,wCAAwC;YACxC,CAAC,KAAK,IAAI,EAAE;gBACX,MAAM,eAAe,GAAG,MAAM,SAAS,CAAC;gBACxC,IAAI,eAAe,EAAE;oBACpB,MAAM,kBAAkB,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;iBACzD;YACF,CAAC,CAAC,EAAE,CAAC;QACN,CAAC,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACN,mBAAmB;QACnB,eAAe;QACf,oBAAoB;QACpB,sBAAsB;QACtB,wBAAwB;QACxB,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,kBAAkB;QAClB,kBAAkB;KAClB,CAAC;AACH,CAAC","sourcesContent":["import { useEffect, useReducer } from \"react\";\nimport { WindowConfig, NotificationsConfig } from \"../components/notifications/types\";\nimport { usePubSub } from \"./usePubSub\";\nimport { NOTIFICATIONS_PUBSUB_TOPIC } from \"../components/notifications/constants\";\nimport { services } from \"@finsemble/finsemble-api\";\nimport { FEA } from \"@finsemble/finsemble-api\";\ntype NotificationServiceState = services.notification.types.NotificationServiceState;\ntype IAction = services.notification.types.IAction;\n\ntype IFilter = services.notification.types.IFilter;\ntype IMuteFilter = services.notification.types.IMuteFilter;\ntype INotification = services.notification.types.INotification;\ntype INotificationHistoryOptions = services.notification.types.INotificationHistoryOptions;\ntype MonitorInfoDetail = FEA.MonitorInfoDetail;\n\nconst { WindowClient, NotificationClient } = FSBL.Clients;\n\nconst initialState: any = { notifications: [] };\n\n/*\nAction Types\n*/\nconst CREATE_MULTIPLE = \"CREATE_MULTIPLE\";\nconst UPDATE = \"UPDATE\";\nconst REMOVE = \"REMOVE\";\n\n/*\n\tReducer\n\t*/\nfunction reducer(state: { notifications: INotification[] }, action: { type: string; payload: any }) {\n\tswitch (action.type) {\n\t\tcase CREATE_MULTIPLE:\n\t\t\treturn {\n\t\t\t\tnotifications: [...state.notifications, ...action.payload],\n\t\t\t};\n\t\tcase UPDATE: {\n\t\t\t// check to see if the notification exists if so update the values\n\t\t\tconst notificationExistsInArray = state.notifications.find(\n\t\t\t\t(notification: INotification) => notification.id === action.payload.id\n\t\t\t);\n\n\t\t\t//if the notification exists then do nothing and return the current state else add the the new notification to the state\n\t\t\tconst notifications = notificationExistsInArray\n\t\t\t\t? state.notifications.map((notification: INotification) =>\n\t\t\t\t\t\tnotification.id === action.payload.id ? action.payload : notification\n\t\t\t\t )\n\t\t\t\t: [action.payload, ...state.notifications];\n\n\t\t\treturn { notifications };\n\t\t}\n\t\tcase REMOVE:\n\t\t\treturn {\n\t\t\t\tnotifications: state.notifications.filter((notification) => notification.id !== action.payload.id),\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new Error();\n\t}\n}\n\ntype NotificationUIStatePublish = (state: NotificationServiceState) => void;\n\n/**\n * Thin wrapper around usePubSub to give us typesafety for the notification service's UI state.\n * Automatically appends this client's windowName which is used by the notification service to\n * display the notification center on an appropriate monitor.\n */\nexport const useNotificationUI = (): [state: NotificationServiceState, setState: NotificationUIStatePublish] => {\n\tconst [state, setState] = usePubSub(NOTIFICATIONS_PUBSUB_TOPIC);\n\n\tconst setStateAndAddWindowName = (newState: NotificationServiceState) => {\n\t\tsetState({\n\t\t\t...newState,\n\t\t\tmostRecentWindowName: finsembleWindow.name,\n\t\t});\n\t};\n\treturn [state as NotificationServiceState, setStateAndAddWindowName];\n};\n\nconst getActiveDescriptorsByType = (componentType: string): Promise<any[]> =>\n\tnew Promise(async (resolve, reject) => {\n\t\tFSBL.Clients.LauncherClient.getActiveDescriptors((err: any, data: any) => {\n\t\t\tconst activeDescriptors: any[] = [];\n\t\t\tif (err) {\n\t\t\t\treject(err);\n\t\t\t} else {\n\t\t\t\tfor (const key in data) {\n\t\t\t\t\tif (data.hasOwnProperty(key) && data[key]?.componentType === componentType) {\n\t\t\t\t\t\tactiveDescriptors.push(data[key]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tresolve(activeDescriptors);\n\t\t});\n\t});\n\nlet toolbarWindowName: string;\n\nexport const moveToToolbarMonitor = async () => {\n\tconst getToolbarMonitorData = async () =>\n\t\tnew Promise<MonitorInfoDetail | undefined>(async (resolve, reject) => {\n\t\t\tif (!toolbarWindowName) {\n\t\t\t\tconst activeDescriptors = await getActiveDescriptorsByType(\"Toolbar\");\n\t\t\t\ttoolbarWindowName = activeDescriptors[0]?.name;\n\t\t\t}\n\t\t\tconst { err, data } = await FSBL.Clients.LauncherClient.getMonitorInfo({\n\t\t\t\twindowIdentifier: { windowName: toolbarWindowName },\n\t\t\t});\n\n\t\t\tif (err) {\n\t\t\t\tFSBL.Clients.Logger.system.error(\"Could not get Monitor info\", err);\n\t\t\t\treject(err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve(data);\n\t\t});\n\n\tconst data = await getToolbarMonitorData();\n\tconst { data: windowMonitor } = await FSBL.Clients.LauncherClient.getMonitorInfo({\n\t\twindowIdentifier: { windowName: finsembleWindow.name },\n\t});\n\n\tconst { data: bounds } = await finsembleWindow.getBounds();\n\tconst width = (bounds?.right ?? 0) - (bounds?.left ?? 0);\n\n\t/**\n\t * It's been reported that on docked laptops and some curved monitors that getMonitorInfo returns undefined.\n\t * The root cause of this has not been determined.\n\t *\n\t * The second condition prevents execution if toolbar and window on the same monitor\n\t */\n\tif (!data || data.deviceId === windowMonitor?.deviceId) return;\n\n\t// notifications-toasts window shouldn't have a full monitor height to prevent flickering\n\tconst height = finsembleWindow.name === \"notifications-toasts\" ? 0 : data[\"availableRect\"][\"height\"];\n\tfinsembleWindow.setBounds(\n\t\t{\n\t\t\tbounds: {\n\t\t\t\ttop: data[\"availableRect\"][\"top\"],\n\t\t\t\tleft: data[\"availableRect\"][\"right\"] - width,\n\t\t\t\theight: height,\n\t\t\t\twidth: width,\n\t\t\t},\n\t\t},\n\t\t(err: any) => {\n\t\t\tif (err) {\n\t\t\t\tFSBL.Clients.Logger.system.error(\"Could not update position\", err);\n\t\t\t}\n\t\t}\n\t);\n};\n\nexport const getOS = () => {\n\tif (navigator.platform.indexOf(\"Win\") != -1) {\n\t\treturn \"Windows\";\n\t} else if (navigator.platform.indexOf(\"Linux\") != -1) {\n\t\treturn \"Linux\";\n\t} else if (navigator.platform.indexOf(\"Mac\") != -1) {\n\t\treturn \"Mac\";\n\t}\n};\n\n/**\n * Example for setting up button clicks\n *\n * @param notification\n * @param action\n */\nexport const doAction = (notification: INotification, action: any) => {\n\ttry {\n\t\tFSBL.Clients.NotificationClient.performAction([notification], action).then(() => {\n\t\t\t// NOTE: The request to perform the action has be sent to the notifications service successfully\n\t\t\t// The action itself has not necessarily been performed successfully\n\t\t\t// 1) alert user notification has been sent (action may not have completed)\n\t\t});\n\t} catch (e) {\n\t\t// NOTE: The request to perform the action has failed\n\t\tconsole.error(\"could not create a notification client\", e);\n\t\tFSBL.Clients.Logger.system.error(\"could not create a notification client\", e);\n\t}\n};\n\n/**\n * Example for setting up button clicks\n *\n * @param filter\n */\nexport const mute = async (filter: IMuteFilter) => {\n\ttry {\n\t\tawait NotificationClient.mute(filter);\n\t} catch (e) {\n\t\t// NOTE: The request to perform the action has failed\n\t\tconsole.error(\"Could not save mute preferences\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not save mute preferences\", e);\n\t}\n};\n\n/**\n * Example for setting up button clicks\n *\n * @param filter\n */\nexport const unmute = async (filter: IMuteFilter) => {\n\ttry {\n\t\tawait NotificationClient.unmute(filter);\n\t} catch (e) {\n\t\t// NOTE: The request to perform the action has failed\n\t\tconsole.error(\"Could not save mute preferences\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not save mute preferences\", e);\n\t}\n};\n\n/**\n * Snooze a notification\n *\n * @param {INotification[]} notifications\n */\nexport const snoozeNotifications = async (notifications: INotification[]) => {\n\tconst preferences: any = await FSBL.Clients.NotificationClient.getPreferences();\n\tconst snoozeAction: IAction = {\n\t\tbuttonText: \"Snooze\",\n\t\ttype: \"SNOOZE\",\n\t};\n\tif (preferences && preferences.defaultSnoozePeriodSeconds) {\n\t\tsnoozeAction.milliseconds = preferences.defaultSnoozePeriodSeconds * 1000;\n\t}\n\n\tfor (let i = 0; i < notifications.length; i++) {\n\t\tdoAction(notifications[i], snoozeAction);\n\t}\n};\n\n/**\n * Marks a notification as read\n *\n * @param {INotification[]} notifications\n */\nexport const markNotificationsUnread = (notifications: INotification[]) => {\n\ttry {\n\t\tNotificationClient.markUnread(notifications).then(() => {\n\t\t\t// NOTE: The request to perform the action has be sent to the notifications service successfully\n\t\t\t// The action itself has not necessarily been perform successfully\n\t\t});\n\t} catch (e) {\n\t\tconsole.error(\"Error marking messages as unread\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not mark notification as unread\", e);\n\t}\n};\n\n/**\n * Marks a notification as read\n *\n * @param {INotification[]} notifications\n */\nexport const markNotificationsRead = (notifications: INotification[]) => {\n\ttry {\n\t\tNotificationClient.markRead(notifications).then(() => {\n\t\t\t// NOTE: The request to perform the action has be sent to the notifications service successfully\n\t\t\t// The action itself has not necessarily been perform successfully\n\t\t});\n\t} catch (e) {\n\t\tconsole.error(\"Error marking messages as read\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not mark notification as read\", e);\n\t}\n};\n\n/**\n * Dismisses a notification\n *\n * @param {INotification[]} notifications\n */\nexport const dismissNotification = (notifications: INotification[]) => {\n\ttry {\n\t\tNotificationClient.deleteNotifications(notifications).then(() => {\n\t\t\t// NOTE: The request to perform the action has be sent to the notifications service successfully\n\t\t\t// The action itself has not necessarily been perform successfully\n\t\t});\n\t} catch (e) {\n\t\tconsole.error(\"Error marking messages as read\", e);\n\t\tFSBL.Clients.Logger.system.error(\"Could not mark notification as read\", e);\n\t}\n};\n\nexport const initializeCenterToggle = () => {\n\tconst [uiState, setUIState] = useNotificationUI();\n\n\tconst toggleCenter = () => {\n\t\tsetUIState({\n\t\t\t...uiState,\n\t\t\tshowCenter: !uiState.showCenter,\n\t\t});\n\t};\n\n\treturn {\n\t\ttoggleCenter,\n\t};\n};\n\n/**\n * Get Notification's config from\n */\nexport const getNotificationConfig = (): NotificationsConfig => {\n\tconst config: WindowConfig = WindowClient.options.customData;\n\n\treturn Object.assign(config?.window?.data?.notifications || {}, {\n\t\tisTransparent: config?.window?.options?.transparent || false,\n\t});\n};\n\nexport const getFetchHistoryParams = (config: any, params: any) => {\n\tconst notificationsHistory = config?.notificationsHistory || params?.config?.notificationsHistory;\n\n\t// Backwards compatibility - `since` replaced with `options` object\n\tlet options = notificationsHistory.since ? notificationsHistory.since : null;\n\n\t// Use options object if it's been set in the component config\n\tif (!options) {\n\t\toptions = notificationsHistory?.options;\n\t}\n\n\t// If no options object set and notificationsHistory is true set in config, use the params\n\tif (!options && typeof notificationsHistory === \"boolean\" && notificationsHistory) {\n\t\toptions = params?.config?.notificationsHistory.options;\n\t}\n\n\tconst filter = notificationsHistory.filter ? notificationsHistory.filter : null;\n\n\treturn [options, filter];\n};\n\nexport default function useNotifications(params: any = {}) {\n\tconst [state, dispatch] = useReducer(reducer, initialState);\n\n\t/*\n\t\tAction Creators\n\t*/\n\tconst removeNotification = (notification: INotification) => {\n\t\tdispatch({ type: REMOVE, payload: notification });\n\t};\n\n\tconst addNotification = (notification: INotification) => {\n\t\tdispatch({ type: UPDATE, payload: notification });\n\t};\n\n\tconst addMultipleNotifications = (notifications: INotification[]) => {\n\t\tdispatch({ type: CREATE_MULTIPLE, payload: notifications });\n\t};\n\n\t/**\n\t * Group Notifications by Type\n\t * @param notifications\n\t */\n\tconst groupNotificationsByType = (notifications: INotification[]) => {\n\t\tconst groupBy = (arr: INotification[]) =>\n\t\t\tarr\n\t\t\t\t.map((notification: INotification): string => notification.type ?? \"unknown\")\n\t\t\t\t.reduce((acc: { [x: string]: any }, notificationType: string, index: number) => {\n\t\t\t\t\tacc[notificationType] = [...(acc[notificationType] || []), arr[index]];\n\t\t\t\t\treturn acc;\n\t\t\t\t}, {});\n\n\t\treturn groupBy(notifications);\n\t};\n\n\t/**\n\t * \t * get the past notifications\n\t * WARNING - The default will get all notifications all the way back from 1969!!!\n\t * @param since\n\t * @param filter\n\t */\n\tconst getNotificationHistory = (\n\t\tsince: INotificationHistoryOptions = { sentAfter: \"1969-12-31T23:59:59.999Z\" },\n\t\tfilter: null | IFilter = null\n\t): Promise<INotification[]> => NotificationClient.fetchHistory(since, filter as IFilter);\n\n\tconst notificationIsActive = (notification: INotification, applyMuteFilterOverride?: boolean | undefined) => {\n\t\tlet applyMuteFilters = applyMuteFilterOverride;\n\n\t\tif (typeof applyMuteFilterOverride === \"undefined\") {\n\t\t\tconst config = getNotificationConfig();\n\t\t\tapplyMuteFilters = config?.applyMuteFilters ? config.applyMuteFilters : false;\n\t\t}\n\n\t\treturn (\n\t\t\t!notification.isSnoozed &&\n\t\t\t!notification.isRead &&\n\t\t\t!notification.isDeleted &&\n\t\t\t(applyMuteFilters ? !notification.isMuted : true)\n\t\t);\n\t};\n\n\tconst activeNotifications = (notifications: INotification[], applyMuteFilterOverride?: boolean | undefined) =>\n\t\tnotifications.filter((notification) => notificationIsActive(notification, applyMuteFilterOverride));\n\n\t/**\n\t * Main init function to start the subscription\n\t */\n\tasync function init() {\n\t\ttry {\n\t\t\tconst subscription = new NotificationClient.Subscription();\n\n\t\t\tconst notificationConfig: NotificationsConfig = getNotificationConfig();\n\n\t\t\tconst filter: IFilter = new NotificationClient.Filter();\n\n\t\t\t// make filters from the config\n\t\t\tif (notificationConfig) {\n\t\t\t\tnotificationConfig.filter?.include && filter.include?.push(...notificationConfig.filter.include);\n\t\t\t\tnotificationConfig.filter?.exclude && filter.exclude?.push(...notificationConfig.filter.exclude);\n\t\t\t}\n\n\t\t\tsubscription.filter = filter;\n\n\t\t\tconst notificationsHistory = notificationConfig?.notificationsHistory || params?.config?.notificationsHistory;\n\n\t\t\tif (notificationsHistory) {\n\t\t\t\tconst [options, historyFilter] = getFetchHistoryParams(notificationConfig, params);\n\n\t\t\t\tconst pastNotifications = await getNotificationHistory(options, historyFilter);\n\t\t\t\taddMultipleNotifications(pastNotifications);\n\t\t\t}\n\t\t\tconst onNotification = function (notification: INotification) {\n\t\t\t\t// This function will be called when a notification arrives\n\t\t\t\tif (notification.isDeleted) {\n\t\t\t\t\tremoveNotification(notification);\n\t\t\t\t} else {\n\t\t\t\t\taddNotification(notification);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\treturn NotificationClient.subscribe(subscription, onNotification);\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n\n\t/**\n\t * Set opaque class to html element\n\t */\n\tfunction setOpaqueClassName(isOpaque: boolean) {\n\t\tif (isOpaque) {\n\t\t\tconst htmlElement = document.getElementsByTagName(\"html\")[0];\n\t\t\tif (!htmlElement.classList.contains(\"opaque\")) {\n\t\t\t\thtmlElement.classList.add(\"opaque\");\n\t\t\t}\n\t\t}\n\t}\n\n\t// start receiving Notifications and putting them in state\n\tuseEffect(() => {\n\t\tconst subscribe = init();\n\t\treturn () => {\n\t\t\t// Unsubscribe using the subscription ID\n\t\t\t(async () => {\n\t\t\t\tconst subscribeObject = await subscribe;\n\t\t\t\tif (subscribeObject) {\n\t\t\t\t\tawait NotificationClient.unsubscribe(subscribeObject.id);\n\t\t\t\t}\n\t\t\t})();\n\t\t};\n\t}, []);\n\n\treturn {\n\t\tactiveNotifications,\n\t\taddNotification,\n\t\tnotificationIsActive,\n\t\tgetNotificationHistory,\n\t\tgroupNotificationsByType,\n\t\tnotifications: state.notifications,\n\t\tremoveNotification,\n\t\tsetOpaqueClassName,\n\t};\n}\n"]}
|