Skip to content

Commit df5922a

Browse files
committed
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-common-lib into fix/bulk-deploy-trigger
2 parents d9d92db + 9b6b2ca commit df5922a

File tree

17 files changed

+227
-37
lines changed

17 files changed

+227
-37
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.19.0-beta-2",
3+
"version": "1.19.0-pre-4",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Assets/IconV2/ic-diff-added.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/IconV2/ic-diff-deleted.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/IconV2/ic-diff-updated.svg

Lines changed: 4 additions & 0 deletions
Loading

src/Common/Helper.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,3 +1133,5 @@ export const findRight = <T,>(arr: T[], predicate: (item: T) => boolean): T | nu
11331133

11341134
return null
11351135
}
1136+
1137+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { Tooltip } from '@Common/Tooltip'
18+
19+
import { InteractiveCellTextProps } from './types'
20+
/**
21+
* A reusable component for rendering text within a tooltip. The text can be interactive (clickable) or static.
22+
*
23+
* @param {Object} props - The props for the component.
24+
* @param {string} props.text - The text to display inside the component. Defaults to `'-'` if not provided.
25+
* @param {function} [props.onClickHandler] - Optional click handler function. If provided, the text will be rendered as a button.
26+
* @param {string} [props.dataTestId] - Optional test ID for the component, useful for testing purposes.
27+
* @param {string} [props.rootClassName] - Additional CSS class names to apply to the root element.
28+
* @param {boolean} [props.interactive=false] - Whether the tooltip content is interactive.
29+
* @param {number} [props.fontSize=13] - Font size for the text. Defaults to `13`.
30+
* @param {React.ReactNode} [props.tippyContent=null] - Custom content for the tooltip. If not provided, `text` will be used.
31+
* @returns {JSX.Element} The rendered `InteractiveCellText` component.
32+
*
33+
* @example
34+
* // Example usage:
35+
* <InteractiveCellText
36+
* text="Click me"
37+
* onClickHandler={() => alert('Clicked!')}
38+
* dataTestId="interactive-cell"
39+
* rootClassName="custom-class"
40+
* interactive={true}
41+
* fontSize={14}
42+
* tippyContent="Tooltip content"
43+
* />
44+
*/
45+
46+
export const InteractiveCellText = ({
47+
text,
48+
onClickHandler,
49+
dataTestId,
50+
rootClassName,
51+
interactive = false,
52+
fontSize = 13,
53+
tippyContent = null,
54+
}: InteractiveCellTextProps) => (
55+
<Tooltip
56+
content={tippyContent || text}
57+
placement="bottom"
58+
className="mxh-210 dc__overflow-auto dc__word-break"
59+
interactive={interactive}
60+
>
61+
{typeof onClickHandler === 'function' ? (
62+
<button
63+
type="button"
64+
onClick={onClickHandler}
65+
className={`flex left dc__unset-button-styles lh-20 dc__truncate cb-5 dc__no-decor cursor ${rootClassName} fs-${fontSize}`}
66+
data-testid={dataTestId}
67+
>
68+
{text || '-'}
69+
</button>
70+
) : (
71+
<p
72+
className={`lh-20 dc__truncate m-0 dc__align-item-left ${rootClassName} fs-${fontSize}`}
73+
data-testid={dataTestId}
74+
>
75+
{text || '-'}
76+
</p>
77+
)}
78+
</Tooltip>
79+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './InteractiveCellText'
2+
export * from './types'
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { TippyCustomizedProps } from '@Common/Types'
18+
19+
export interface InteractiveCellTextProps {
20+
text: string
21+
onClickHandler?: () => void
22+
dataTestId?: string
23+
rootClassName?: string
24+
interactive?: boolean
25+
fontSize?: number
26+
tippyContent?: TippyCustomizedProps<false>['additionalContent']
27+
}

src/Common/Types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,4 +1102,4 @@ export interface ClusterEnvironmentCategoryDTO {
11021102
description?: string
11031103
}
11041104

1105-
export interface ClusterEnvironmentCategoryType extends ClusterEnvironmentCategoryDTO {}
1105+
export interface ClusterEnvironmentCategoryType extends ClusterEnvironmentCategoryDTO {}

0 commit comments

Comments
 (0)