Skip to content

Commit e45f38c

Browse files
committed
feat: update SidePanel and SidePanelDocumentation to handle reinitialization of iframe and improve doc link handling
1 parent fa41148 commit e45f38c

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

src/components/charts/list/DiscoverCharts.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,10 @@ const ChartListHeader = ({ charts }) => {
754754
Select chart to deploy.  
755755
<DocLink
756756
dataTestId="chart-group-link"
757-
docLinkKey="CHART_GROUP"
758-
text="Learn more about chart groups"
757+
docLinkKey="CHART_LIST"
758+
text="Learn how to deploy charts"
759759
fontWeight="normal"
760+
size={ComponentSizeType.small}
760761
/>
761762
</p>
762763
</div>

src/components/common/SidePanel/SidePanel.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const SidePanel = ({ asideWidth }: SidePanelProps) => {
4646
// HANDLERS
4747
const handleClose = () => {
4848
asideWidth.set(SIDE_PANEL_MIN_ASIDE_WIDTH)
49-
setSidePanelConfig({ open: false })
49+
setSidePanelConfig({ open: false, docLink: null, reinitialize: false })
5050
}
5151

5252
const handleDrag: DraggableEventHandler = (_, data) => {
@@ -89,11 +89,13 @@ export const SidePanel = ({ asideWidth }: SidePanelProps) => {
8989
<div className="aside-drag__handle px-1 br-1" />
9090
</div>
9191
</Draggable>
92-
<div
93-
className={`flex-grow-1 dc__position-rel mt-8 mr-8 mb-8 br-6 bg__primary flexbox-col dc__overflow-hidden ${appTheme === AppThemeType.dark ? 'border__primary-translucent' : ''}`}
94-
>
95-
{contentOverlay && <div className="dc__position-abs w-100 h-100 dc__zi-1" />}
96-
<SidePanelDocumentation onClose={handleClose} />
92+
<div className="flex-grow-1 py-8 pr-8">
93+
<div
94+
className={`w-100 h-100 dc__position-rel br-6 bg__primary flexbox-col dc__overflow-hidden ${appTheme === AppThemeType.dark ? 'border__primary-translucent' : ''}`}
95+
>
96+
{contentOverlay && <div className="dc__position-abs w-100 h-100 dc__zi-1" />}
97+
<SidePanelDocumentation onClose={handleClose} />
98+
</div>
9799
</div>
98100
</motion.aside>
99101
)}

src/components/common/SidePanel/SidePanelDocumentation.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { useRef } from 'react'
1+
import { useEffect, useRef } from 'react'
22

33
import {
44
Button,
55
ButtonComponentType,
66
ButtonStyleType,
77
ButtonVariantType,
88
ComponentSizeType,
9+
getUniqueId,
910
Icon,
1011
useMainContext,
1112
useTheme,
@@ -17,17 +18,31 @@ export const SidePanelDocumentation = ({ onClose }: SidePanelDocumentationProps)
1718
// HOOKS
1819
const { appTheme } = useTheme()
1920
const {
20-
sidePanelConfig: { docLink },
21+
sidePanelConfig: { docLink, reinitialize },
22+
setSidePanelConfig,
2123
} = useMainContext()
2224

2325
// REFS
2426
const iframeRef = useRef<HTMLIFrameElement | null>(null)
27+
const iframeKeyRef = useRef<string | null>(`${docLink}-${getUniqueId()}`)
2528

2629
// CONSTANTS
2730
const iframeSrc = docLink
2831
? `${docLink}${docLink.includes('?') ? `&theme=${appTheme}` : `?theme=${appTheme}`}`
2932
: null
3033

34+
useEffect(() => {
35+
/**
36+
* Reinitializes the iframe when the reinitialize flag is set to true. \
37+
* This is needed to reload the iframe content whenever doc link is clicked (reinitialize is set to true). \
38+
* It generates a new unique key for the iframe which forces React to recreate it.
39+
*/
40+
if (reinitialize) {
41+
iframeKeyRef.current = `${docLink}-${getUniqueId()}`
42+
setSidePanelConfig((prev) => ({ ...prev, reinitialize: false }))
43+
}
44+
}, [reinitialize])
45+
3146
return (
3247
<>
3348
<div className="side-panel-documentation__header px-16 pt-12 pb-11 border__primary--bottom flex dc__gap-12">
@@ -61,7 +76,7 @@ export const SidePanelDocumentation = ({ onClose }: SidePanelDocumentationProps)
6176
<div className="flex-grow-1">
6277
{iframeSrc && (
6378
<iframe
64-
key={iframeSrc}
79+
key={iframeKeyRef.current}
6580
ref={iframeRef}
6681
title="side-panel-documentation"
6782
loading="lazy"

src/components/common/navigation/NavigationRoutes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export default function NavigationRoutes({ reloadVersionConfig }: Readonly<Navig
154154
const [licenseInfoDialogType, setLicenseInfoDialogType] = useState<LicenseInfoDialogType>(null)
155155
const [intelligenceConfig, setIntelligenceConfig] = useState<IntelligenceConfig>(null)
156156

157-
const [sidePanelConfig, setSidePanelConfig] = useState<SidePanelConfig>({ open: false })
157+
const [sidePanelConfig, setSidePanelConfig] = useState<SidePanelConfig>({ open: false, docLink: null, reinitialize: false })
158158
const asideWidth = useMotionValue(0)
159159

160160
const {

src/components/dockerRegistry/ManageRegistry.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ import {
3535
InfoIconTippy,
3636
InfoBlock,
3737
DocLink,
38+
stopPropagation,
3839
} from '@devtron-labs/devtron-fe-common-lib'
3940
import { REQUIRED_FIELD_MSG } from '../../config/constantMessaging'
40-
import { Link } from 'react-router-dom'
4141

4242
export const DropdownIndicator = (props) => {
4343
return (
@@ -322,6 +322,7 @@ const ManageRegistry = ({
322322
docLinkKey="SPECIFY_IMAGE_PULL_SECRET"
323323
text="image pull secret name created via CLI"
324324
fontWeight="normal"
325+
onClick={stopPropagation}
325326
/>
326327
. The secret must be present in the namespaces you're deploying to.
327328
</div>

0 commit comments

Comments
 (0)