Skip to content

Commit 1c6f9d0

Browse files
committed
fix: review comments
1 parent a5a7ab7 commit 1c6f9d0

File tree

7 files changed

+32
-18
lines changed

7 files changed

+32
-18
lines changed

src/Common/Tooltip/Tooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import './styles.scss'
77
const Tooltip = ({
88
shortcutKeyCombo,
99
alwaysShowTippyOnHover,
10-
// NOTE: if alwaysShowTippyOnHover is being passed by user don't apply truncation logic at all
10+
// NOTE: if alwaysShowTippyOnHover or shortcutKeyCombo are being passed by user don't apply truncation logic at all
1111
showOnTruncate = alwaysShowTippyOnHover === undefined && shortcutKeyCombo === undefined,
1212
wordBreak = true,
1313
children: child,

src/Common/Tooltip/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type BaseTooltipProps =
2727
* @default false
2828
*/
2929
shortcutKeyCombo?: never
30+
content: TippyProps['content']
3031
}
3132
| {
3233
/**
@@ -44,6 +45,7 @@ type BaseTooltipProps =
4445
* @default false
4546
*/
4647
shortcutKeyCombo?: never
48+
content: TippyProps['content']
4749
}
4850
| {
4951
/**
@@ -55,11 +57,12 @@ type BaseTooltipProps =
5557
* If showOnTruncate is defined this prop doesn't work
5658
* @default false
5759
*/
58-
alwaysShowTippyOnHover?: never
60+
alwaysShowTippyOnHover?: boolean
5961
/**
6062
* If true, use the common styling for shortcuts
6163
* @default true
6264
*/
65+
content?: never
6366
shortcutKeyCombo?: {
6467
text: string
6568
combo: SupportedKeyboardKeysType[]

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

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

157-
if (!tooltipProps.shortcutKeyCombo) {
158-
return {
159-
alwaysShowTippyOnHover: showTooltip && !!tooltipProps?.content,
160-
...(tooltipProps as Omit<TooltipProps, 'shortcutKeyCombo' | 'showOnTruncate'>),
161-
}
157+
if (Object.hasOwn(tooltipProps, 'shortcutKeyCombo') && 'shortcutKeyCombo' in tooltipProps) {
158+
return tooltipProps
162159
}
163160

164-
return tooltipProps
161+
return {
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'>>),
165+
}
165166
}
166167

167168
return (

src/Shared/Components/Button/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ 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'>
98101
}
99102
| {
100103
showTooltip?: never

src/Shared/Components/CICDHistory/History.components.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import Tippy from '@tippyjs/react'
1817
import { useCallback, useEffect } from 'react'
1918
import { useLocation } from 'react-router-dom'
2019
import { withShortcut, IWithShortcut } from 'react-keybind'
@@ -102,7 +101,7 @@ export const LogResizeButton = withShortcut(
102101

103102
export const Scroller = ({ scrollToTop, scrollToBottom, style }: ScrollerType): JSX.Element => (
104103
<div style={style} className="dc__element-scroller flex column top br-4">
105-
<Tippy className="default-tt" arrow={false} content="Scroll to Top" placement="left">
104+
<Tooltip content="Scroll to Top" placement="left">
106105
<button
107106
className="flex"
108107
disabled={!scrollToTop}
@@ -112,8 +111,8 @@ export const Scroller = ({ scrollToTop, scrollToBottom, style }: ScrollerType):
112111
>
113112
<DropDownIcon className="rotate" style={{ ['--rotateBy' as any]: '180deg' }} />
114113
</button>
115-
</Tippy>
116-
<Tippy className="default-tt" arrow={false} content="Scroll to Bottom" placement="left">
114+
</Tooltip>
115+
<Tooltip content="Scroll to Bottom" placement="left">
117116
<button
118117
className="flex"
119118
disabled={!scrollToBottom}
@@ -123,7 +122,7 @@ export const Scroller = ({ scrollToTop, scrollToBottom, style }: ScrollerType):
123122
>
124123
<DropDownIcon className="rotate" />
125124
</button>
126-
</Tippy>
125+
</Tooltip>
127126
</div>
128127
)
129128

src/Shared/Components/CICDHistory/LogsRenderer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ const LogsRenderer = ({
191191
const { searchKey, handleSearch } = useUrlFilters()
192192

193193
const areAllStagesExpanded = useMemo(() => stageList.every((item) => item.isOpen), [stageList])
194+
const shortcutTippyText = areAllStagesExpanded ? 'Collapse all stages' : 'Expand all stages'
194195

195196
const areStagesAvailable =
196197
(window._env_.FEATURE_STEP_WISE_LOGS_ENABLE && streamDataList[0]?.startsWith(LOGS_STAGE_IDENTIFIER)) || false
@@ -454,18 +455,17 @@ const LogsRenderer = ({
454455
/>
455456
<Tooltip
456457
shortcutKeyCombo={{
457-
text: areAllStagesExpanded ? 'Collapse all stages' : 'Expand all stages',
458+
text: shortcutTippyText,
458459
combo: ['E'] as const,
459460
}}
460461
className="dc__mxw-500"
461462
placement="left"
462463
>
463464
<button
464465
type="button"
465-
className="dc__unset-button-styles px-10 flex dc__bg-n0--opacity-0_2 pointer"
466+
className="dc__unset-button-styles px-10 flex dc__bg-n0--opacity-0_2"
466467
onClick={handleToggleOpenAllStages}
467-
aria-label="Expand all stages"
468-
data-toggle-state={areAllStagesExpanded}
468+
aria-label={shortcutTippyText}
469469
>
470470
{areAllStagesExpanded ? (
471471
<ICCollapseAll className="icon-dim-16 dc__no-shrink dc__transition--transform scn-0" />

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ export enum FetchIdDataStatus {
4747
}
4848

4949
export interface LogResizeButtonType {
50+
/**
51+
* If given, that shortcut combo will be bound to the button
52+
* @default null
53+
*/
5054
shortcutCombo?: SupportedKeyboardKeysType[]
55+
/**
56+
* If true, only show the button when location.pathname contains '/logs'
57+
* @default true
58+
*/
5159
showOnlyWhenPathIncludesLogs?: boolean
5260
fullScreenView: boolean
5361
setFullScreenView: React.Dispatch<React.SetStateAction<boolean>>

0 commit comments

Comments
 (0)