Skip to content

Commit d1c8241

Browse files
committed
feat: add handling for insecure connections in SidePanelDocumentation
1 parent a0a16e8 commit d1c8241

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

src/assets/img/img-page-blocked.webp

19.2 KB
Binary file not shown.

src/components/common/SidePanel/SidePanelDocumentation.tsx

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,44 @@ import {
77
ButtonVariantType,
88
ComponentSizeType,
99
DOCUMENTATION,
10+
GenericEmptyState,
1011
getUniqueId,
1112
Icon,
1213
ProgressBar,
1314
SidePanelTab,
15+
useIsSecureConnection,
1416
useMainContext,
1517
useTheme,
1618
} from '@devtron-labs/devtron-fe-common-lib'
1719

20+
import ImgPageBlocked from '@Images/img-page-blocked.webp'
21+
1822
import { SidePanelContentBaseProps } from './types'
1923

24+
const renderButton = (docLink: string) => () => (
25+
<Button
26+
dataTestId="open-in-new-tab-button"
27+
endIcon={<Icon name="ic-arrow-square-out" color={null} />}
28+
variant={ButtonVariantType.text}
29+
size={ComponentSizeType.medium}
30+
component={ButtonComponentType.anchor}
31+
text="Open in new tab"
32+
anchorProps={{
33+
href: docLink,
34+
}}
35+
/>
36+
)
37+
2038
export const SidePanelDocumentation = ({ SidePanelHeaderActions }: SidePanelContentBaseProps) => {
2139
// HOOKS
2240
const { appTheme } = useTheme()
2341
const {
2442
sidePanelConfig: { state, docLink: sidePanelDocLink, reinitialize },
2543
setSidePanelConfig,
2644
} = useMainContext()
45+
const isSecureConnection = useIsSecureConnection()
2746

28-
const [isLoading, setIsLoading] = useState(true)
47+
const [isLoading, setIsLoading] = useState(isSecureConnection)
2948

3049
const docLink = sidePanelDocLink ?? DOCUMENTATION.DOC_HOME_PAGE
3150

@@ -74,19 +93,29 @@ export const SidePanelDocumentation = ({ SidePanelHeaderActions }: SidePanelCont
7493
<div className="flex-grow-1 dc__position-rel">
7594
<ProgressBar isLoading={isLoading} />
7695

77-
{iframeSrc && (
78-
<iframe
79-
key={iframeKeyRef.current}
80-
ref={iframeRef}
81-
title="side-panel-documentation"
82-
loading="lazy"
83-
className="dc__no-border"
84-
src={iframeSrc}
85-
width="100%"
86-
height="100%"
87-
allow="clipboard-read; clipboard-write"
88-
referrerPolicy="strict-origin-when-cross-origin"
89-
onLoad={onLoad}
96+
{isSecureConnection ? (
97+
iframeSrc && (
98+
<iframe
99+
key={iframeKeyRef.current}
100+
ref={iframeRef}
101+
title="side-panel-documentation"
102+
loading="lazy"
103+
className="dc__no-border"
104+
src={iframeSrc}
105+
width="100%"
106+
height="100%"
107+
allow="clipboard-read; clipboard-write"
108+
referrerPolicy="strict-origin-when-cross-origin"
109+
onLoad={onLoad}
110+
/>
111+
)
112+
) : (
113+
<GenericEmptyState
114+
title="Unable to load docs"
115+
subTitle="Your Devtron setup isn’t secure, so the documentation can’t be displayed here."
116+
image={ImgPageBlocked}
117+
isButtonAvailable
118+
renderButton={renderButton(docLink)}
90119
/>
91120
)}
92121
</div>

0 commit comments

Comments
 (0)