Skip to content

Commit b73674d

Browse files
committed
Merge branch 'kubecon-2024' of github.com:devtron-labs/devtron-fe-common-lib into feat/silver-surfer
2 parents 5df2a5f + ca8efcb commit b73674d

File tree

9 files changed

+51
-33
lines changed

9 files changed

+51
-33
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": "0.6.0-patch-1-beta-11",
3+
"version": "0.6.0-patch-1-beta-12",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/CodeEditor/codeEditor.scss

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,6 @@
105105
min-height: 300px;
106106
}
107107

108-
.code-editor__information {
109-
font-size: 12px;
110-
font-weight: 400;
111-
line-height: 1.33;
112-
letter-spacing: normal;
113-
color: var(--N900);
114-
height: auto;
115-
padding: 8px 16px;
116-
border-bottom: 1px solid #d6dbdf;
117-
background-color: var(--B100);
118-
}
119-
120108
.code-editor__information-info-icon {
121109
width: 16px;
122110
height: 16px;
@@ -140,16 +128,6 @@
140128
background: url('../../Assets/Icon/ic-compare.svg');
141129
}
142130

143-
.code-editor__error {
144-
background-color: #fde7e7;
145-
color: #862020;
146-
font-size: 12px;
147-
font-weight: 400;
148-
line-height: 1.33;
149-
padding: 8px 16px;
150-
border-bottom: 1px solid #d6dbdf;
151-
}
152-
153131
.monaco-editor-hover {
154132
margin-left: 40px;
155133
}

src/Common/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export const ROUTES = {
114114
DEPLOYMENT_CHARTS_LIST: 'deployment/template/fetch',
115115
USER_LIST_MIN: 'user/list/min',
116116
CONFIG_DATA: 'config/data',
117+
K8S_RESOURCE_LIST: 'k8s/resource/list',
117118
}
118119

119120
export enum KEY_VALUE {

src/Common/Helper.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import React, { SyntheticEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'
1818
import DOMPurify from 'dompurify'
1919
import { JSONPath, JSONPathOptions } from 'jsonpath-plus'
20-
import { compare as compareJSON, applyPatch } from 'fast-json-patch'
20+
import { compare as compareJSON, applyPatch, unescapePathComponent } from 'fast-json-patch'
2121
import { components } from 'react-select'
2222
import * as Sentry from '@sentry/browser'
2323
import moment from 'moment'
@@ -595,7 +595,7 @@ const buildObjectFromPathTokens = (index: number, tokens: string[], value: any)
595595
const isKeyNumber = !Number.isNaN(numberKey)
596596
return isKeyNumber
597597
? [...Array(numberKey).fill(null), buildObjectFromPathTokens(index + 1, tokens, value)]
598-
: { [key]: buildObjectFromPathTokens(index + 1, tokens, value) }
598+
: { [unescapePathComponent(key)]: buildObjectFromPathTokens(index + 1, tokens, value) }
599599
}
600600

601601
/**
@@ -644,10 +644,7 @@ export const powerSetOfSubstringsFromStart = (strings: string[], regex: RegExp)
644644
})
645645

646646
export const convertJSONPointerToJSONPath = (pointer: string) =>
647-
pointer
648-
.replace(/\/([\*0-9]+)\//g, '[$1].')
649-
.replace(/\//g, '.')
650-
.replace(/\./, '$.')
647+
unescapePathComponent(pointer.replace(/\/([\*0-9]+)\//g, '[$1].').replace(/\//g, '.').replace(/\./, '$.'))
651648

652649
export const flatMapOfJSONPaths = (
653650
paths: string[],

src/Common/RJSF/Form.tsx

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

17+
import { forwardRef } from 'react'
1718
import RJSF from '@rjsf/core'
1819
import RJSFValidator from '@rjsf/validator-ajv8'
1920

@@ -27,7 +28,7 @@ import './rjsfForm.scss'
2728
const Form = RJSF
2829
const validator = RJSFValidator
2930

30-
export const RJSFForm = (props: FormProps) => (
31+
export const RJSFForm = forwardRef((props: FormProps, ref: FormProps['ref']) => (
3132
<Form
3233
noHtml5Validate
3334
showErrorList={false}
@@ -42,5 +43,6 @@ export const RJSFForm = (props: FormProps) => (
4243
formContext={props.formData}
4344
widgets={{ ...widgets, ...props.widgets }}
4445
translateString={translateString}
46+
ref={ref}
4547
/>
46-
)
48+
))

src/Pages/ResourceBrowser/ResourceBrowser.Types.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,33 @@ export interface K8SObjectBaseType {
4040
isExpanded: boolean
4141
}
4242

43+
interface K8sRequestResourceIdentifierType {
44+
groupVersionKind: GVKType
45+
namespace?: string
46+
name?: string
47+
}
48+
49+
interface ResourceListPayloadK8sRequestType {
50+
resourceIdentifier: K8sRequestResourceIdentifierType
51+
patch?: string
52+
forceDelete?: boolean
53+
}
54+
55+
export interface K8sResourceListPayloadType {
56+
clusterId: number
57+
filter?: string
58+
k8sRequest: ResourceListPayloadK8sRequestType
59+
}
60+
61+
export type K8sResourceDetailDataType = {
62+
[key: string]: string | number | object
63+
}
64+
65+
export interface K8sResourceDetailType {
66+
headers: string[]
67+
data: K8sResourceDetailDataType[]
68+
}
69+
4370
export interface BulkSelectionActionWidgetProps {
4471
count: number
4572
handleOpenBulkDeleteModal: () => void

src/Pages/ResourceBrowser/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
export * from './ResourceBrowser.Types'
1818
export * from './Helper'
1919
export * from './types'
20+
export * from './service'

src/Pages/ResourceBrowser/service.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { post } from '@Common/Api'
2+
import { ROUTES } from '@Common/Constants'
3+
import { ResponseType } from '@Common/Types'
4+
import { K8sResourceDetailType, K8sResourceListPayloadType } from './ResourceBrowser.Types'
5+
6+
export const getK8sResourceList = (
7+
resourceListPayload: K8sResourceListPayloadType,
8+
signal?: AbortSignal,
9+
): Promise<ResponseType<K8sResourceDetailType>> =>
10+
post(ROUTES.K8S_RESOURCE_LIST, resourceListPayload, {
11+
signal,
12+
})

0 commit comments

Comments
 (0)