Skip to content

Commit 3fe9844

Browse files
Merge pull request #3449 from RedisInsight/fe/rejson_change_misprint
change misprint for ReJSON
2 parents 152c80c + b1a7959 commit 3fe9844

File tree

10 files changed

+25
-37
lines changed

10 files changed

+25
-37
lines changed

redisinsight/ui/src/pages/browser/components/add-key/constants/fields-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const AddListFormConfig: IAddListFormConfig = {
108108
name: 'count',
109109
isRequire: true,
110110
label: 'Count',
111-
placeholder: 'Enter Count'
111+
placeholder: 'Enter Count*'
112112
}
113113
}
114114

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/RejsonDetailsWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const RejsonDetailsWrapper = (props: Props) => {
106106
data={data as IJSONData}
107107
length={length}
108108
parentPath={path}
109-
expadedRows={expandedRows}
109+
expandedRows={expandedRows}
110110
onJsonKeyExpandAndCollapse={handleJsonKeyExpandAndCollapse}
111111
isDownloaded={downloaded}
112112
/>

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/components/edit-entire-item-action/EditEntireItemAction.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import cx from 'classnames'
1313

1414
import FieldMessage from 'uiSrc/components/field-message/FieldMessage'
1515
import { Nullable } from 'uiSrc/utils'
16-
import { validateRejsonValue } from '../../utils'
16+
import { isValidJSON } from '../../utils'
17+
import { JSONErrors } from '../../constants'
1718

1819
import styles from '../../styles.module.scss'
1920

@@ -42,9 +43,8 @@ const EditEntireItemAction = (props: Props) => {
4243
const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
4344
e.preventDefault()
4445

45-
const error = validateRejsonValue(value)
46-
if (error) {
47-
setError(error)
46+
if (!isValidJSON(value)) {
47+
setError(JSONErrors.valueJSONFormat)
4848
return
4949
}
5050

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/interfaces.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ export interface BaseProps {
4343
selectedKey: RedisResponseBuffer
4444
isDownloaded: boolean
4545
onJsonKeyExpandAndCollapse: (isExpanded: boolean, path: string) => void
46-
expadedRows: Set<string>
46+
expandedRows: Set<string>
4747
}
4848

4949
export interface DynamicTypesProps {
5050
data: IJSONData
5151
parentPath?: string
5252
leftPadding?: number
53-
expadedRows: Set<string>
53+
expandedRows: Set<string>
5454
selectedKey: RedisResponseBuffer
5555
isDownloaded: boolean
5656
onClickRemoveKey: (path: string, keyName: string) => void
@@ -80,7 +80,7 @@ export interface JSONScalarProps extends JSONCommonProps {
8080
export interface JSONObjectProps extends JSONCommonProps {
8181
type: ObjectTypes
8282
isDownloaded: boolean
83-
expadedRows: Set<string>
83+
expandedRows: Set<string>
8484
onJsonKeyExpandAndCollapse: (isExpanded: boolean, path: string) => void
8585
onClickRemoveKey: (path: string, keyName: string) => void
8686
handleSubmitUpdateValue?: (body: UpdateValueBody) => void

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/rejson-details/RejsonDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const RejsonDetails = (props: BaseProps) => {
2525
parentPath,
2626
isDownloaded,
2727
onJsonKeyExpandAndCollapse,
28-
expadedRows
28+
expandedRows
2929
} = props
3030

3131
const [addRootKVPair, setAddRootKVPair] = useState<boolean>(false)
@@ -80,7 +80,7 @@ const RejsonDetails = (props: BaseProps) => {
8080
parentPath={parentPath}
8181
selectedKey={selectedKey}
8282
isDownloaded={isDownloaded}
83-
expadedRows={expadedRows}
83+
expandedRows={expandedRows}
8484
onClickRemoveKey={onClickRemoveKey}
8585
onJsonKeyExpandAndCollapse={onJsonKeyExpandAndCollapse}
8686
handleAppendRejsonObjectItemAction={handleAppendRejsonArrayItemAction}

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/rejson-dynamic-types/RejsonDynamicTypes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const RejsonDynamicTypes = (props: DynamicTypesProps) => {
1414
selectedKey,
1515
parentPath = '',
1616
isDownloaded,
17-
expadedRows,
17+
expandedRows,
1818
leftPadding = 0,
1919
onClickRemoveKey,
2020
onJsonKeyExpandAndCollapse,
@@ -42,7 +42,7 @@ const RejsonDynamicTypes = (props: DynamicTypesProps) => {
4242

4343
const renderJSONObject = (data: any, type: string) => (
4444
<RejsonObject
45-
expadedRows={expadedRows}
45+
expandedRows={expandedRows}
4646
type={type as ObjectTypes}
4747
isDownloaded={isDownloaded}
4848
leftPadding={nextLeftPadding}

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/rejson-object/RejsonObject.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const RejsonObject = (props: JSONObjectProps) => {
1818
parentPath,
1919
keyName,
2020
isDownloaded,
21-
expadedRows,
21+
expandedRows,
2222
leftPadding,
2323
selectedKey,
2424
cardinality = 0,
@@ -43,14 +43,14 @@ const RejsonObject = (props: JSONObjectProps) => {
4343
const [isExpanded, setIsExpanded] = useState<boolean>(false)
4444

4545
useEffect(() => {
46-
if (!expadedRows?.has(path)) {
46+
if (!expandedRows?.has(path)) {
4747
setValue(defaultValue)
4848
return
4949
}
5050

5151
if (isDownloaded) {
5252
setValue(currentValue)
53-
setIsExpanded(expadedRows?.has(path))
53+
setIsExpanded(expandedRows?.has(path))
5454
return
5555
}
5656

@@ -173,7 +173,7 @@ const RejsonObject = (props: JSONObjectProps) => {
173173
/>
174174
) : (
175175
<RejsonDynamicTypes
176-
expadedRows={expadedRows}
176+
expandedRows={expandedRows}
177177
leftPadding={leftPadding}
178178
data={value}
179179
parentPath={path}

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/rejson-scalar/RejsonScalar.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import PopoverDelete from 'uiSrc/pages/browser/components/popover-delete/Popover
99
import { bufferToString, createDeleteFieldHeader, createDeleteFieldMessage, Nullable } from 'uiSrc/utils'
1010
import FieldMessage from 'uiSrc/components/field-message/FieldMessage'
1111

12-
import { JSONScalarValue, JSONScalarProps } from '../interfaces'
13-
import { generatePath, getClassNameByValue, validateRejsonValue } from '../utils'
12+
import { JSONScalarProps } from '../interfaces'
13+
import { generatePath, getClassNameByValue, isValidJSON } from '../utils'
14+
import { JSONErrors } from '../constants'
1415

1516
import styles from '../styles.module.scss'
1617
import '../styles.scss'
@@ -43,10 +44,9 @@ const RejsonScalar = (props: JSONScalarProps) => {
4344
setError(null)
4445
}
4546

46-
const onApplyValue = (value: JSONScalarValue) => {
47-
const error = validateRejsonValue(value)
48-
if (error) {
49-
setError(error)
47+
const onApplyValue = (value: string) => {
48+
if (!isValidJSON(value)) {
49+
setError(JSONErrors.valueJSONFormat)
5050
return
5151
}
5252

redisinsight/ui/src/pages/browser/modules/key-details/components/rejson-details/utils/utils.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { isArray } from 'lodash'
2-
import { JSONErrors } from '../constants'
32
import { JSONScalarValue, ObjectTypes } from '../interfaces'
43
import styles from '../styles.module.scss'
54

@@ -38,15 +37,6 @@ export const wrapPath = (key: string, path: string = '') => {
3837
}
3938
}
4039

41-
export const validateRejsonValue = (value: any) => {
42-
try {
43-
JSON.parse(value as string)
44-
return null
45-
} catch (e) {
46-
return JSONErrors.valueJSONFormat
47-
}
48-
}
49-
5040
export const getClassNameByValue = (value: any) => {
5141
const type = typeof value
5242
// @ts-ignore

redisinsight/ui/src/telemetry/telemetryUtils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ const getJsonPathLevel = (path: string): string => {
6868
const levelsLength = jsonpath.parse(
6969
`$${path.startsWith('.') ? '' : '..'}${path}`,
7070
).length
71-
if (levelsLength === 1) {
72-
return 'root'
73-
}
74-
return `${levelsLength - 2}`
71+
72+
return levelsLength === 1 ? 'root' : `${levelsLength - 2}`
7573
} catch (e) {
7674
return 'root'
7775
}

0 commit comments

Comments
 (0)