Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtron-labs/devtron-fe-common-lib",
"version": "1.17.0",
"version": "1.17.1",
"description": "Supporting common component library",
"type": "module",
"main": "dist/index.js",
Expand Down
3 changes: 3 additions & 0 deletions src/Shared/Components/DocLink/DocLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MouseEvent } from 'react'
import { DOCUMENTATION_HOME_PAGE } from '@Common/Constants'
import { Button, ButtonComponentType, ButtonVariantType, Icon } from '@Shared/Components'
import { ComponentSizeType } from '@Shared/constants'
import { useIsSecureConnection } from '@Shared/Hooks'
import { SidePanelTab, useMainContext } from '@Shared/Providers'

import { DocLinkProps } from './types'
Expand All @@ -24,6 +25,7 @@ export const DocLink = <T extends boolean = false>({
}: DocLinkProps<T>) => {
// HOOKS
const { isEnterprise, setSidePanelConfig, isLicenseDashboard } = useMainContext()
const isSecureConnection = useIsSecureConnection()

// CONSTANTS
const documentationLink = getDocumentationUrl({
Expand All @@ -36,6 +38,7 @@ export const DocLink = <T extends boolean = false>({
// HANDLERS
const handleClick = (e: MouseEvent<HTMLAnchorElement>) => {
if (
isSecureConnection &&
!isExternalLink &&
!openInNewTab &&
!e.metaKey &&
Expand Down
4 changes: 3 additions & 1 deletion src/Shared/Components/Header/HelpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SliderButton } from '@typeform/embed-react'
import { DOCUMENTATION_HOME_PAGE, MAX_LOGIN_COUNT, URLS } from '@Common/Constants'
import { handleAnalyticsEvent } from '@Shared/Analytics'
import { ComponentSizeType } from '@Shared/constants'
import { useIsSecureConnection } from '@Shared/Hooks'
import { AppThemeType, SidePanelTab, useMainContext, useTheme } from '@Shared/Providers'
import { InstallationType } from '@Shared/types'

Expand Down Expand Up @@ -54,6 +55,7 @@ export const HelpButton = ({ serverInfo, fetchingServerInfo, onClick, hideGettin
showGettingStartedCard,
} = useMainContext()
const { appTheme } = useTheme()
const isSecureConnection = useIsSecureConnection()

// REFS
const typeFormSliderButtonRef = useRef(null)
Expand All @@ -73,7 +75,7 @@ export const HelpButton = ({ serverInfo, fetchingServerInfo, onClick, hideGettin

const handleViewDocumentationClick: HelpButtonActionMenuProps['onClick'] = (_, e) => {
// Opens documentation in side panel when clicked normally, or in a new tab when clicked with the meta/command key
if (!e.metaKey) {
if (isSecureConnection && !e.metaKey) {
e.preventDefault()
setSidePanelConfig((prev) => ({
...prev,
Expand Down
1 change: 1 addition & 0 deletions src/Shared/Hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
export * from './UseDownload'
export * from './useForm'
export * from './useGetResourceKindsOptions'
export * from './useIsSecureConnection'
export * from './useOneTimePrompt'
export * from './UsePrompt'
export * from './useStickyEvent'
Expand Down
1 change: 1 addition & 0 deletions src/Shared/Hooks/useIsSecureConnection/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './useIsSecureConnection'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useEffect, useState } from 'react'

export const useIsSecureConnection = () => {
const [isSecure, setIsSecure] = useState(false)

useEffect(() => {
setIsSecure(window.location.protocol === 'https:')
}, [])

return isSecure
}
Loading