@@ -7,25 +7,44 @@ import {
7
7
ButtonVariantType ,
8
8
ComponentSizeType ,
9
9
DOCUMENTATION ,
10
+ GenericEmptyState ,
10
11
getUniqueId ,
11
12
Icon ,
12
13
ProgressBar ,
13
14
SidePanelTab ,
15
+ useIsSecureConnection ,
14
16
useMainContext ,
15
17
useTheme ,
16
18
} from '@devtron-labs/devtron-fe-common-lib'
17
19
20
+ import ImgPageBlocked from '@Images/img-page-blocked.webp'
21
+
18
22
import { SidePanelContentBaseProps } from './types'
19
23
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
+
20
38
export const SidePanelDocumentation = ( { SidePanelHeaderActions } : SidePanelContentBaseProps ) => {
21
39
// HOOKS
22
40
const { appTheme } = useTheme ( )
23
41
const {
24
42
sidePanelConfig : { state, docLink : sidePanelDocLink , reinitialize } ,
25
43
setSidePanelConfig,
26
44
} = useMainContext ( )
45
+ const isSecureConnection = useIsSecureConnection ( )
27
46
28
- const [ isLoading , setIsLoading ] = useState ( true )
47
+ const [ isLoading , setIsLoading ] = useState ( isSecureConnection )
29
48
30
49
const docLink = sidePanelDocLink ?? DOCUMENTATION . DOC_HOME_PAGE
31
50
@@ -74,19 +93,29 @@ export const SidePanelDocumentation = ({ SidePanelHeaderActions }: SidePanelCont
74
93
< div className = "flex-grow-1 dc__position-rel" >
75
94
< ProgressBar isLoading = { isLoading } />
76
95
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 ) }
90
119
/>
91
120
) }
92
121
</ div >
0 commit comments