Skip to content

Commit 6f0fceb

Browse files
committed
feat: Help action menu dynamic doc link support added
1 parent 53c0552 commit 6f0fceb

5 files changed

Lines changed: 27 additions & 12 deletions

File tree

src/Shared/Components/Header/HelpButton.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ const CheckForUpdates = ({
5555
</div>
5656
)
5757

58-
export const HelpButton = ({ serverInfo, fetchingServerInfo, onClick, hideGettingStartedCard }: HelpButtonProps) => {
58+
export const HelpButton = ({
59+
serverInfo,
60+
fetchingServerInfo,
61+
onClick,
62+
hideGettingStartedCard,
63+
docPath,
64+
}: HelpButtonProps) => {
5965
// STATES
6066
const [isActionMenuOpen, setIsActionMenuOpen] = useState(false)
6167
const [expiryDate, setExpiryDate] = useState(0)
@@ -150,6 +156,7 @@ export const HelpButton = ({ serverInfo, fetchingServerInfo, onClick, hideGettin
150156
options={getHelpActionMenuOptions({
151157
isTrialOrFreemium: (licenseData?.isTrial || licenseData?.isFreemium) ?? false,
152158
isEnterprise,
159+
docPath,
153160
})}
154161
onClick={handleActionMenuClick}
155162
onOpen={setIsActionMenuOpen}

src/Shared/Components/Header/PageHeader.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const PageHeader = ({
5050
onClose,
5151
tippyProps,
5252
closeIcon,
53+
docPath,
5354
}: PageHeaderType) => {
5455
const { setLoginCount, setShowGettingStartedCard, setSidePanelConfig, sidePanelConfig, tempAppWindowConfig } =
5556
useMainContext()
@@ -158,6 +159,7 @@ const PageHeader = ({
158159
fetchingServerInfo={currentServerInfo.fetchingServerInfo}
159160
onClick={handleHelpButtonClick}
160161
hideGettingStartedCard={hideGettingStartedCard}
162+
docPath={docPath}
161163
/>
162164
{!window._env_.K8S_CLIENT && (
163165
<TippyCustomized

src/Shared/Components/Header/constants.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
import { DEVTRON_GPT_LINK, DISCORD_LINK, DOCUMENTATION_HOME_PAGE, URLS } from '@Common/Constants'
1818
import { CONTACT_SUPPORT_LINK, OPEN_NEW_TICKET, RAISE_ISSUE, VIEW_ALL_TICKETS } from '@Shared/constants'
1919

20-
import { HelpButtonActionMenuProps, HelpMenuItems } from './types'
20+
import { HelpButtonActionMenuProps, HelpMenuItems, PageHeaderType } from './types'
2121

22-
export const COMMON_HELP_ACTION_MENU_ITEMS: HelpButtonActionMenuProps['options'][number]['items'] = [
22+
export const getCommonHelpActionMenuItems = ({
23+
docPath,
24+
}: Pick<PageHeaderType, 'docPath'>): HelpButtonActionMenuProps['options'][number]['items'] => [
2325
...((!window._env_?.K8S_CLIENT
2426
? [
2527
{
@@ -36,7 +38,7 @@ export const COMMON_HELP_ACTION_MENU_ITEMS: HelpButtonActionMenuProps['options']
3638
label: 'View documentation',
3739
startIcon: { name: 'ic-book-open' },
3840
componentType: 'anchor',
39-
href: DOCUMENTATION_HOME_PAGE,
41+
href: `${DOCUMENTATION_HOME_PAGE}${docPath ? `/${docPath}` : ''}`,
4042
},
4143
{
4244
id: HelpMenuItems.DEVTRON_GPT,

src/Shared/Components/Header/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface PageHeaderType {
3939
}
4040
onClose?: () => void
4141
closeIcon?: JSX.Element
42+
docPath?: string
4243
}
4344

4445
export interface ServerInfo {
@@ -52,7 +53,7 @@ export interface ServerInfoResponse extends ResponseType {
5253
result?: ServerInfo
5354
}
5455

55-
export interface HelpButtonProps {
56+
export interface HelpButtonProps extends Pick<PageHeaderType, 'docPath'> {
5657
serverInfo: ServerInfo
5758
fetchingServerInfo: boolean
5859
onClick: () => void
@@ -79,3 +80,8 @@ export interface ProfileMenuProps {
7980
user: string
8081
onClick?: () => void
8182
}
83+
84+
export interface HelpActionOptionTypes extends Pick<PageHeaderType, 'docPath'> {
85+
isEnterprise: boolean
86+
isTrialOrFreemium: boolean
87+
}

src/Shared/Components/Header/utils.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
import { LOGIN_COUNT } from '@Common/Constants'
1818

1919
import {
20-
COMMON_HELP_ACTION_MENU_ITEMS,
2120
ENTERPRISE_HELP_ACTION_MENU_ITEMS,
2221
ENTERPRISE_TRIAL_HELP_ACTION_MENU_ITEMS,
22+
getCommonHelpActionMenuItems,
2323
OSS_HELP_ACTION_MENU_ITEMS,
2424
} from './constants'
2525
import { updatePostHogEvent } from './service'
26-
import { HelpButtonActionMenuProps } from './types'
26+
import { HelpActionOptionTypes, HelpButtonActionMenuProps } from './types'
2727

2828
const millisecondsInDay = 86400000
2929
export const getDateInMilliseconds = (days) => 1 + new Date().valueOf() + (days ?? 0) * millisecondsInDay
@@ -45,12 +45,10 @@ export const setActionWithExpiry = (key: string, days: number): void => {
4545
export const getHelpActionMenuOptions = ({
4646
isEnterprise,
4747
isTrialOrFreemium,
48-
}: {
49-
isEnterprise: boolean
50-
isTrialOrFreemium: boolean
51-
}): HelpButtonActionMenuProps['options'] => [
48+
docPath,
49+
}: HelpActionOptionTypes): HelpButtonActionMenuProps['options'] => [
5250
{
53-
items: COMMON_HELP_ACTION_MENU_ITEMS,
51+
items: getCommonHelpActionMenuItems({ docPath }),
5452
},
5553
...(isEnterprise
5654
? [

0 commit comments

Comments
 (0)