Skip to content

Commit 8e4707e

Browse files
Merge pull request #806 from devtron-labs/feat/rb-table
fix: RB table
2 parents 7068e51 + 276bacd commit 8e4707e

6 files changed

Lines changed: 27 additions & 16 deletions

File tree

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.16.0-pre-7",
3+
"version": "1.16.0-pre-8",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Hooks/UseRegisterShortcut/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export const KEYBOARD_KEYS_MAP = {
3131
X: 'X',
3232
A: 'A',
3333
N: 'N',
34+
S: 'S',
35+
'/': '/',
3436
Escape: 'Esc',
3537
Enter: '↩',
3638
ArrowLeft: '←',

src/Pages/ResourceBrowser/constants.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,14 @@ export const NODE_DRAIN_OPTIONS_CHECKBOX_CONFIG: {
116116
export const GVK_FILTER_KIND_QUERY_PARAM_KEY = 'gvkFilterKind'
117117
export const GVK_FILTER_API_VERSION_QUERY_PARAM_KEY = 'gvkFilterApiVersion'
118118

119-
export const DUMMY_RESOURCE_GVK_VERSION = 'v1'
120-
121119
export const RESOURCE_BROWSER_ROUTES = {
122120
OVERVIEW: `${URLS.RESOURCE_BROWSER}/:clusterId/overview`,
123121
MONITORING_DASHBOARD: `${URLS.RESOURCE_BROWSER}/:clusterId/monitoring-dashboard`,
124122
TERMINAL: `${URLS.RESOURCE_BROWSER}/:clusterId/terminal`,
125123
CLUSTER_UPGRADE: `${URLS.RESOURCE_BROWSER}/:clusterId/cluster-upgrade`,
126124
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`,
125+
K8S_RESOURCE_DETAIL: `${URLS.RESOURCE_BROWSER}/:clusterId/:namespace/:kind/:group/:name`,
126+
K8S_RESOURCE_LIST: `${URLS.RESOURCE_BROWSER}/:clusterId/:kind/:group`,
129127
RESOURCE_RECOMMENDER: `${URLS.RESOURCE_BROWSER}/:clusterId/resource-recommender`,
130128
} as const
131129

src/Shared/Components/CICDHistory/utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ 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'
26+
import { K8S_EMPTY_GROUP } from '@Pages/ResourceBrowser'
2727

2828
import { DeploymentStatusBreakdownItemType, Node, ResourceKindType, WorkflowStatusEnum } from '../../types'
2929
import { Icon } from '../Icon'
@@ -234,7 +234,7 @@ export const getHistoryItemStatusIconFromWorkflowStages = (
234234
}
235235

236236
export const getWorkerPodBaseUrl = (clusterId: number = DEFAULT_CLUSTER_ID, podNamespace: string = DEFAULT_NAMESPACE) =>
237-
`${URLS.RESOURCE_BROWSER}/${clusterId}/${podNamespace}/pod/${K8S_EMPTY_GROUP}/${DUMMY_RESOURCE_GVK_VERSION}`
237+
`${URLS.RESOURCE_BROWSER}/${clusterId}/${podNamespace}/pod/${K8S_EMPTY_GROUP}`
238238

239239
export const getWorkflowNodeStatusTitle = (status: string) => {
240240
if (!status) {

src/Shared/Components/Table/InternalTable.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,24 @@ const InternalTable = ({
6161

6262
useEffect(() => {
6363
const handleFocusOutEvent = (e: FocusEvent) => {
64-
const container = e.currentTarget as HTMLElement
65-
const related = e.relatedTarget as HTMLElement | null
66-
67-
if (container && (!related || related.tagName === 'BODY')) {
68-
const tableElement = wrapperDivRef.current.getElementsByClassName('generic-table')[0] as HTMLDivElement
69-
tableElement?.focus()
70-
}
64+
setTimeout(() => {
65+
const container = e.currentTarget as HTMLElement
66+
const related = e.relatedTarget as HTMLElement | null
67+
68+
// NOTE: we want to focus the table if the focus is lost from any element inside the table
69+
// and the focus is not moving to another element inside the table. Ideally we don't want to steal focus
70+
// inputs, buttons, etc. from the user, but when we blur any element by pressing Escape, we want to focus the table
71+
// Keep in mind that if we tab focus onto a div/span with tabIndex then the relatedTarget will be that null
72+
if (
73+
!container.contains(document.activeElement) &&
74+
(!related || related.tagName === 'BODY' || document.activeElement === document.body)
75+
) {
76+
const tableElement = wrapperDivRef.current.getElementsByClassName(
77+
'generic-table',
78+
)[0] as HTMLDivElement
79+
tableElement?.focus()
80+
}
81+
}, 0)
7182
}
7283

7384
wrapperDivRef.current?.addEventListener('focusout', handleFocusOutEvent)

0 commit comments

Comments
 (0)