diff --git a/package-lock.json b/package-lock.json index db90e2aaa..71b0db8b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.17.0", + "version": "1.17.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.17.0", + "version": "1.17.1", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index 1473fed9a..52d979718 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/Shared/Components/DocLink/DocLink.tsx b/src/Shared/Components/DocLink/DocLink.tsx index 5867dc29a..bb72a9957 100644 --- a/src/Shared/Components/DocLink/DocLink.tsx +++ b/src/Shared/Components/DocLink/DocLink.tsx @@ -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' @@ -24,6 +25,7 @@ export const DocLink = ({ }: DocLinkProps) => { // HOOKS const { isEnterprise, setSidePanelConfig, isLicenseDashboard } = useMainContext() + const isSecureConnection = useIsSecureConnection() // CONSTANTS const documentationLink = getDocumentationUrl({ @@ -36,6 +38,7 @@ export const DocLink = ({ // HANDLERS const handleClick = (e: MouseEvent) => { if ( + isSecureConnection && !isExternalLink && !openInNewTab && !e.metaKey && diff --git a/src/Shared/Components/Header/HelpButton.tsx b/src/Shared/Components/Header/HelpButton.tsx index 422eab6ee..96a044877 100644 --- a/src/Shared/Components/Header/HelpButton.tsx +++ b/src/Shared/Components/Header/HelpButton.tsx @@ -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' @@ -54,6 +55,7 @@ export const HelpButton = ({ serverInfo, fetchingServerInfo, onClick, hideGettin showGettingStartedCard, } = useMainContext() const { appTheme } = useTheme() + const isSecureConnection = useIsSecureConnection() // REFS const typeFormSliderButtonRef = useRef(null) @@ -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, diff --git a/src/Shared/Hooks/index.ts b/src/Shared/Hooks/index.ts index 4a7279c6c..794d0678c 100644 --- a/src/Shared/Hooks/index.ts +++ b/src/Shared/Hooks/index.ts @@ -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' diff --git a/src/Shared/Hooks/useIsSecureConnection/index.ts b/src/Shared/Hooks/useIsSecureConnection/index.ts new file mode 100644 index 000000000..2e4dd58b3 --- /dev/null +++ b/src/Shared/Hooks/useIsSecureConnection/index.ts @@ -0,0 +1 @@ +export * from './useIsSecureConnection' diff --git a/src/Shared/Hooks/useIsSecureConnection/useIsSecureConnection.tsx b/src/Shared/Hooks/useIsSecureConnection/useIsSecureConnection.tsx new file mode 100644 index 000000000..e9c5e4fd9 --- /dev/null +++ b/src/Shared/Hooks/useIsSecureConnection/useIsSecureConnection.tsx @@ -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 +}