Skip to content

Commit bef5387

Browse files
authored
Merge pull request #2765 from devtron-labs/fix/ai
chore: side panel default link
2 parents 81bd2b8 + 84cb5d5 commit bef5387

File tree

10 files changed

+62
-65
lines changed

10 files changed

+62
-65
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.15.1-pre-4",
7+
"@devtron-labs/devtron-fe-common-lib": "1.15.1-pre-5",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/components/app/details/main.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ const AIAgentContextSetterWrapper = ({ children, appName }: PropsWithChildren<{
6565
const { path, url } = useRouteMatch()
6666

6767
useEffect(() => {
68-
setAIAgentContext({ path, context: { appName, ...params }})
68+
const contextData: Record<string, string> = {
69+
...params,
70+
}
71+
if (contextData.buildId) {
72+
// For build history page
73+
contextData['Workflow_id'] = contextData.buildId
74+
delete contextData.buildId
75+
}
76+
setAIAgentContext({ path, context: { appName, ...contextData }})
6977
}, [path, url])
7078

7179
return <>{children}</>

src/components/common/SidePanel/SidePanel.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
}
1414
}
1515

16-
.side-panel-documentation {
17-
&__header {
18-
flex: 0 0 48px;
16+
.side-panel-content {
17+
&--hidden {
18+
visibility: hidden;
19+
height: 0;
1920
}
2021
}

src/components/common/SidePanel/SidePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const SidePanel = ({ asideWidth }: SidePanelProps) => {
9090
<div className="aside-drag__handle px-1 br-1" />
9191
</div>
9292
</Draggable>
93-
<div className="flex-grow-1 py-8 pr-8">
93+
<div className="flex-grow-1 py-8 pr-8 dc__overflow-hidden">
9494
<div
9595
className={`w-100 h-100 dc__position-rel br-6 bg__primary flexbox-col dc__overflow-hidden ${appTheme === AppThemeType.dark ? 'border__primary-translucent' : ''}`}
9696
>

src/components/common/SidePanel/SidePanelContent.tsx

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
GenericEmptyState,
99
Icon,
1010
ImageType,
11-
logExceptionToSentry,
1211
SidePanelTab,
1312
} from '@devtron-labs/devtron-fe-common-lib'
1413

@@ -20,7 +19,7 @@ import { TABS_CONFIG } from './constants'
2019
import { SidePanelDocumentation } from './SidePanelDocumentation'
2120
import { SidePanelHeaderActions } from './SidePanelHeaderActions'
2221
import { SidePanelContentProps } from './types'
23-
import { renderOpenTicketButton } from './utils'
22+
import { getContentWrapperClassNameForTab, renderOpenTicketButton } from './utils'
2423

2524
const AIChat = importComponentFromFELibrary(
2625
'AIChat',
@@ -35,51 +34,24 @@ const AIChat = importComponentFromFELibrary(
3534
)
3635

3736
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
6538

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} />
6943
}
7044

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+
)
8355
}
8456

8557
return (
@@ -108,7 +80,6 @@ export const SidePanelContent = ({ onClose, setSidePanelConfig, sidePanelConfig
10880
onClick={onTabClick}
10981
style={{ ...(isSelected ? { boxShadow: '0 1px 0 0 var(--bg-primary)' } : {}) }}
11082
tabIndex={0}
111-
data-config={JSON.stringify(getConfigForTab(id))}
11283
onKeyDown={onKeyDown}
11384
>
11485
<Icon name={iconName} color={isSelected ? 'N900' : 'N700'} />
@@ -137,7 +108,11 @@ export const SidePanelContent = ({ onClose, setSidePanelConfig, sidePanelConfig
137108
</div>
138109
</div>
139110

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>
141116
</>
142117
)
143118
}

src/components/common/SidePanel/SidePanelDocumentation.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useRef } from 'react'
1+
import { useEffect, useRef, useState } from 'react'
22

33
import {
44
Button,
@@ -9,6 +9,7 @@ import {
99
DOCUMENTATION,
1010
getUniqueId,
1111
Icon,
12+
ProgressBar,
1213
useMainContext,
1314
useTheme,
1415
} from '@devtron-labs/devtron-fe-common-lib'
@@ -19,18 +20,20 @@ export const SidePanelDocumentation = ({ SidePanelHeaderActions }: SidePanelCont
1920
// HOOKS
2021
const { appTheme } = useTheme()
2122
const {
22-
sidePanelConfig: { docLink = DOCUMENTATION.DOC_HOME_PAGE, reinitialize },
23+
sidePanelConfig: { docLink: sidePanelDocLink, reinitialize },
2324
setSidePanelConfig,
2425
} = useMainContext()
2526

27+
const [isLoading, setIsLoading] = useState(true)
28+
29+
const docLink = sidePanelDocLink ?? DOCUMENTATION.DOC_HOME_PAGE
30+
2631
// REFS
2732
const iframeRef = useRef<HTMLIFrameElement | null>(null)
2833
const iframeKeyRef = useRef<string | null>(`${docLink}-${getUniqueId()}`)
2934

3035
// CONSTANTS
31-
const iframeSrc = docLink
32-
? `${docLink}${docLink.includes('?') ? `&theme=${appTheme}` : `?theme=${appTheme}`}`
33-
: null
36+
const iframeSrc = `${docLink}${docLink.includes('?') ? `&theme=${appTheme}` : `?theme=${appTheme}`}`
3437

3538
useEffect(() => {
3639
/**
@@ -44,6 +47,10 @@ export const SidePanelDocumentation = ({ SidePanelHeaderActions }: SidePanelCont
4447
}
4548
}, [reinitialize])
4649

50+
const onLoad = () => {
51+
setIsLoading(false)
52+
}
53+
4754
return (
4855
<>
4956
<SidePanelHeaderActions>
@@ -61,7 +68,9 @@ export const SidePanelDocumentation = ({ SidePanelHeaderActions }: SidePanelCont
6168
/>
6269
</SidePanelHeaderActions>
6370

64-
<div className="flex-grow-1">
71+
<div className="flex-grow-1 dc__position-rel">
72+
<ProgressBar isLoading={isLoading} />
73+
6574
{iframeSrc && (
6675
<iframe
6776
key={iframeKeyRef.current}
@@ -74,6 +83,7 @@ export const SidePanelDocumentation = ({ SidePanelHeaderActions }: SidePanelCont
7483
height="100%"
7584
allow="clipboard-read; clipboard-write"
7685
referrerPolicy="strict-origin-when-cross-origin"
86+
onLoad={onLoad}
7787
/>
7888
)}
7989
</div>

src/components/common/SidePanel/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface SidePanelContentBaseProps {
1111
}
1212

1313
export interface SidePanelContentProps extends Pick<MainContext, 'sidePanelConfig' | 'setSidePanelConfig'> {
14-
tab?: SidePanelTab
1514
onClose: () => void
1615
}
1716

src/components/common/SidePanel/utils.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ComponentSizeType,
66
CONTACT_SUPPORT_LINK,
77
OPEN_NEW_TICKET,
8+
SidePanelTab,
89
} from '@devtron-labs/devtron-fe-common-lib'
910

1011
export const renderOpenTicketButton = () => (
@@ -29,3 +30,6 @@ export const renderOpenTicketButton = () => (
2930
/>
3031
</div>
3132
)
33+
34+
export const getContentWrapperClassNameForTab = (tab: SidePanelTab, expected: SidePanelTab) =>
35+
`flexbox-col dc__overflow-hidden ${tab !== expected ? 'side-panel-content--hidden' : 'flex-grow-1'}`

src/components/common/navigation/navigation.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616

1717
#root > div > main {
18-
width: 100%;
18+
width: 100vw;
1919
min-height: 100vh;
2020
display: grid;
21-
overflow-y: hidden;
21+
overflow: hidden;
2222
}
2323

2424
.main {

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,10 +1125,10 @@
11251125
dependencies:
11261126
"@jridgewell/trace-mapping" "0.3.9"
11271127

1128-
"@devtron-labs/[email protected]4":
1129-
version "1.15.1-pre-4"
1130-
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.15.1-pre-4.tgz#e08f6aa2a0dbeaf4c86f5da9ae2d7eed283d1801"
1131-
integrity sha512-YbsS4aR9hgR/DXi6ya5itARn40nvSkxLeiQrPULK1Q3KKL1zy9BiUVOyYXf1tGIAbLJIi+wQVT1w5xmQOOkA7Q==
1128+
"@devtron-labs/[email protected]5":
1129+
version "1.15.1-pre-5"
1130+
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.15.1-pre-5.tgz#5a0e58d329f066193961700c7eb2ac9f4f3e0757"
1131+
integrity sha512-71Ik06tlMy/Zd7l/XwyGeJqEkQcCxUjMyz+kDMz0jKVPCCyHSyZys2TvcHCTYRf/WRM3rmt0jvUvm+v5HL2WxA==
11321132
dependencies:
11331133
"@codemirror/lang-json" "6.0.1"
11341134
"@codemirror/lang-yaml" "6.1.2"

0 commit comments

Comments
 (0)