@taruvi/navkit 0.0.48-beta.9 → 0.0.48

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.
@@ -5,6 +5,7 @@ export const shortcutsStyles = {
5
5
  display: { xs: 'none', md: 'flex' },
6
6
  alignItems: 'center',
7
7
  gap: '10px',
8
+ ml: spacing.md,
8
9
  },
9
10
  mobileTrigger: {
10
11
  display: { xs: 'flex', md: 'none' },
@@ -15,12 +16,9 @@ export const shortcutsStyles = {
15
16
  display: 'flex',
16
17
  flexDirection: 'column' as const,
17
18
  alignItems: 'center',
18
- justifyContent: 'center',
19
19
  textDecoration: 'none',
20
20
  cursor: 'pointer',
21
21
  color: colours.text.secondary,
22
- minWidth: 40,
23
- minHeight: 40,
24
22
  '&:hover': {
25
23
  opacity: 0.7,
26
24
  },
@@ -1,10 +1,17 @@
1
1
  import type { AppData } from '../../types'
2
- import { Box, Link, IconButton } from '@mui/material'
2
+ import { Box, Link, IconButton, SvgIcon } from '@mui/material'
3
3
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
4
4
  import { shortcutsStyles } from './Shortcuts.styles'
5
5
  import { useNavigation } from '../../NavkitContext'
6
6
 
7
+ const ChatIcon = ({ color }: { color?: string }) => (
8
+ <SvgIcon viewBox="-2 -2 24 24" sx={{ fontSize: 23, display: 'block', position: 'relative', top: 2 }}>
9
+ <path d="M18 0H2C0.9 0 0 0.9 0 2V20L4 16H18C19.1 16 20 15.1 20 14V2C20 0.9 19.1 0 18 0Z" fill={color || "#9DE5FD"}/>
10
+ </SvgIcon>
11
+ )
12
+
7
13
  interface ShortcutsProps {
14
+ showChat?: (showChat: boolean) => void
8
15
  onMenuToggle?: () => void
9
16
  triggerRef?: React.RefObject<HTMLButtonElement | null>
10
17
  iconColor?: string
@@ -12,8 +19,8 @@ interface ShortcutsProps {
12
19
 
13
20
  const Shortcuts = (props: ShortcutsProps) => {
14
21
 
15
- const { onMenuToggle, triggerRef, iconColor } = props
16
- const { navigateToUrl, siteSettings } = useNavigation()
22
+ const { showChat, onMenuToggle, triggerRef, iconColor } = props
23
+ const { navigateToUrl, siteSettings, isUserAuthenticated } = useNavigation()
17
24
  const shortcuts = siteSettings.shortcuts
18
25
 
19
26
  const handleShortcutClick = (shortcut: AppData) => {
@@ -38,10 +45,19 @@ const Shortcuts = (props: ShortcutsProps) => {
38
45
  />
39
46
  </Link>
40
47
  ))}
48
+ {siteSettings['show-chat'] && siteSettings['chat-url'] && isUserAuthenticated &&
49
+ <Link
50
+ key={"chat"}
51
+ onClick={() => showChat?.(true)}
52
+ sx={shortcutsStyles.shortcut}
53
+ >
54
+ <ChatIcon color={iconColor} />
55
+ </Link>
56
+ }
41
57
  </Box>
42
58
 
43
59
  {/* Mobile view - trigger button */}
44
- {(shortcuts?.length ?? 0) > 0 && (
60
+ {((shortcuts?.length ?? 0) > 0 || (siteSettings['show-chat'] && siteSettings['chat-url'] && isUserAuthenticated)) && (
45
61
  <IconButton
46
62
  ref={triggerRef}
47
63
  onClick={onMenuToggle}
@@ -1,13 +1,22 @@
1
- import { Card, MenuItem, Typography } from '@mui/material'
1
+ import { Card, MenuItem, Typography, SvgIcon } from '@mui/material'
2
2
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
3
3
  import type { AppData } from '../../types'
4
4
  import { getShortcutsMenuStyles } from './ShortcutsMenu.styles'
5
5
  import { useNavigation } from '../../NavkitContext'
6
6
 
7
- interface ShortcutsMenuProps {}
7
+ const ChatIcon = ({ style }: { style: Record<string, any> }) => (
8
+ <SvgIcon viewBox="-2 -2 24 24" sx={{ fontSize: style.fontSize, color: style.color }}>
9
+ <path d="M18 0H2C0.9 0 0 0.9 0 2V20L4 16H18C19.1 16 20 15.1 20 14V2C20 0.9 19.1 0 18 0Z" fill="currentColor"/>
10
+ </SvgIcon>
11
+ )
8
12
 
9
- const ShortcutsMenu = (_props: ShortcutsMenuProps) => {
10
- const { navigateToUrl, siteSettings, themeMode } = useNavigation()
13
+ interface ShortcutsMenuProps {
14
+ showChat: (showChat: boolean) => void
15
+ }
16
+
17
+ const ShortcutsMenu = (props: ShortcutsMenuProps) => {
18
+ const { showChat } = props
19
+ const { navigateToUrl, siteSettings, isUserAuthenticated, themeMode } = useNavigation()
11
20
  const shortcuts = siteSettings.shortcuts
12
21
  const themedStyles = getShortcutsMenuStyles(themeMode)
13
22
 
@@ -19,6 +28,18 @@ const ShortcutsMenu = (_props: ShortcutsMenuProps) => {
19
28
 
20
29
  return (
21
30
  <Card sx={themedStyles.menu}>
31
+ {siteSettings['show-chat'] && siteSettings['chat-url'] && isUserAuthenticated && (
32
+ <MenuItem
33
+ key="chat"
34
+ onClick={() => showChat(true)}
35
+ sx={themedStyles.menuItem}
36
+ >
37
+ <ChatIcon style={themedStyles.iconStyle} />
38
+ <Typography sx={themedStyles.menuItemText}>
39
+ Chat
40
+ </Typography>
41
+ </MenuItem>
42
+ )}
22
43
  {shortcuts?.map((shortcut) => (
23
44
  <MenuItem
24
45
  key={shortcut.id}
package/src/types.ts CHANGED
@@ -32,13 +32,13 @@ export interface NavigationContextType {
32
32
  navigateToUrl: (url: string, openInLine: boolean) => void
33
33
  isDesk: boolean
34
34
  appsList: AppData[]
35
+ fetchUserAppsList: (name?: string) => Promise<void>
35
36
  userData: UserData | null
36
37
  siteSettings: SiteSettings
37
38
  appSettings: AppSettings
38
39
  appSettingsLoaded: boolean
39
40
  appName?: string
40
- chatUrl: string
41
- sessionToken: string
41
+ jwtToken: string
42
42
  isUserAuthenticated: boolean
43
43
  client: Client
44
44
  auth: Auth