Skip to content

Commit 8606e70

Browse files
authored
Merge pull request #985 from devtron-labs/feat/page-header-doclink
feat: Help action menu dynamic doc link support added
2 parents 556fd5c + e1482da commit 8606e70

9 files changed

Lines changed: 126 additions & 115 deletions

File tree

package-lock.json

Lines changed: 62 additions & 95 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.21.0-beta-10",
3+
"version": "1.21.1-beta-4",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/DocLink/constants.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,24 @@ export const DOCUMENTATION = {
4242
CHART_STORE: 'usage/deploy-chart',
4343
CHART_STORE_METRICS_SERVER: 'dashboard//chart-store/discover?appStoreName=metrics-server',
4444
CUSTOM_VALUES: 'usage/deploy-chart/overview-of-charts#custom-values',
45+
CONFIGURING_WEBHOOK: 'usage/applications/creating-application/workflow/ci-pipeline#configuring-webhook',
4546
DEPLOYMENT: 'usage/applications/creating-application/deployment-template/deployment',
4647
DEPLOYMENT_TEMPLATE: 'usage/applications/creating-application/deployment-template',
4748
DEVTRON_UPGRADE: 'getting-started/upgrade',
48-
CONFIGURING_WEBHOOK: 'usage/applications/creating-application/workflow/ci-pipeline#configuring-webhook',
49+
DOC_HOME_PAGE: DOCUMENTATION_HOME_PAGE,
4950
ENTERPRISE_LICENSE: 'enterprise-license',
5051
EXECUTE_CUSTOM_SCRIPT:
5152
'usage/applications/creating-application/workflow/ci-pipeline/ci-build-pre-post-plugins#execute-custom-script',
5253
EXTERNAL_LINKS: 'getting-started/global-configurations/external-links',
5354
EXTERNAL_SECRET: 'usage/applications/creating-application/secrets#external-secrets',
5455
HOME_PAGE: 'https://devtron.ai',
55-
DOC_HOME_PAGE: DOCUMENTATION_HOME_PAGE,
56-
KUBE_CONFIG: 'usage/resource-browser#running-kubectl-commands-locally',
5756
JOBS: 'usage/jobs',
58-
TAINT: 'usage/resource-browser#taint-a-node',
57+
KUBE_CONFIG: 'usage/resource-browser#running-kubectl-commands-locally',
5958
RESOURCE_BROWSER: 'usage/resource-browser',
59+
TAINT: 'usage/resource-browser#taint-a-node',
6060

6161
// Global Configurations
62+
GLOBAL_CONFIGUDATIONS: 'getting-started/global-configurations',
6263
GLOBAL_CONFIG_API_TOKEN: 'getting-started/global-configurations/authorization/api-tokens',
6364
GLOBAL_CONFIG_BUILD_INFRA: 'global-configurations/build-infra',
6465
GLOBAL_CONFIG_CHART: 'getting-started/global-configurations/chart-repo',
@@ -117,6 +118,9 @@ export const DOCUMENTATION = {
117118
GLOBAL_CONFIG_PULL_IMAGE_DIGEST: 'global-configurations/pull-image-digest',
118119
GLOBAL_CONFIG_TAGS: 'getting-started/global-configurations/tags-policy',
119120

121+
// Application Management
122+
APP_MANAGEMENT: 'docs/user-guide/app-management',
123+
120124
// Software Release Management
121125
SOFTWARE_DISTRIBUTION_HUB: 'usage/software-distribution-hub',
122126
RELEASE_TRACKS: 'usage/software-distribution-hub/release-hub#creating-release-tracks-and-versions',
@@ -126,8 +130,21 @@ export const DOCUMENTATION = {
126130
TENANTS_INSTALLATION: 'usage/software-distribution-hub/tenants',
127131

128132
// Infrastructure Management
129-
AUTOSCALER_DETECTION: 'user-guide/infra-management/infrastructure-overview#troubleshooting-autoscaler-detection',
133+
AUTOSCALER_DETECTION:
134+
'docs/user-guide/infra-management/infrastructure-overview#troubleshooting-autoscaler-detection',
135+
INFRA_MANAGEMENT: 'docs/user-guide/infra-management',
130136

131137
// Cost Visibility
132-
COST_CALCULATION: 'user-guide/finops/overview-cost-visibility#how-is-the-cost-calculated',
138+
COST_BREAKDOWN: 'docs/user-guide/finops',
139+
COST_CALCULATION: 'docs/user-guide/finops/overview-cost-visibility#how-is-the-cost-calculated',
140+
COST_VISIBILITY_OVERVIEW: 'docs/user-guide/finops/overview-cost-visibility',
141+
142+
// Security Center
143+
SECURITY_CENTER: 'docs/user-guide/security-features',
144+
145+
// AI Recommendations
146+
AI_RECOMMENDATIONS: 'docs/user-guide/ai-recommendations',
147+
148+
// Automation & Enablement
149+
AUTOMATION_AND_ENABLEMENT: 'docs/user-guide/automation',
133150
} as const

src/Shared/Components/Header/HeaderWithCreateButton/HeaderWithCreateButon.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { BreadCrumb, BreadcrumbText, useBreadcrumb } from '@Common/index'
2222
import { ActionMenu } from '@Shared/Components/ActionMenu'
2323
import { ButtonComponentType } from '@Shared/Components/Button'
2424
import Button from '@Shared/Components/Button/Button.component'
25+
import { DOCUMENTATION } from '@Shared/Components/DocLink'
2526
import { Icon } from '@Shared/Components/Icon'
2627
import { ComponentSizeType } from '@Shared/constants'
2728
import { useMainContext } from '@Shared/Providers'
@@ -93,6 +94,16 @@ export const HeaderWithCreateButton = ({ viewType }: HeaderWithCreateButtonProps
9394
)
9495
const renderBreadcrumbs = () => <BreadCrumb breadcrumbs={breadcrumbs} />
9596

97+
const getDocPath = () => {
98+
if (viewType === 'jobs') {
99+
return DOCUMENTATION.AUTOMATION_AND_ENABLEMENT
100+
}
101+
if (viewType === 'infra-apps') {
102+
return DOCUMENTATION.INFRA_MANAGEMENT
103+
}
104+
return DOCUMENTATION.APP_MANAGEMENT
105+
}
106+
96107
return (
97108
<div className="create-button-container dc__position-sticky dc__top-0 bg__primary dc__zi-4">
98109
<PageHeader
@@ -110,6 +121,7 @@ export const HeaderWithCreateButton = ({ viewType }: HeaderWithCreateButtonProps
110121
},
111122
}
112123
: {})}
124+
docPath={getDocPath()}
113125
/>
114126
</div>
115127
)

src/Shared/Components/Header/HelpButton.tsx

Lines changed: 9 additions & 2 deletions
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)
@@ -96,7 +102,7 @@ export const HelpButton = ({ serverInfo, fetchingServerInfo, onClick, hideGettin
96102
setSidePanelConfig((prev) => ({
97103
...prev,
98104
state: SidePanelTab.DOCUMENTATION,
99-
docLink: DOCUMENTATION_HOME_PAGE,
105+
docLink: `${DOCUMENTATION_HOME_PAGE}${docPath ? `/${docPath}` : ''}`,
100106
reinitialize: true,
101107
}))
102108
}
@@ -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)