Skip to content

Commit 44d758f

Browse files
author
Amrit Kashyap Borah
committed
fix: review comments
1 parent 654fca7 commit 44d758f

5 files changed

Lines changed: 54 additions & 6 deletions

File tree

src/Common/Hooks/UseRegisterShortcut/UseRegisterShortcutProvider.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ const UseRegisterShortcutProvider = ({
182182
clearTimeout(keyDownTimeoutRef.current)
183183
}
184184
}
185-
}, [handleKeyupEvent, handleKeydownEvent, handleBlur])
185+
}, [handleKeyupEvent, handleKeydownEvent, handleBlur, shouldHookOntoWindow])
186186

187187
const providerValue: UseRegisterShortcutContextType = useMemo(
188188
() => ({
@@ -194,7 +194,16 @@ const UseRegisterShortcutProvider = ({
194194
? { targetProps: { onKeyDown: handleKeydownEvent, onKeyUp: handleKeyupEvent, onBlur: handleBlur } }
195195
: {}),
196196
}),
197-
[registerShortcut, unregisterShortcut, setDisableShortcuts, triggerShortcut],
197+
[
198+
registerShortcut,
199+
unregisterShortcut,
200+
setDisableShortcuts,
201+
triggerShortcut,
202+
shouldHookOntoWindow,
203+
handleKeydownEvent,
204+
handleKeyupEvent,
205+
handleBlur,
206+
],
198207
)
199208

200209
return <UseRegisterShortcutContext.Provider value={providerValue}>{children}</UseRegisterShortcutContext.Provider>

src/Pages/ResourceBrowser/constants.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { ReactComponent as ICCleanBrush } from '@Icons/ic-medium-clean-brush.svg'
1818
import { ReactComponent as ICMediumPause } from '@Icons/ic-medium-pause.svg'
1919
import { ReactComponent as ICMediumPlay } from '@Icons/ic-medium-play.svg'
20+
import { URLS } from '@Common/Constants'
2021
import { SelectPickerOptionType } from '@Shared/Components'
2122

2223
import { NodeDrainRequest } from './types'
@@ -114,3 +115,18 @@ export const NODE_DRAIN_OPTIONS_CHECKBOX_CONFIG: {
114115

115116
export const GVK_FILTER_KIND_QUERY_PARAM_KEY = 'gvkFilterKind'
116117
export const GVK_FILTER_API_VERSION_QUERY_PARAM_KEY = 'gvkFilterApiVersion'
118+
119+
export const DUMMY_RESOURCE_GVK_VERSION = 'v1'
120+
121+
export const RESOURCE_BROWSER_ROUTES = {
122+
OVERVIEW: `${URLS.RESOURCE_BROWSER}/:clusterId/overview`,
123+
MONITORING_DASHBOARD: `${URLS.RESOURCE_BROWSER}/:clusterId/monitoring-dashboard`,
124+
TERMINAL: `${URLS.RESOURCE_BROWSER}/:clusterId/terminal`,
125+
CLUSTER_UPGRADE: `${URLS.RESOURCE_BROWSER}/:clusterId/cluster-upgrade`,
126+
NODE_DETAIL: `${URLS.RESOURCE_BROWSER}/:clusterId/node/:name`,
127+
K8S_RESOURCE_DETAIL: `${URLS.RESOURCE_BROWSER}/:clusterId/:namespace/:kind/:group/:version/:name`,
128+
K8S_RESOURCE_LIST: `${URLS.RESOURCE_BROWSER}/:clusterId/:kind/:group/:version`,
129+
RESOURCE_RECOMMENDER: `${URLS.RESOURCE_BROWSER}/:clusterId/resource-recommender`,
130+
} as const
131+
132+
export const K8S_EMPTY_GROUP = 'k8sEmptyGroup'

src/Pages/ResourceBrowser/types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,22 @@ export interface InstallationClusterConfigType
150150
status: InstallationClusterStatus
151151
correspondingClusterId: number | 0
152152
}
153+
154+
export enum NodeActionMenuOptionIdEnum {
155+
terminal = 'terminal',
156+
cordon = 'cordon',
157+
uncordon = 'uncordon',
158+
drain = 'drain',
159+
editTaints = 'edit-taints',
160+
editYaml = 'edit-yaml',
161+
delete = 'delete',
162+
}
163+
164+
export enum ResourceBrowserActionMenuEnum {
165+
manifest = 'manifest',
166+
events = 'events',
167+
logs = 'logs',
168+
terminal = 'terminal',
169+
delete = 'delete',
170+
vulnerability = 'vulnerability',
171+
}

src/Shared/Components/CICDHistory/utils.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ import moment from 'moment'
1919
import { ReactComponent as ICCheck } from '@Icons/ic-check.svg'
2020
import { ReactComponent as Close } from '@Icons/ic-close.svg'
2121
import { ReactComponent as ICInProgress } from '@Icons/ic-in-progress.svg'
22-
import { DATE_TIME_FORMATS } from '@Common/Constants'
22+
import { DATE_TIME_FORMATS, URLS } from '@Common/Constants'
2323
import { DeploymentAppTypes } from '@Common/Types'
2424
import { ALL_RESOURCE_KIND_FILTER } from '@Shared/constants'
2525
import { isTimeStringAvailable } from '@Shared/Helpers'
26+
import { DUMMY_RESOURCE_GVK_VERSION, K8S_EMPTY_GROUP } from '@Pages/ResourceBrowser'
2627

2728
import { DeploymentStatusBreakdownItemType, Node, ResourceKindType, WorkflowStatusEnum } from '../../types'
2829
import { Icon } from '../Icon'
@@ -233,7 +234,7 @@ export const getHistoryItemStatusIconFromWorkflowStages = (
233234
}
234235

235236
export const getWorkerPodBaseUrl = (clusterId: number = DEFAULT_CLUSTER_ID, podNamespace: string = DEFAULT_NAMESPACE) =>
236-
`/resource-browser/${clusterId}/${podNamespace}/pod/k8sEmptyGroup/v1`
237+
`${URLS.RESOURCE_BROWSER}/${clusterId}/${podNamespace}/pod/${K8S_EMPTY_GROUP}/${DUMMY_RESOURCE_GVK_VERSION}`
237238

238239
export const getWorkflowNodeStatusTitle = (status: string) => {
239240
if (!status) {

src/Shared/Components/Table/InternalTable.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,21 @@ const InternalTable = ({
6060
const searchSortTimeoutRef = useRef<number>(-1)
6161

6262
useEffect(() => {
63-
wrapperDivRef.current?.addEventListener('focusout', (e: FocusEvent) => {
63+
const handleFocusOutEvent = (e: FocusEvent) => {
6464
const container = e.currentTarget as HTMLElement
6565
const related = e.relatedTarget as HTMLElement | null
6666

6767
if (container && (!related || related.tagName === 'BODY')) {
6868
const tableElement = wrapperDivRef.current.getElementsByClassName('generic-table')[0] as HTMLDivElement
6969
tableElement?.focus()
7070
}
71-
})
71+
}
72+
73+
wrapperDivRef.current?.addEventListener('focusout', handleFocusOutEvent)
7274

7375
return () => {
7476
clearTimeout(searchSortTimeoutRef.current)
77+
wrapperDivRef.current?.removeEventListener('focusout', handleFocusOutEvent)
7578
}
7679
}, [])
7780

0 commit comments

Comments
 (0)