Skip to content

Commit 4b2e657

Browse files
committed
Merge branch 'develop' into feat/patch-dt-cm-cs
2 parents 8ffa2d1 + f87dd5b commit 4b2e657

File tree

10 files changed

+89
-41
lines changed

10 files changed

+89
-41
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.2.8-beta-1",
3+
"version": "1.2.12",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Hooks/UseRegisterShortcut/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const KEYBOARD_KEYS_MAP = {
2626
R: 'R',
2727
K: 'K',
2828
Escape: 'Escape',
29-
Enter: 'Enter',
29+
Enter: '',
3030
} as const
3131

3232
export type SupportedKeyboardKeysType = keyof typeof KEYBOARD_KEYS_MAP

src/Shared/Components/ImageCardAccordion/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface ImageCardAccordionProps extends MaterialSecurityInfoType {
2929
isScanEnabled: boolean
3030
SecurityModalSidebar: React.FC<SidebarPropsType>
3131
getSecurityScan: (
32-
props: Pick<AppDetailsPayload, 'appId' | 'envId' | 'artifactId'>,
32+
props: Pick<AppDetailsPayload, 'appId' | 'artifactId'>,
3333
) => Promise<ResponseType<ApiResponseResultType>>
3434
}
3535

src/Shared/Components/Security/SecurityModal/SecurityModal.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import {
1212
stopPropagation,
1313
VisibleModal2,
1414
} from '@Common/index'
15-
import { ReactComponent as ICClose } from '@Icons/ic-close.svg'
15+
import { ReactComponent as ICClose } from '@Icons/ic-cross.svg'
1616
import { ReactComponent as ICBack } from '@Icons/ic-caret-left-small.svg'
17+
import { Button, ButtonStyleType, ButtonVariantType } from '@Shared/Components/Button'
18+
import { ComponentSizeType } from '@Shared/constants'
1719
import { Table, InfoCard } from './components'
1820
import { DEFAULT_SECURITY_MODAL_STATE } from './constants'
1921
import { getTableData, getInfoCardData } from './config'
@@ -64,16 +66,16 @@ const SecurityModal: React.FC<SecurityModalPropsType> = ({
6466
const renderHeader = () => (
6567
<div className="flexbox dc__content-space dc__align-items-center pl-20 pr-20 pt-12 pb-12 dc__border-bottom">
6668
<span className="fs-16 fw-6 lh-24 cn-9">Security</span>
67-
<button
68-
type="button"
69-
className="dc__unset-button-styles"
69+
<Button
70+
dataTestId="close-security-modal"
71+
ariaLabel="close-security-modal"
72+
icon={<ICClose />}
7073
onClick={handleModalClose}
71-
aria-label="Close Modal"
72-
>
73-
<div className="flex p-4">
74-
<ICClose className="icon-dim-16" />
75-
</div>
76-
</button>
74+
showAriaLabelInTippy={false}
75+
size={ComponentSizeType.xs}
76+
style={ButtonStyleType.neutral}
77+
variant={ButtonVariantType.borderLess}
78+
/>
7779
</div>
7880
)
7981

src/Shared/Components/Security/Vulnerabilities/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const useGetSecurityVulnerabilities = ({
8383
)
8484

8585
const [scanResultLoading, scanResultResponse, scanResultError, reloadScanResult] = useAsync(
86-
() => getSecurityScan({ artifactId, appId, envId }),
86+
() => getSecurityScan({ artifactId, appId }),
8787
[],
8888
isScanned && isScanEnabled && isScanV2Enabled && !!getSecurityScan,
8989
{

src/Shared/Components/SelectPicker/FilterSelectPicker.tsx

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import { useEffect, useMemo, useState } from 'react'
66
import { ReactComponent as ICFilter } from '@Icons/ic-filter.svg'
77
import { ReactComponent as ICFilterApplied } from '@Icons/ic-filter-applied.svg'
88
import { ComponentSizeType } from '@Shared/constants'
9+
import { useRegisterShortcut, UseRegisterShortcutProvider } from '@Common/Hooks'
10+
import { IS_PLATFORM_MAC_OS } from '@Common/Constants'
11+
import { SupportedKeyboardKeysType } from '@Common/Hooks/UseRegisterShortcut/types'
912
import SelectPicker from './SelectPicker.component'
1013
import { FilterSelectPickerProps, SelectPickerOptionType, SelectPickerProps } from './type'
1114
import { Button } from '../Button'
1215

16+
const APPLY_FILTER_SHORTCUT_KEYS: SupportedKeyboardKeysType[] = [IS_PLATFORM_MAC_OS ? 'Meta' : 'Control', 'Enter']
17+
1318
const FilterSelectPicker = ({
1419
appliedFilterOptions,
1520
handleApplyFilter,
@@ -23,6 +28,8 @@ const FilterSelectPicker = ({
2328
structuredClone(appliedFilterOptions ?? []),
2429
)
2530

31+
const { registerShortcut, unregisterShortcut } = useRegisterShortcut()
32+
2633
const appliedFiltersCount = appliedFilterOptions?.length ?? 0
2734

2835
useEffect(() => {
@@ -52,24 +59,39 @@ const FilterSelectPicker = ({
5259
setSelectedOptions(structuredClone(appliedFilterOptions ?? []))
5360
}
5461

55-
const renderApplyButton = () => {
56-
const handleApplyClick = () => {
57-
handleApplyFilter(selectedOptions)
58-
closeMenu()
62+
const handleApplyClick = () => {
63+
handleApplyFilter(selectedOptions)
64+
closeMenu()
65+
}
66+
67+
const renderApplyButton = () => (
68+
<div className="p-8 dc__border-top-n1">
69+
<Button
70+
text="Apply"
71+
dataTestId="filter-select-picker-apply"
72+
onClick={handleApplyClick}
73+
size={ComponentSizeType.small}
74+
fullWidth
75+
showTooltip
76+
tooltipProps={{
77+
shortcutKeyCombo: {
78+
text: 'Apply filter',
79+
combo: APPLY_FILTER_SHORTCUT_KEYS,
80+
},
81+
}}
82+
/>
83+
</div>
84+
)
85+
86+
useEffect(() => {
87+
if (isMenuOpen) {
88+
registerShortcut({ keys: APPLY_FILTER_SHORTCUT_KEYS, callback: handleApplyClick })
5989
}
6090

61-
return (
62-
<div className="p-8 dc__border-top-n1">
63-
<Button
64-
text="Apply"
65-
dataTestId="filter-select-picker-apply"
66-
onClick={handleApplyClick}
67-
size={ComponentSizeType.small}
68-
fullWidth
69-
/>
70-
</div>
71-
)
72-
}
91+
return () => {
92+
unregisterShortcut(APPLY_FILTER_SHORTCUT_KEYS)
93+
}
94+
}, [handleApplyClick, isMenuOpen])
7395

7496
return (
7597
<div className="dc__mxw-250">
@@ -96,4 +118,10 @@ const FilterSelectPicker = ({
96118
)
97119
}
98120

99-
export default FilterSelectPicker
121+
const FilterSelectPickerWrapper = (props: FilterSelectPickerProps) => (
122+
<UseRegisterShortcutProvider ignoreTags={[]}>
123+
<FilterSelectPicker {...props} />
124+
</UseRegisterShortcutProvider>
125+
)
126+
127+
export default FilterSelectPickerWrapper

src/Shared/Components/SelectPicker/SelectPicker.component.tsx

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

17-
import { GroupHeadingProps, MultiValueProps, OptionProps, ValueContainerProps, MenuPlacement } from 'react-select'
17+
import {
18+
GroupHeadingProps,
19+
MultiValueProps,
20+
OptionProps,
21+
ValueContainerProps,
22+
MenuPlacement,
23+
Props as ReactSelectProps,
24+
} from 'react-select'
1825
import CreatableSelect from 'react-select/creatable'
1926
import { ReactElement, useCallback, useMemo } from 'react'
2027

@@ -308,6 +315,13 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
308315
}
309316
}
310317

318+
const handleKeyDown: ReactSelectProps['onKeyDown'] = (e) => {
319+
// Prevent the option from being selected if meta or control key is pressed
320+
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
321+
e.preventDefault()
322+
}
323+
}
324+
311325
const commonProps = useMemo(
312326
() => ({
313327
name: name || inputId,
@@ -318,7 +332,7 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
318332
menuPlacement: 'auto' as MenuPlacement,
319333
menuPosition,
320334
menuShouldScrollIntoView: true,
321-
backspaceRemovesValue: isMulti,
335+
backspaceRemovesValue: isMulti && controlShouldRenderValue,
322336
'aria-errormessage': errorElementId,
323337
'aria-invalid': !!error,
324338
'aria-labelledby': labelId,
@@ -336,8 +350,8 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
336350
errorElementId,
337351
error,
338352
labelId,
339-
isMulti,
340353
shouldRenderCustomOptions,
354+
controlShouldRenderValue,
341355
],
342356
)
343357

@@ -393,6 +407,7 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
393407
onInputChange={onInputChange}
394408
icon={icon}
395409
showSelectedOptionIcon={shouldShowSelectedOptionIcon}
410+
onKeyDown={handleKeyDown}
396411
/>
397412
</div>
398413
</ConditionalWrap>

src/Shared/Components/SelectPicker/common.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,18 @@ export const SelectPickerMenuList = <OptionValue,>(props: MenuListProps<SelectPi
207207
} = props
208208

209209
return (
210-
// added key here to explicitly re-render the list on input change so that the top option is rendered
211-
<components.MenuList {...props} key={inputValue}>
212-
<div className="py-4 cursor">{shouldRenderCustomOptions ? renderCustomOptions() : children}</div>
213-
{/* Added to the bottom of menu list to prevent from hiding when the menu is opened close to the bottom of the screen */}
210+
<>
211+
{/* added key here to explicitly re-render the list on input change so that the top option is rendered */}
212+
<components.MenuList {...props} key={inputValue}>
213+
<div className="py-4 cursor">{shouldRenderCustomOptions ? renderCustomOptions() : children}</div>
214+
{/* Added to the bottom of menu list to prevent from hiding when the menu is opened close to the bottom of the screen */}
215+
</components.MenuList>
214216
{!shouldRenderCustomOptions && renderMenuListFooter && (
215217
<div className="dc__position-sticky dc__bottom-0 dc__bottom-radius-4 bcn-0 dc__zi-2">
216218
{renderMenuListFooter()}
217219
</div>
218220
)}
219-
</components.MenuList>
221+
</>
220222
)
221223
}
222224

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export interface customEnv {
9898
FEATURE_BULK_RESTART_WORKLOADS_FROM_RB: string
9999
FEATURE_DEFAULT_MERGE_STRATEGY?: OverrideMergeStrategyType
100100
FEATURE_DEFAULT_LANDING_RB_ENABLE?: boolean
101+
FEATURE_CLUSTER_MAP_ENABLE?: boolean
101102
}
102103
declare global {
103104
interface Window {

0 commit comments

Comments
 (0)