@camunda/camunda-composite-components 0.0.41 → 0.0.42
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/README.md +2 -1
- package/lib/esm/api/api.d.ts +19 -19
- package/lib/esm/api/api.js +65 -67
- package/lib/esm/api/endpoints.const.d.ts +12 -12
- package/lib/esm/api/endpoints.const.js +24 -25
- package/lib/esm/api/jwt.utils.d.ts +3 -3
- package/lib/esm/api/jwt.utils.js +23 -21
- package/lib/esm/api/notifications.d.ts +64 -35
- package/lib/esm/api/notifications.js +168 -159
- package/lib/esm/components/c3-empty-state/c3-empty-state.d.ts +8 -2
- package/lib/esm/components/c3-empty-state/c3-empty-state.js +58 -17
- package/lib/esm/components/c3-empty-state/c3-empty-state.types.d.ts +19 -19
- package/lib/esm/components/c3-empty-state/c3-empty-state.types.js +1 -1
- package/lib/esm/components/c3-navigation/c3-info-button.d.ts +3 -3
- package/lib/esm/components/c3-navigation/c3-info-button.js +13 -5
- package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.d.ts +5 -5
- package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.js +21 -8
- package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.types.d.ts +5 -5
- package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.types.js +1 -1
- package/lib/esm/components/c3-navigation/c3-navigation-appbar.d.ts +3 -3
- package/lib/esm/components/c3-navigation/c3-navigation-appbar.js +157 -68
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-info-sidebar.d.ts +5 -5
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-info-sidebar.js +58 -37
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.d.ts +9 -9
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.js +56 -33
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.d.ts +8 -8
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.js +114 -54
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.d.ts +70 -60
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.js +1 -1
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-notification-sidebar.d.ts +4 -4
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-notification-sidebar.js +142 -88
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-org-sidebar.d.ts +5 -5
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-org-sidebar.js +105 -51
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-sidebar-state-provider.d.ts +26 -24
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-sidebar-state-provider.js +38 -25
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-user-sidebar.d.ts +5 -5
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-user-sidebar.js +125 -43
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/components.d.ts +6 -1
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/components.js +4 -4
- package/lib/esm/components/c3-navigation/c3-navigation.d.ts +13 -2
- package/lib/esm/components/c3-navigation/c3-navigation.js +210 -88
- package/lib/esm/components/c3-navigation/c3-navigation.types.d.ts +69 -63
- package/lib/esm/components/c3-navigation/c3-navigation.types.js +1 -1
- package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-container.d.ts +30 -13
- package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-container.js +114 -70
- package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-provider.d.ts +29 -27
- package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-provider.js +118 -90
- package/lib/esm/components/c3-navigation/helpers.d.ts +5 -3
- package/lib/esm/components/c3-navigation/helpers.js +53 -49
- package/lib/esm/components/c3-navigation/index.d.ts +4 -2
- package/lib/esm/components/c3-navigation/index.js +3 -3
- package/lib/esm/components/c3-navigation/story-helpers.d.ts +23 -18
- package/lib/esm/components/c3-navigation/story-helpers.js +189 -186
- package/lib/esm/components/c3-navigation/story-templates.d.ts +8 -8
- package/lib/esm/components/c3-navigation/story-templates.js +66 -33
- package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.d.ts +20 -16
- package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.js +9 -4
- package/lib/esm/icons/c3-icons.d.ts +7 -5
- package/lib/esm/icons/c3-icons.js +82 -14
- package/lib/esm/icons/c3-icons.types.d.ts +1 -1
- package/lib/esm/icons/c3-icons.types.js +1 -1
- package/lib/esm/index.d.ts +14 -9
- package/lib/esm/index.js +4 -4
- package/package.json +2 -1
|
@@ -1,64 +1,124 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
HeaderGlobalAction,
|
|
4
|
+
HeaderPanel as CarbonHeaderPanel,
|
|
5
|
+
Stack,
|
|
6
|
+
SwitcherDivider,
|
|
7
|
+
} from "@carbon/react"
|
|
8
|
+
import React from "react"
|
|
9
|
+
import { useOnClickOutside } from "../helpers"
|
|
10
|
+
import C3NavigationSidebarElement from "./c3-navigation-sidebar-element"
|
|
11
|
+
import styled from "styled-components"
|
|
12
|
+
import { useSidebarState } from "./c3-sidebar-state-provider"
|
|
13
|
+
const Wrapper = styled.div`
|
|
8
14
|
.cds--popover * {
|
|
9
15
|
z-index: 9000;
|
|
10
16
|
}
|
|
11
|
-
|
|
12
|
-
const HeaderPanel = styled(CarbonHeaderPanel)
|
|
17
|
+
`
|
|
18
|
+
const HeaderPanel = styled(CarbonHeaderPanel)`
|
|
13
19
|
visibility: ${({ expanded }) => (expanded ? "visible" : "hidden")};
|
|
14
20
|
display: grid;
|
|
15
21
|
grid-auto-flow: row;
|
|
16
22
|
grid-auto-rows: max-content 1fr;
|
|
17
23
|
overflow-y: auto;
|
|
18
24
|
overflow-x: hidden;
|
|
19
|
-
|
|
25
|
+
`
|
|
26
|
+
const BottomElements = styled.div`
|
|
27
|
+
align-self: end;
|
|
28
|
+
|
|
29
|
+
button {
|
|
30
|
+
padding-top: 6px;
|
|
31
|
+
}
|
|
32
|
+
`
|
|
20
33
|
const C3NavigationSideBar = (props) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
34
|
+
const { icon, sideBar, children, bottomChildren } = props
|
|
35
|
+
const { callbacks, onOpen } = sideBar
|
|
36
|
+
const { isOpen, setIsOpen: setOpenState } = useSidebarState()[sideBar.type]
|
|
37
|
+
const setIsOpen = (open) => {
|
|
38
|
+
if (open) {
|
|
39
|
+
callbacks?.beforeOpening?.()
|
|
40
|
+
onOpen?.()
|
|
41
|
+
}
|
|
42
|
+
setOpenState(open)
|
|
43
|
+
if (!open) callbacks?.afterClosing?.()
|
|
44
|
+
}
|
|
45
|
+
const itemTabIndex = isOpen ? undefined : -1
|
|
46
|
+
const [panelRef, iconRef] = useOnClickOutside(() => setIsOpen(false))
|
|
47
|
+
const id = `c3-${sideBar.type}-sidebar`
|
|
48
|
+
return React.createElement(
|
|
49
|
+
Wrapper,
|
|
50
|
+
null,
|
|
51
|
+
React.createElement(
|
|
52
|
+
HeaderGlobalAction,
|
|
53
|
+
{
|
|
54
|
+
ref: iconRef,
|
|
55
|
+
"aria-label": `Open ${sideBar.ariaLabel}`,
|
|
56
|
+
"aria-expanded": isOpen,
|
|
57
|
+
"aria-controls": id,
|
|
58
|
+
onClick: () => {
|
|
59
|
+
setIsOpen(!isOpen)
|
|
60
|
+
},
|
|
61
|
+
isActive: isOpen,
|
|
62
|
+
tooltipAlignment: sideBar.type === "user" ? "end" : "center",
|
|
63
|
+
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
|
|
64
|
+
/* @ts-ignore */
|
|
65
|
+
leaveDelayMs: 100,
|
|
66
|
+
},
|
|
67
|
+
icon,
|
|
68
|
+
),
|
|
69
|
+
React.createElement(
|
|
70
|
+
HeaderPanel,
|
|
71
|
+
{ ref: panelRef, expanded: isOpen, id: id },
|
|
72
|
+
React.createElement(
|
|
73
|
+
Stack,
|
|
74
|
+
null,
|
|
75
|
+
children,
|
|
76
|
+
sideBar.elements &&
|
|
77
|
+
sideBar.elements.length > 0 &&
|
|
78
|
+
"customElements" in sideBar &&
|
|
79
|
+
sideBar.customElements &&
|
|
80
|
+
"activeOrganization" in sideBar.customElements &&
|
|
81
|
+
!sideBar.customElements?.activeOrganization &&
|
|
82
|
+
React.createElement(SwitcherDivider, null),
|
|
83
|
+
sideBar.elements?.map((element, index) =>
|
|
84
|
+
React.createElement(C3NavigationSidebarElement, {
|
|
85
|
+
key: element.key,
|
|
86
|
+
element: element,
|
|
87
|
+
index: index,
|
|
88
|
+
sideBar: sideBar,
|
|
89
|
+
setSideBarOpen: setIsOpen,
|
|
90
|
+
itemTabIndex: itemTabIndex,
|
|
91
|
+
}),
|
|
92
|
+
),
|
|
93
|
+
bottomChildren,
|
|
94
|
+
),
|
|
95
|
+
React.createElement(
|
|
96
|
+
BottomElements,
|
|
97
|
+
null,
|
|
98
|
+
sideBar.bottomElements &&
|
|
99
|
+
sideBar.bottomElements.map((element) =>
|
|
100
|
+
React.createElement(
|
|
101
|
+
Button,
|
|
102
|
+
{
|
|
103
|
+
kind: element.kind,
|
|
104
|
+
key: element.key,
|
|
105
|
+
className: "cds--switcher__item",
|
|
106
|
+
renderIcon: element.renderIcon,
|
|
107
|
+
onClick: () => {
|
|
108
|
+
if (element.onClick) {
|
|
109
|
+
element.onClick()
|
|
110
|
+
}
|
|
111
|
+
if (sideBar.closeOnClick !== false) {
|
|
112
|
+
setIsOpen(false)
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
tabIndex: itemTabIndex,
|
|
116
|
+
},
|
|
117
|
+
element.label,
|
|
118
|
+
),
|
|
119
|
+
),
|
|
120
|
+
),
|
|
121
|
+
),
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
export default C3NavigationSideBar
|
package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.d.ts
CHANGED
|
@@ -1,64 +1,74 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { C3NavigationElementProps } from "../c3-navigation.types"
|
|
3
|
-
import { Notification } from "../../../api/notifications"
|
|
2
|
+
import { C3NavigationElementProps } from "../c3-navigation.types"
|
|
3
|
+
import { Notification } from "../../../api/notifications"
|
|
4
4
|
export declare type C3NavigationSideBarBaseProps = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
export declare type C3NavigationOrgSideBarProps =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
5
|
+
ariaLabel?: string
|
|
6
|
+
isOpen?: boolean
|
|
7
|
+
onOpen?: () => void
|
|
8
|
+
closeOnClick?: boolean
|
|
9
|
+
elementClicked?: (key: string) => void
|
|
10
|
+
elements?: C3NavigationElementProps[]
|
|
11
|
+
bottomElements?: C3NavigationElementProps[]
|
|
12
|
+
}
|
|
13
|
+
export declare type C3NavigationOrgSideBarProps =
|
|
14
|
+
C3NavigationSideBarBaseProps & {
|
|
15
|
+
type: "org"
|
|
16
|
+
customElements?: {
|
|
17
|
+
activeOrganization?: {
|
|
18
|
+
activeLabel: string
|
|
19
|
+
otherLabel: string
|
|
20
|
+
orgName: string
|
|
21
|
+
action: {
|
|
22
|
+
label: string
|
|
23
|
+
onClick: () => void
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export declare type C3NavigationInfoSideBarProps =
|
|
29
|
+
C3NavigationSideBarBaseProps & {
|
|
30
|
+
type: "info"
|
|
31
|
+
version?: string
|
|
32
|
+
}
|
|
33
|
+
export declare type C3NavigationUserSideBarProps =
|
|
34
|
+
C3NavigationSideBarBaseProps & {
|
|
35
|
+
type: "user"
|
|
36
|
+
customElements?: {
|
|
37
|
+
customSection?: JSX.Element
|
|
38
|
+
profile?: {
|
|
39
|
+
label: string
|
|
40
|
+
user: {
|
|
41
|
+
name: string
|
|
42
|
+
email: string
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
themeSelector?: {
|
|
46
|
+
currentTheme: string
|
|
47
|
+
onChange: (newValue: string) => void
|
|
48
|
+
}
|
|
49
|
+
stageToggle?: {
|
|
50
|
+
prodFeaturesEnabled: boolean
|
|
51
|
+
toggle: () => void
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export declare type C3NavigationNotificationsSideBarProps =
|
|
56
|
+
C3NavigationSideBarBaseProps & {
|
|
57
|
+
type: "notifications"
|
|
58
|
+
onLinkClick?: (meta: Notification["meta"]) => void
|
|
59
|
+
}
|
|
56
60
|
export declare type C3NavigationAppBarProps = C3NavigationSideBarBaseProps & {
|
|
57
|
-
|
|
58
|
-
}
|
|
61
|
+
type: "app"
|
|
62
|
+
}
|
|
59
63
|
export declare type C3NavigationSideBarProps = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} & (
|
|
64
|
+
callbacks?: {
|
|
65
|
+
beforeOpening?: () => void
|
|
66
|
+
afterClosing?: () => void
|
|
67
|
+
}
|
|
68
|
+
} & (
|
|
69
|
+
| C3NavigationOrgSideBarProps
|
|
70
|
+
| C3NavigationInfoSideBarProps
|
|
71
|
+
| C3NavigationUserSideBarProps
|
|
72
|
+
| C3NavigationNotificationsSideBarProps
|
|
73
|
+
| C3NavigationAppBarProps
|
|
74
|
+
)
|
package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FC } from "react"
|
|
2
|
-
import { C3NavigationNotificationsSideBarProps } from "./c3-navigation-sidebar.types"
|
|
1
|
+
import { FC } from "react"
|
|
2
|
+
import { C3NavigationNotificationsSideBarProps } from "./c3-navigation-sidebar.types"
|
|
3
3
|
export declare const C3NotificationSidebar: FC<{
|
|
4
|
-
|
|
5
|
-
}
|
|
4
|
+
sideBar: C3NavigationNotificationsSideBarProps
|
|
5
|
+
}>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { Button } from "@carbon/react"
|
|
2
|
-
import { Notification as NotificationIcon } from "@carbon/react/icons"
|
|
3
|
-
import React, { useContext, useEffect, useRef, useState } from "react"
|
|
4
|
-
import styled from "styled-components"
|
|
5
|
-
import { C3BellIcon, C3NotificationsUnreadIcon } from "../../../icons/c3-icons"
|
|
6
|
-
import C3NotificationContainer, {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { Button } from "@carbon/react"
|
|
2
|
+
import { Notification as NotificationIcon } from "@carbon/react/icons"
|
|
3
|
+
import React, { useContext, useEffect, useRef, useState } from "react"
|
|
4
|
+
import styled from "styled-components"
|
|
5
|
+
import { C3BellIcon, C3NotificationsUnreadIcon } from "../../../icons/c3-icons"
|
|
6
|
+
import C3NotificationContainer, {
|
|
7
|
+
NotificationDescription,
|
|
8
|
+
NotificationTitle,
|
|
9
|
+
} from "../c3-notification-provider/c3-notification-container"
|
|
10
|
+
import { C3NotificationContext } from "../c3-notification-provider/c3-notification-provider"
|
|
11
|
+
import C3NavigationSideBar from "./c3-navigation-sidebar"
|
|
12
|
+
import { useNotificationSidebarState } from "./c3-sidebar-state-provider"
|
|
13
|
+
const PanelHeader = styled.div`
|
|
11
14
|
background: var(--cds-layer-01);
|
|
12
15
|
box-shadow: inset 0px -1px 0px var(--cds-border-subtle-01);
|
|
13
16
|
width: 100%;
|
|
@@ -17,95 +20,146 @@ const PanelHeader = styled.div `
|
|
|
17
20
|
flex-direction: row;
|
|
18
21
|
justify-content: space-between;
|
|
19
22
|
align-items: center;
|
|
20
|
-
|
|
21
|
-
const PanelTitle = styled.span
|
|
23
|
+
`
|
|
24
|
+
const PanelTitle = styled.span`
|
|
22
25
|
color: var(--cds-text-primary);
|
|
23
26
|
font-size: var(--cds-body-01-font-size);
|
|
24
27
|
font-weight: var(--cds-body-01-font-weight);
|
|
25
28
|
line-height: var(--cds-body-01-line-height);
|
|
26
29
|
letter-spacing: var(--cds-body-01-letter-spacing);
|
|
27
|
-
|
|
28
|
-
const DismissAllButton = styled(Button)
|
|
30
|
+
`
|
|
31
|
+
const DismissAllButton = styled(Button)`
|
|
29
32
|
font-size: var(--cds-helper-text-01-font-size);
|
|
30
33
|
font-weight: var(--cds-helper-text-01-font-weight);
|
|
31
34
|
line-height: var(--cds-helper-text-01-line-height);
|
|
32
35
|
letter-spacing: var(--cds-helper-text-01-letter-spacing);
|
|
33
|
-
|
|
34
|
-
const EmptyState = styled.div
|
|
36
|
+
`
|
|
37
|
+
const EmptyState = styled.div`
|
|
35
38
|
padding: 16px;
|
|
36
|
-
|
|
37
|
-
const EmptyStateTitle = styled(NotificationTitle)
|
|
39
|
+
`
|
|
40
|
+
const EmptyStateTitle = styled(NotificationTitle)`
|
|
38
41
|
margin-top: 24px;
|
|
39
|
-
|
|
40
|
-
const EmptyStateDescription = styled(NotificationDescription)
|
|
42
|
+
`
|
|
43
|
+
const EmptyStateDescription = styled(NotificationDescription)`
|
|
41
44
|
color: var(--cds-text-secondary);
|
|
42
45
|
margin-top: 8px;
|
|
43
|
-
|
|
46
|
+
`
|
|
44
47
|
export const C3NotificationSidebar = ({ sideBar }) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
48
|
+
const { onLinkClick } = sideBar
|
|
49
|
+
const {
|
|
50
|
+
notifications,
|
|
51
|
+
markAsRead,
|
|
52
|
+
dismiss,
|
|
53
|
+
markAllAsRead,
|
|
54
|
+
dismissAll,
|
|
55
|
+
analytics,
|
|
56
|
+
enabled,
|
|
57
|
+
} = useContext(C3NotificationContext)
|
|
58
|
+
const [unreadNotifications, setUnreadNotifications] = useState([])
|
|
59
|
+
const hasUnreadNotifications = notifications.some(
|
|
60
|
+
({ state }) => state === "new",
|
|
61
|
+
)
|
|
62
|
+
const { isOpen } = useNotificationSidebarState()
|
|
63
|
+
const notificationsRef = useRef()
|
|
64
|
+
notificationsRef.current = notifications
|
|
65
|
+
const markAllAsReadSidebar = () => {
|
|
66
|
+
const newNotifications = notificationsRef.current?.filter(
|
|
67
|
+
(notification) => notification.state === "new",
|
|
68
|
+
)
|
|
69
|
+
if (newNotifications) markAllAsRead(newNotifications)
|
|
70
|
+
}
|
|
71
|
+
const dismissAllSidebar = () => dismissAll(notifications)
|
|
72
|
+
const beforeOpening = () => {
|
|
73
|
+
// remember new notifications, so the dots can be displayed
|
|
74
|
+
if (notificationsRef.current)
|
|
75
|
+
setUnreadNotifications(
|
|
76
|
+
notificationsRef.current
|
|
77
|
+
.filter(({ state }) => state === "new")
|
|
78
|
+
.map(({ uuid }) => uuid),
|
|
79
|
+
)
|
|
80
|
+
markAllAsReadSidebar()
|
|
81
|
+
if (enabled && analytics) {
|
|
82
|
+
analytics("notification-panel-opened")
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const afterClosing = () => {
|
|
86
|
+
markAllAsReadSidebar()
|
|
87
|
+
setUnreadNotifications([])
|
|
88
|
+
}
|
|
89
|
+
const sortNotificationsDescending = (a, b) => {
|
|
90
|
+
if (new Date(a.timestamp) > new Date(b.timestamp)) return -1
|
|
91
|
+
return 0
|
|
92
|
+
}
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
// mark notifications as read on unmount
|
|
95
|
+
return () => {
|
|
96
|
+
if (isOpen) markAllAsReadSidebar()
|
|
97
|
+
}
|
|
98
|
+
}, [])
|
|
99
|
+
return React.createElement(
|
|
100
|
+
C3NavigationSideBar,
|
|
101
|
+
{
|
|
102
|
+
sideBar: {
|
|
103
|
+
...sideBar,
|
|
104
|
+
ariaLabel: sideBar.ariaLabel || "Notification Sidebar",
|
|
105
|
+
callbacks: { beforeOpening, afterClosing },
|
|
106
|
+
},
|
|
107
|
+
icon: hasUnreadNotifications
|
|
108
|
+
? React.createElement(C3NotificationsUnreadIcon, { size: 20 })
|
|
109
|
+
: React.createElement(NotificationIcon, {
|
|
110
|
+
size: 20,
|
|
111
|
+
label: "Notifications",
|
|
112
|
+
}),
|
|
113
|
+
},
|
|
114
|
+
React.createElement(
|
|
115
|
+
PanelHeader,
|
|
116
|
+
null,
|
|
117
|
+
React.createElement(PanelTitle, null, "Notifications"),
|
|
118
|
+
notifications.length > 0 &&
|
|
119
|
+
// eslint-disable-next-line
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
React.createElement(
|
|
122
|
+
DismissAllButton,
|
|
123
|
+
{ kind: "ghost", size: "sm", onClick: dismissAllSidebar },
|
|
124
|
+
"Dismiss all",
|
|
125
|
+
),
|
|
126
|
+
),
|
|
127
|
+
notifications.length > 0
|
|
128
|
+
? notifications.sort(sortNotificationsDescending).map((notification) =>
|
|
129
|
+
React.createElement(C3NotificationContainer, {
|
|
130
|
+
key: notification.uuid,
|
|
131
|
+
onRead: () => {
|
|
132
|
+
if (notification.state === "new") {
|
|
133
|
+
markAsRead(notification)
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
onDismiss: () => dismiss(notification),
|
|
137
|
+
originalOnLinkClick: onLinkClick,
|
|
138
|
+
onLinkClick: () => {
|
|
139
|
+
if (enabled && analytics) {
|
|
140
|
+
analytics(
|
|
141
|
+
"notification-clicked-cta",
|
|
142
|
+
notification.meta?.identifier,
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
if (onLinkClick) {
|
|
146
|
+
onLinkClick(notification.meta)
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
unread: unreadNotifications.some((id) => id === notification.uuid),
|
|
150
|
+
...notification,
|
|
151
|
+
}),
|
|
152
|
+
)
|
|
153
|
+
: React.createElement(
|
|
154
|
+
EmptyState,
|
|
155
|
+
null,
|
|
156
|
+
React.createElement(C3BellIcon, { size: 56 }),
|
|
157
|
+
React.createElement(EmptyStateTitle, null, "No notifications"),
|
|
158
|
+
React.createElement(
|
|
159
|
+
EmptyStateDescription,
|
|
160
|
+
null,
|
|
161
|
+
"New updates regarding your processes, clusters and more will appear here.",
|
|
162
|
+
),
|
|
163
|
+
),
|
|
164
|
+
)
|
|
165
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC } from "react"
|
|
2
|
-
import { C3NavigationOrgSideBarProps } from "./c3-navigation-sidebar.types"
|
|
1
|
+
import { FC } from "react"
|
|
2
|
+
import { C3NavigationOrgSideBarProps } from "./c3-navigation-sidebar.types"
|
|
3
3
|
declare const C3OrgSidebar: FC<{
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export default C3OrgSidebar
|
|
4
|
+
sideBar: C3NavigationOrgSideBarProps
|
|
5
|
+
}>
|
|
6
|
+
export default C3OrgSidebar
|