Skip to content

Commit 288808b

Browse files
committed
Merge branch 'fix/expand-all-logs' of github.com:devtron-labs/devtron-fe-common-lib into feat/fullscreen-terminal
2 parents a5ea658 + 5ca7c73 commit 288808b

25 files changed

+489
-172
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.5-beta-4",
3+
"version": "0.3.6-beta-6",
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/AppStatus/AppStatus.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import Tippy from '@tippyjs/react'
18+
import { ReactComponent as ICErrorCross } from '@Icons/ic-error-cross.svg'
1819
import { ReactComponent as InfoIcon } from '../../Assets/Icon/ic-info-outlined.svg'
1920
import { StatusConstants, YET_TO_RUN } from './constants'
2021
import { AppStatusType } from './types'
@@ -52,7 +53,11 @@ export default function AppStatus({
5253

5354
const renderIcon = () => {
5455
if (iconClass) {
55-
return <span className={`dc__app-summary__icon icon-dim-16 ${iconClass} ${iconClass}--node`} />
56+
return iconClass === 'failed' || iconClass === 'error' ? (
57+
<ICErrorCross className="icon-dim-16 dc__no-shrink ic-error-cross-red" />
58+
) : (
59+
<span className={`dc__app-summary__icon icon-dim-16 ${iconClass} ${iconClass}--node`} />
60+
)
5661
}
5762
if (isVirtualEnv) {
5863
return (
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
<div className="flexbox dc__gap-4 dc__align-items-center flex-wrap">
7+
{combo.map((key) => (
8+
<span key={key} className="shortcut-keys__chip dc__capitalize lh-16 fs-11 fw-5 flex">
9+
{KEYBOARD_KEYS_MAP[key]}
10+
</span>
11+
))}
12+
</div>
13+
</div>
14+
)
15+
16+
export default ShortcutKeyComboTooltipContent

src/Common/Tooltip/Tooltip.tsx

Lines changed: 9 additions & 3 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,
710
// NOTE: if alwaysShowTippyOnHover is being passed by user don't apply truncation logic at all
8-
showOnTruncate = alwaysShowTippyOnHover === undefined,
11+
showOnTruncate = alwaysShowTippyOnHover === undefined && shortcutKeyCombo === undefined,
912
wordBreak = true,
1013
children: child,
1114
...rest
@@ -22,14 +25,17 @@ const Tooltip = ({
2225
}
2326
}
2427

25-
return (!isTextTruncated || !showOnTruncate) && !alwaysShowTippyOnHover ? (
28+
return (!showOnTruncate || !isTextTruncated) && !alwaysShowTippyOnHover && !shortcutKeyCombo ? (
2629
cloneElement(child, { ...child.props, onMouseEnter: handleMouseEnterEvent })
2730
) : (
2831
<TippyJS
2932
arrow={false}
3033
placement="top"
34+
// NOTE: setting the default maxWidth to empty string so that we can override using css
35+
maxWidth=""
3136
{...rest}
32-
className={`default-tt ${wordBreak ? 'dc__word-break-all' : ''} dc__mxw-200-imp ${rest.className}`}
37+
{...(shortcutKeyCombo ? { content: <ShortcutKeyComboTooltipContent {...shortcutKeyCombo} /> } : {})}
38+
className={`${shortcutKeyCombo ? 'shortcut-keys__tippy' : 'default-tt'} ${wordBreak ? 'dc__word-break-all' : ''} dc__mxw-200 ${rest.className ?? ''}`}
3339
>
3440
{cloneElement(child, { ...child.props, onMouseEnter: handleMouseEnterEvent })}
3541
</TippyJS>

src/Common/Tooltip/index.ts

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

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: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import { TippyProps } from '@tippyjs/react'
22

3+
const isMacOS = navigator.userAgent.toUpperCase().includes('MAC')
4+
5+
export const KEYBOARD_KEYS_MAP = {
6+
Control: isMacOS ? '⌘' : 'Ctrl',
7+
Shift: '⇧',
8+
F: 'F',
9+
E: 'E',
10+
} as const
11+
12+
export type SupportedKeyboardKeysType = keyof typeof KEYBOARD_KEYS_MAP
13+
314
type BaseTooltipProps =
415
| {
516
/**
@@ -12,6 +23,11 @@ type BaseTooltipProps =
1223
* @default false
1324
*/
1425
alwaysShowTippyOnHover?: never
26+
/**
27+
* If true, use the common styling for shortcuts
28+
* @default false
29+
*/
30+
shortcutKeyCombo?: never
1531
}
1632
| {
1733
/**
@@ -21,9 +37,34 @@ type BaseTooltipProps =
2137
showOnTruncate?: never
2238
/**
2339
* If true, wrap with tippy irrespective of other options
24-
* @default false
40+
* @default true
2541
*/
2642
alwaysShowTippyOnHover?: boolean
43+
/**
44+
* If true, use the common styling for shortcuts
45+
* @default false
46+
*/
47+
shortcutKeyCombo?: never
48+
}
49+
| {
50+
/**
51+
* If true, show tippy on truncate
52+
* @default false
53+
*/
54+
showOnTruncate?: never
55+
/**
56+
* If showOnTruncate is defined this prop doesn't work
57+
* @default false
58+
*/
59+
alwaysShowTippyOnHover?: never
60+
/**
61+
* If true, use the common styling for shortcuts
62+
* @default true
63+
*/
64+
shortcutKeyCombo?: {
65+
text: string
66+
combo: SupportedKeyboardKeysType[]
67+
}
2768
}
2869

2970
export type TooltipProps = BaseTooltipProps &

0 commit comments

Comments
 (0)