Skip to content

Commit 9775886

Browse files
authored
Merge pull request #308 from devtron-labs/feat/expand-all-logs
feat: add a button to expand all log accordions in build history logs
2 parents 7dfb823 + 3800215 commit 9775886

19 files changed

+302
-88
lines changed

package-lock.json

Lines changed: 9 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: 2 additions & 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": "0.3.12",
3+
"version": "0.3.13",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -87,6 +87,7 @@
8787
"react-mde": "^11.5.0",
8888
"react-router": "^5.3.0",
8989
"react-router-dom": "^5.3.0",
90+
"react-keybind": "^0.9.4",
9091
"rxjs": "^7.8.1",
9192
"yaml": "^2.4.1"
9293
},

src/Assets/Icon/ic-collapse-all.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/Icon/ic-expand-all.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Common/Constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,6 @@ export const VULNERABILITIES_SORT_PRIORITY = {
548548
low: 4,
549549
unknown: 5,
550550
}
551+
552+
// TODO: might not work need to verify
553+
export const IS_PLATFORM_MAC_OS = window.navigator.userAgent.toUpperCase().includes('MAC')
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { KEYBOARD_KEYS_MAP, TooltipProps } from './types'
2+
3+
const ShortcutKeyComboTooltipContent = ({ text, combo }: TooltipProps['shortcutKeyCombo']) => (
4+
<div className="flexbox dc__gap-8 px-8 py-4 flex-wrap">
5+
<span className="lh-18 fs-12 fw-4 cn-0">{text}</span>
6+
{!!combo?.length && (
7+
<div className="flexbox dc__gap-4 dc__align-items-center flex-wrap">
8+
{combo.map((key) => (
9+
<span key={key} className="shortcut-keys__chip dc__capitalize lh-16 fs-11 fw-5 flex">
10+
{KEYBOARD_KEYS_MAP[key]}
11+
</span>
12+
))}
13+
</div>
14+
)}
15+
</div>
16+
)
17+
18+
export default ShortcutKeyComboTooltipContent

src/Common/Tooltip/Tooltip.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { useState, cloneElement } from 'react'
22
import TippyJS from '@tippyjs/react'
33
import { TooltipProps } from './types'
4+
import ShortcutKeyComboTooltipContent from './ShortcutKeyComboTooltipContent'
5+
import './styles.scss'
46

57
const Tooltip = ({
8+
shortcutKeyCombo,
69
alwaysShowTippyOnHover,
7-
// NOTE: if alwaysShowTippyOnHover is being passed by user don't apply truncation logic at all
8-
showOnTruncate = alwaysShowTippyOnHover === undefined,
10+
// NOTE: if alwaysShowTippyOnHover or shortcutKeyCombo are being passed by user don't apply truncation logic at all
11+
showOnTruncate = alwaysShowTippyOnHover === undefined && shortcutKeyCombo === undefined,
912
wordBreak = true,
1013
children: child,
1114
...rest
@@ -22,17 +25,24 @@ const Tooltip = ({
2225
}
2326
}
2427

25-
return (!isTextTruncated || !showOnTruncate) && !alwaysShowTippyOnHover ? (
26-
cloneElement(child, { ...child.props, onMouseEnter: handleMouseEnterEvent })
27-
) : (
28+
const showTooltipWhenShortcutKeyComboProvided =
29+
!!shortcutKeyCombo && (alwaysShowTippyOnHover === undefined || alwaysShowTippyOnHover)
30+
const showTooltipOnTruncate = showOnTruncate && isTextTruncated
31+
32+
return showTooltipOnTruncate || showTooltipWhenShortcutKeyComboProvided || alwaysShowTippyOnHover ? (
2833
<TippyJS
2934
arrow={false}
3035
placement="top"
36+
// NOTE: setting the default maxWidth to empty string so that we can override using css
37+
maxWidth=""
3138
{...rest}
32-
className={`default-tt ${wordBreak ? 'dc__word-break-all' : ''} dc__mxw-200-imp ${rest.className}`}
39+
{...(shortcutKeyCombo ? { content: <ShortcutKeyComboTooltipContent {...shortcutKeyCombo} /> } : {})}
40+
className={`${shortcutKeyCombo ? 'shortcut-keys__tippy' : 'default-tt'} ${wordBreak ? 'dc__word-break-all' : ''} dc__mxw-200 ${rest.className ?? ''}`}
3341
>
3442
{cloneElement(child, { ...child.props, onMouseEnter: handleMouseEnterEvent })}
3543
</TippyJS>
44+
) : (
45+
cloneElement(child, { ...child.props, onMouseEnter: handleMouseEnterEvent })
3646
)
3747
}
3848

src/Common/Tooltip/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { default as Tooltip } from './Tooltip'
2+
export type { SupportedKeyboardKeysType } from './types'
23
export { TOOLTIP_CONTENTS } from './constants'

src/Common/Tooltip/styles.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.tippy-box.shortcut-keys__tippy {
2+
border-radius: 4px;
3+
border: 1px solid rgba(255, 255, 255, 0.20);
4+
background: var(--N900);
5+
6+
& > .tippy-content {
7+
padding: 0;
8+
}
9+
10+
& .shortcut-keys__chip {
11+
border-radius: 4px;
12+
border: 0.5px solid rgba(255, 255, 255, 0.20);
13+
background: var(--N800);
14+
box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.20);
15+
padding: 0 2px;
16+
min-width: 16px;
17+
max-width: 250px;
18+
}
19+
}

src/Common/Tooltip/types.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
import { IS_PLATFORM_MAC_OS } from '@Common/Constants'
12
import { TippyProps } from '@tippyjs/react'
23

4+
export const KEYBOARD_KEYS_MAP = {
5+
Control: IS_PLATFORM_MAC_OS ? '⌘' : 'Ctrl',
6+
Shift: '⇧',
7+
F: 'F',
8+
E: 'E',
9+
} as const
10+
11+
export type SupportedKeyboardKeysType = keyof typeof KEYBOARD_KEYS_MAP
12+
313
type BaseTooltipProps =
414
| {
515
/**
@@ -12,6 +22,12 @@ type BaseTooltipProps =
1222
* @default false
1323
*/
1424
alwaysShowTippyOnHover?: never
25+
/**
26+
* If true, use the common styling for shortcuts
27+
* @default undefined
28+
*/
29+
shortcutKeyCombo?: never
30+
content: TippyProps['content']
1531
}
1632
| {
1733
/**
@@ -21,9 +37,36 @@ type BaseTooltipProps =
2137
showOnTruncate?: never
2238
/**
2339
* If true, wrap with tippy irrespective of other options
40+
* @default true
41+
*/
42+
alwaysShowTippyOnHover: boolean
43+
/**
44+
* If true, use the common styling for shortcuts
45+
* @default undefined
46+
*/
47+
shortcutKeyCombo?: never
48+
content: TippyProps['content']
49+
}
50+
| {
51+
/**
52+
* If true, show tippy on truncate
53+
* @default false
54+
*/
55+
showOnTruncate?: never
56+
/**
57+
* If showOnTruncate is defined this prop doesn't work
2458
* @default false
2559
*/
2660
alwaysShowTippyOnHover?: boolean
61+
/**
62+
* If true, use the common styling for shortcuts
63+
* @default undefined
64+
*/
65+
shortcutKeyCombo: {
66+
text: string
67+
combo: SupportedKeyboardKeysType[]
68+
}
69+
content?: never
2770
}
2871

2972
export type TooltipProps = BaseTooltipProps &

src/Shared/Components/Button/Button.component.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,14 @@ const Button = ({
154154
}
155155
}
156156

157+
if (Object.hasOwn(tooltipProps, 'shortcutKeyCombo') && 'shortcutKeyCombo' in tooltipProps) {
158+
return tooltipProps
159+
}
160+
157161
return {
158-
alwaysShowTippyOnHover: showTooltip && !!tooltipProps?.content,
159-
...tooltipProps,
162+
// TODO: using some typing somersaults here, clean it up later
163+
alwaysShowTippyOnHover: showTooltip && !!(tooltipProps as Required<Pick<TooltipProps, 'content'>>)?.content,
164+
...(tooltipProps as Required<Pick<TooltipProps, 'content'>>),
160165
}
161166
}
162167

src/Shared/Components/Button/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ export type ButtonProps = (
9494
/**
9595
* Props for tooltip
9696
*/
97-
tooltipProps: Omit<TooltipProps, 'alwaysShowTippyOnHover' | 'showOnTruncate'>
97+
// TODO: using some typing somersaults here, clean it up later
98+
tooltipProps:
99+
| Omit<TooltipProps, 'alwaysShowTippyOnHover' | 'showOnTruncate' | 'shortcutKeyCombo'>
100+
| (Omit<TooltipProps, 'alwaysShowTippyOnHover' | 'showOnTruncate' | 'content'> &
101+
Required<Pick<TooltipProps, 'shortcutKeyCombo'>>)
98102
}
99103
| {
100104
showTooltip?: never

0 commit comments

Comments
 (0)