Skip to content

Commit efc2597

Browse files
committed
chore: moved doc link to shared
1 parent d3af342 commit efc2597

File tree

18 files changed

+121
-98
lines changed

18 files changed

+121
-98
lines changed

src/Common/DocLink/types.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Common/DocLink/utils.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Common/TippyCustomized.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import 'tippy.js/animations/shift-toward-subtle.css'
2323
import 'tippy.js/animations/shift-toward.css'
2424
import { TippyCustomizedProps, TippyTheme } from './Types'
2525
import { not, stopPropagation } from './Helper'
26-
import { DocLink, DOCUMENTATION } from './DocLink'
26+
import { DocLink } from '../Shared/DocLink'
2727

2828
// This component will handle some of the new tippy designs and interactions
2929
// So this can be updated to support further for new features or interactions
30-
export const TippyCustomized = (props: TippyCustomizedProps) => {
30+
export const TippyCustomized = <T extends boolean = false>(props: TippyCustomizedProps<T>) => {
3131
const tippyRef = useRef(null)
3232
const [showHeadingInfo, setShowHeadingInfo] = useState(false)
3333
const isWhiteTheme = props.theme === TippyTheme.white
@@ -160,13 +160,13 @@ export const TippyCustomized = (props: TippyCustomizedProps) => {
160160
{documentationLink && (
161161
<div className="px-12 pb-12 flexbox">
162162
<DocLink
163-
docLinkKey={documentationLink}
164163
text={documentationLinkText}
165164
dataTestId="learn-more-about-tippy-link"
166165
showExternalIcon
167166
onClick={closeTippy}
168167
isEnterprise={isEnterprise}
169168
isExternalLink={isExternalLink}
169+
docLinkKey={documentationLink}
170170
/>
171171
</div>
172172
)}

src/Common/Types.ts

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -120,56 +120,62 @@ export interface CheckboxProps {
120120
children?: ReactNode
121121
}
122122

123-
export interface TippyCustomizedProps extends Pick<TippyProps, 'appendTo'> {
124-
theme: TippyTheme
125-
visible?: boolean
126-
heading?: ReactNode | string
127-
headingInfo?: ReactNode | string
128-
noHeadingBorder?: boolean
129-
infoTextHeading?: string
130-
hideHeading?: boolean
131-
placement?: TippyProps['placement']
132-
className?: string
133-
Icon?: React.FunctionComponent<React.SVGProps<SVGSVGElement>>
134-
iconPath?: string
135-
iconClass?: string
136-
iconSize?: number // E.g. 16, 20, etc.. Currently, there are around 12 sizes supported. Check `icons.css` or `base.scss` for supported sizes or add new size (class names starts with `icon-dim-`).
137-
onImageLoadError?: (e) => void
138-
onClose?: () => void
139-
infoText?: React.ReactNode
140-
showCloseButton?: boolean
141-
arrow?: boolean
142-
interactive?: boolean
143-
showOnCreate?: boolean
144-
trigger?: string
145-
animation?: string
146-
duration?: number
147-
additionalContent?: ReactNode
148-
documentationLink?: keyof typeof DOCUMENTATION
149-
documentationLinkText?: string
150-
children: React.ReactElement<any>
151-
disableClose?: boolean
123+
export type TippyWithBaseDocLinkTypes<T extends boolean> = {
124+
isExternalLink?: T
152125
isEnterprise?: boolean
153-
isExternalLink?: boolean
154-
}
155-
156-
export interface InfoIconTippyProps
157-
extends Pick<
158-
TippyCustomizedProps,
159-
| 'heading'
160-
| 'infoText'
161-
| 'iconClass'
162-
| 'documentationLinkText'
163-
| 'additionalContent'
164-
| 'placement'
165-
| 'Icon'
166-
| 'headingInfo'
167-
| 'documentationLink'
168-
| 'isEnterprise'
169-
| 'isExternalLink'
126+
documentationLink: T extends true ? string : keyof typeof DOCUMENTATION
127+
}
128+
129+
export type TippyCustomizedProps<T extends boolean> = Pick<TippyProps, 'appendTo'> &
130+
TippyWithBaseDocLinkTypes<T> & {
131+
theme: TippyTheme
132+
visible?: boolean
133+
heading?: ReactNode | string
134+
headingInfo?: ReactNode | string
135+
noHeadingBorder?: boolean
136+
infoTextHeading?: string
137+
hideHeading?: boolean
138+
placement?: TippyProps['placement']
139+
className?: string
140+
Icon?: React.FunctionComponent<React.SVGProps<SVGSVGElement>>
141+
iconPath?: string
142+
iconClass?: string
143+
iconSize?: number // E.g. 16, 20, etc.. Currently, there are around 12 sizes supported. Check `icons.css` or `base.scss` for supported sizes or add new size (class names starts with `icon-dim-`).
144+
onImageLoadError?: (e) => void
145+
onClose?: () => void
146+
infoText?: React.ReactNode
147+
showCloseButton?: boolean
148+
arrow?: boolean
149+
interactive?: boolean
150+
showOnCreate?: boolean
151+
trigger?: string
152+
animation?: string
153+
duration?: number
154+
additionalContent?: ReactNode
155+
documentationLinkText?: string
156+
children: React.ReactElement<any>
157+
disableClose?: boolean
158+
}
159+
160+
export interface InfoIconTippyProps<T extends boolean = false>
161+
extends Partial<
162+
Pick<
163+
TippyCustomizedProps<T>,
164+
| 'heading'
165+
| 'infoText'
166+
| 'iconClass'
167+
| 'documentationLinkText'
168+
| 'additionalContent'
169+
| 'placement'
170+
| 'Icon'
171+
| 'headingInfo'
172+
| 'documentationLink'
173+
| 'isEnterprise'
174+
| 'isExternalLink'
175+
>
170176
> {
171177
dataTestid?: string
172-
children?: TippyCustomizedProps['children']
178+
children?: TippyCustomizedProps<T>['children']
173179
iconClassName?: string
174180
buttonPadding?: string
175181
}

src/Common/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
export * from '../Shared/DocLink'
1718
export * from './AddCDButton'
1819
export * from './API'
1920
export { BreadCrumb, useBreadcrumb } from './BreadCrumb/BreadCrumb'
@@ -30,7 +31,6 @@ export * from './DeleteCINodeButton'
3031
export { default as DevtronCopyright } from './DevtronCopyright'
3132
export * from './DevtronProgressing'
3233
export * from './Dialogs'
33-
export * from './DocLink'
3434
export * from './DraggableWrapper'
3535
export * from './Drawer'
3636
export * from './EmptyState'

src/Shared/Components/CICDHistory/Artifacts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import folder from '@Icons/ic-folder.svg'
2424
import { ReactComponent as ICHelpOutline } from '@Icons/ic-help.svg'
2525
import { ReactComponent as MechanicalOperation } from '@Icons/ic-mechanical-operation.svg'
2626
import noartifact from '@Images/no-artifact.webp'
27-
import { DocLink } from '@Common/DocLink'
27+
import { DocLink } from '@Shared/DocLink'
2828
import { getIsApprovalPolicyConfigured } from '@Shared/Helpers'
2929
import { useDownload } from '@Shared/Hooks'
3030

src/Shared/Components/CICDHistory/LogsRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import DOMPurify from 'dompurify'
2222
import { ReactComponent as ICArrow } from '@Icons/ic-caret-down.svg'
2323
import { ReactComponent as ICCollapseAll } from '@Icons/ic-collapse-all.svg'
2424
import { ReactComponent as ICExpandAll } from '@Icons/ic-expand-all.svg'
25-
import { DocLink } from '@Common/DocLink'
2625
import { ANSI_UP_REGEX, ComponentSizeType } from '@Shared/constants'
26+
import { DocLink } from '@Shared/DocLink'
2727
import { escapeRegExp, sanitizeTargetPlatforms } from '@Shared/Helpers'
2828
import { AppThemeType, getComponentSpecificThemeClass } from '@Shared/Providers'
2929

src/Shared/Components/FeatureDescription/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
import React, { ReactNode } from 'react'
1818

19-
import { DocLinkProps } from '@Common/DocLink/types'
19+
import { DocLinkProps } from '@Shared/DocLink/types'
2020

2121
import { ImageType } from '../../../Common'
2222
import { Breadcrumb } from '../../../Common/BreadCrumb/Types'
2323

24-
interface BaseFeatureDescriptionModalProps {
24+
interface BaseFeatureDescriptionModalProps<T extends boolean = false> {
2525
renderDescriptionContent?: () => ReactNode
26-
docLink?: DocLinkProps['docLinkKey']
26+
docLink?: DocLinkProps<T>['docLinkKey']
2727
imageVariant?: ImageType
2828
SVGImage?: React.FunctionComponent<React.SVGProps<SVGSVGElement>>
2929
imageStyles?: React.CSSProperties

src/Shared/Components/Header/PageHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ const PageHeader = ({
156156
arrow
157157
onClose={handleCloseSwitchThemeLocationTippyChange}
158158
isEnterprise={isEnterprise}
159+
documentationLink={tippyRedirectLink}
159160
>
160161
<button
161162
type="button"

src/Shared/Components/Header/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export enum InstallationType {
2525
ENTERPRISE = 'enterprise',
2626
}
2727

28-
export interface PageHeaderType {
28+
export interface PageHeaderType<T extends boolean = false> {
2929
headerName?: string
3030
showTabs?: boolean
3131
additionalHeaderInfo?: () => JSX.Element
@@ -36,7 +36,7 @@ export interface PageHeaderType {
3636
showCloseButton?: boolean
3737
onClose?: () => void
3838
markAsBeta?: boolean
39-
tippyProps?: Pick<TippyCustomizedProps, 'additionalContent'> & {
39+
tippyProps?: Pick<TippyCustomizedProps<T>, 'additionalContent'> & {
4040
isTippyCustomized?: boolean
4141
tippyRedirectLink?: keyof typeof DOCUMENTATION
4242
TippyIcon?: React.FunctionComponent<any>

0 commit comments

Comments
 (0)