Skip to content

Commit 245f125

Browse files
committed
Merge branch 'kubecon-2025' of https://github.com/devtron-labs/devtron-fe-common-lib into feat/security-overview
2 parents c8789b1 + 538ae44 commit 245f125

23 files changed

+432
-159
lines changed

package-lock.json

Lines changed: 2 additions & 2 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.20.6-beta-2",
3+
"version": "1.20.6-pre-39",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 112 additions & 0 deletions
Loading

src/Assets/IconV2/ic-pause.svg

Lines changed: 4 additions & 0 deletions
Loading

src/Common/ClipboardButton/ClipboardButton.tsx

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
import { useEffect, useRef, useState } from 'react'
1818

1919
import Tooltip from '@Common/Tooltip/Tooltip'
20+
import { Button, ButtonStyleType, ButtonVariantType } from '@Shared/Components/Button'
2021

2122
import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg'
2223
import { ReactComponent as ICCopy } from '../../Assets/Icon/ic-copy.svg'
2324
import { copyToClipboard, noop, stopPropagation } from '../Helper'
24-
import ClipboardProps from './types'
25+
import { ClipboardProps } from './types'
2526

2627
/**
2728
* @param content - Content to be copied
@@ -40,6 +41,8 @@ export const ClipboardButton = ({
4041
rootClassName = '',
4142
iconSize = 16,
4243
handleSuccess,
44+
variant = 'default',
45+
size,
4346
}: ClipboardProps) => {
4447
const [copied, setCopied] = useState<boolean>(false)
4548
const setCopiedFalseTimeoutRef = useRef<ReturnType<typeof setTimeout>>(-1)
@@ -96,18 +99,44 @@ export const ClipboardButton = ({
9699

97100
const iconClassName = `icon-dim-${iconSize} dc__no-shrink`
98101

102+
const ariaLabel = `Copy ${content}`
103+
104+
const renderIcon = () => (
105+
<div className="flex">
106+
{copied ? <Check className={iconClassName} /> : <ICCopy className={iconClassName} />}
107+
</div>
108+
)
109+
110+
const tooltipContent = copied ? copiedTippyText : initialTippyText
111+
112+
if (variant === 'button--secondary') {
113+
return (
114+
<Button
115+
variant={ButtonVariantType.secondary}
116+
dataTestId="clippy-button"
117+
icon={renderIcon()}
118+
size={size}
119+
onClick={handleCopyContent}
120+
tooltipProps={{
121+
content: tooltipContent,
122+
}}
123+
showTooltip
124+
ariaLabel={ariaLabel}
125+
style={ButtonStyleType.neutral}
126+
/>
127+
)
128+
}
129+
99130
return (
100-
<Tooltip content={copied ? copiedTippyText : initialTippyText} alwaysShowTippyOnHover>
131+
<Tooltip content={tooltipContent} alwaysShowTippyOnHover>
101132
{/* TODO: semantically buttons should not be nested; fix later */}
102133
<button
103134
type="button"
104135
className={`dc__outline-none-imp p-0 flex dc__transparent--unstyled dc__no-border ${rootClassName}`}
105-
aria-label={`Copy ${content}`}
136+
aria-label={ariaLabel}
106137
onClick={handleCopyContent}
107138
>
108-
<div className="flex">
109-
{copied ? <Check className={iconClassName} /> : <ICCopy className={iconClassName} />}
110-
</div>
139+
{renderIcon()}
111140
</button>
112141
</Tooltip>
113142
)

src/Common/ClipboardButton/types.ts

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

17-
export default interface ClipboardProps {
17+
import { ComponentSizeType } from '@Shared/constants'
18+
19+
export type ClipboardProps = (
20+
| {
21+
/**
22+
* @default 'default'
23+
*/
24+
variant?: 'default'
25+
size?: never
26+
}
27+
| {
28+
variant: 'button--secondary'
29+
size: ComponentSizeType
30+
}
31+
) & {
1832
content: string
1933
/**
2034
* tippy text before copying

src/Common/Constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export const URLS = {
140140
DATA_PROTECTION: DATA_PROTECTION_ROOT,
141141
DATA_PROTECTION_OVERVIEW: `${DATA_PROTECTION_ROOT}/overview`,
142142
DATA_PROTECTION_BACKUP_AND_SCHEDULE,
143-
DATA_PROTECTION_BACKUP_AND_SCHEDULE_DETAIL: `${DATA_PROTECTION_BACKUP_AND_SCHEDULE}/:name`,
143+
DATA_PROTECTION_BACKUP_AND_SCHEDULE_DETAIL: `${DATA_PROTECTION_BACKUP_AND_SCHEDULE}/detail/:id`,
144144
DATA_PROTECTION_RESTORES: `${DATA_PROTECTION_ROOT}/restores`,
145145
DATA_PROTECTION_RESTORES_DETAIL: `${DATA_PROTECTION_ROOT}/restores/:restoreId`,
146146
DATA_PROTECTION_BACKUP_LOCATIONS: `${DATA_PROTECTION_ROOT}/backup-locations/:type(${Object.values(BackupLocationsTypes).join('|')})`,
@@ -181,6 +181,7 @@ export const ROUTES = {
181181
PATCH: 'patch',
182182
ENVIRONMENT_LIST_MIN: 'env/autocomplete',
183183
CLUSTER: 'cluster',
184+
CLUSTER_MIN: 'cluster/min',
184185
API_RESOURCE: 'k8s/api-resources',
185186
GVK: 'gvk',
186187
NAMESPACE: 'env/namespace',

0 commit comments

Comments
 (0)