8
8
GenericEmptyState ,
9
9
Icon ,
10
10
ImageType ,
11
- logExceptionToSentry ,
12
11
SidePanelTab ,
13
12
} from '@devtron-labs/devtron-fe-common-lib'
14
13
@@ -20,7 +19,7 @@ import { TABS_CONFIG } from './constants'
20
19
import { SidePanelDocumentation } from './SidePanelDocumentation'
21
20
import { SidePanelHeaderActions } from './SidePanelHeaderActions'
22
21
import { SidePanelContentProps } from './types'
23
- import { renderOpenTicketButton } from './utils'
22
+ import { getContentWrapperClassNameForTab , renderOpenTicketButton } from './utils'
24
23
25
24
const AIChat = importComponentFromFELibrary (
26
25
'AIChat' ,
@@ -35,51 +34,24 @@ const AIChat = importComponentFromFELibrary(
35
34
)
36
35
37
36
export const SidePanelContent = ( { onClose, setSidePanelConfig, sidePanelConfig } : SidePanelContentProps ) => {
38
- const tab = sidePanelConfig . state
39
-
40
- const renderContent = ( ) => {
41
- switch ( tab ) {
42
- case SidePanelTab . DOCUMENTATION :
43
- return < SidePanelDocumentation SidePanelHeaderActions = { SidePanelHeaderActions } />
44
- case SidePanelTab . ASK_DEVTRON :
45
- // NOTE: even if flag is off, for oss clients need to show EnterpriseTrialDialog
46
- if ( ! AIChat || window . _env_ ?. FEATURE_ASK_DEVTRON_EXPERT ) {
47
- return < AIChat SidePanelHeaderActions = { SidePanelHeaderActions } />
48
- }
49
-
50
- return (
51
- < GenericEmptyState
52
- title = "AI Integration not configured"
53
- subTitle = "For AI-powered insights, please follow documentation or contact the Devtron team."
54
- SvgImage = { ICMaintenance }
55
- imageType = { ImageType . Medium }
56
- isButtonAvailable
57
- renderButton = { renderOpenTicketButton }
58
- />
59
- )
60
- default :
61
- logExceptionToSentry ( `Unknown ${ tab } in SidePanelContent` )
62
- return null
63
- }
64
- }
37
+ const tab = sidePanelConfig . state as SidePanelTab
65
38
66
- const getConfigForTab = ( tabId : SidePanelTab ) => {
67
- if ( sidePanelConfig . state === tabId ) {
68
- return sidePanelConfig
39
+ const renderAIChat = ( ) => {
40
+ // NOTE: even if flag is off, for oss clients need to show EnterpriseTrialDialog
41
+ if ( ! AIChat || window . _env_ ?. FEATURE_ASK_DEVTRON_EXPERT ) {
42
+ return < AIChat SidePanelHeaderActions = { SidePanelHeaderActions } />
69
43
}
70
44
71
- switch ( tabId ) {
72
- case SidePanelTab . ASK_DEVTRON :
73
- return {
74
- state : SidePanelTab . ASK_DEVTRON ,
75
- }
76
- case SidePanelTab . DOCUMENTATION :
77
- default :
78
- return {
79
- state : SidePanelTab . DOCUMENTATION ,
80
- docLink : null ,
81
- }
82
- }
45
+ return (
46
+ < GenericEmptyState
47
+ title = "AI Integration not configured"
48
+ subTitle = "For AI-powered insights, please follow documentation or contact the Devtron team."
49
+ SvgImage = { ICMaintenance }
50
+ imageType = { ImageType . Medium }
51
+ isButtonAvailable
52
+ renderButton = { renderOpenTicketButton }
53
+ />
54
+ )
83
55
}
84
56
85
57
return (
@@ -108,7 +80,6 @@ export const SidePanelContent = ({ onClose, setSidePanelConfig, sidePanelConfig
108
80
onClick = { onTabClick }
109
81
style = { { ...( isSelected ? { boxShadow : '0 1px 0 0 var(--bg-primary)' } : { } ) } }
110
82
tabIndex = { 0 }
111
- data-config = { JSON . stringify ( getConfigForTab ( id ) ) }
112
83
onKeyDown = { onKeyDown }
113
84
>
114
85
< Icon name = { iconName } color = { isSelected ? 'N900' : 'N700' } />
@@ -137,7 +108,11 @@ export const SidePanelContent = ({ onClose, setSidePanelConfig, sidePanelConfig
137
108
</ div >
138
109
</ div >
139
110
140
- { renderContent ( ) }
111
+ < div className = { getContentWrapperClassNameForTab ( tab , SidePanelTab . DOCUMENTATION ) } >
112
+ < SidePanelDocumentation SidePanelHeaderActions = { SidePanelHeaderActions } />
113
+ </ div >
114
+
115
+ < div className = { getContentWrapperClassNameForTab ( tab , SidePanelTab . ASK_DEVTRON ) } > { renderAIChat ( ) } </ div >
141
116
</ >
142
117
)
143
118
}
0 commit comments