Skip to content

Commit 77a125b

Browse files
committed
fix: review comments
1 parent 66fd8a6 commit 77a125b

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

src/Common/Helper.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,23 @@ import moment from 'moment'
2323
import { useLocation } from 'react-router-dom'
2424
import YAML from 'yaml'
2525
import { deepEquals } from '@rjsf/utils'
26-
import { ERROR_EMPTY_SCREEN, SortingOrder, EXCLUDED_FALSY_VALUES, DISCORD_LINK, ZERO_TIME_STRING, TOAST_ACCESS_DENIED } from './Constants'
26+
import {
27+
ERROR_EMPTY_SCREEN,
28+
SortingOrder,
29+
EXCLUDED_FALSY_VALUES,
30+
DISCORD_LINK,
31+
ZERO_TIME_STRING,
32+
TOAST_ACCESS_DENIED,
33+
} from './Constants'
2734
import { ServerErrors } from './ServerError'
2835
import { AsyncOptions, AsyncState, UseSearchString } from './Types'
29-
import { scrollableInterface, DATE_TIME_FORMAT_STRING, ToastManager, ToastVariantType, versionComparatorBySortOrder } from '../Shared'
36+
import {
37+
scrollableInterface,
38+
DATE_TIME_FORMAT_STRING,
39+
ToastManager,
40+
ToastVariantType,
41+
versionComparatorBySortOrder,
42+
} from '../Shared'
3043
import { ReactComponent as ArrowDown } from '../Assets/Icon/ic-chevron-down.svg'
3144

3245
export function showError(serverError, showToastOnUnknownError = true, hideAccessError = false) {

src/Common/RJSF/utils.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ export const getInferredTypeFromValueType = (value) => {
137137
}
138138
}
139139

140-
const conformPathToPointers = (path: string) => {
140+
const conformPathToPointers = (path: string): string => {
141+
if (!path) {
142+
return ''
143+
}
141144
const trimmedPath = path.trim()
142145
const isSlashSeparatedPathMissingBeginSlash = trimmedPath.match(/^\w+(\/\w+)*$/g)
143146
if (isSlashSeparatedPathMissingBeginSlash) {
@@ -151,6 +154,11 @@ const conformPathToPointers = (path: string) => {
151154
return trimmedPath
152155
}
153156

157+
const emptyMetaHiddenTypeInstance: MetaHiddenType = {
158+
value: false,
159+
path: '',
160+
}
161+
154162
export const parseSchemaHiddenType = (hiddenSchema: HiddenType): MetaHiddenType => {
155163
if (!hiddenSchema) {
156164
return null
@@ -162,14 +170,20 @@ export const parseSchemaHiddenType = (hiddenSchema: HiddenType): MetaHiddenType
162170
path: conformPathToPointers(clone),
163171
}
164172
}
165-
if ('condition' in clone) {
173+
if (typeof clone !== 'object') {
174+
return structuredClone(emptyMetaHiddenTypeInstance)
175+
}
176+
if ('condition' in clone && 'value' in clone) {
166177
return {
167178
value: clone.condition,
168179
path: conformPathToPointers(clone.value),
169180
}
170181
}
171-
return {
172-
...clone,
173-
path: conformPathToPointers(clone.path),
182+
if ('value' in clone && 'path' in clone) {
183+
return {
184+
value: clone.value,
185+
path: conformPathToPointers(clone.path),
186+
}
174187
}
188+
return structuredClone(emptyMetaHiddenTypeInstance)
175189
}

src/Shared/Helpers.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ export const numberComparatorBySortOrder = (
141141

142142
export function versionComparatorBySortOrder(a: string, b: string, orderBy = SortingOrder.ASC) {
143143
if (orderBy === SortingOrder.DESC) {
144-
return a.localeCompare(b, undefined, { numeric: true })
144+
return a?.localeCompare(b, undefined, { numeric: true }) ?? 1
145145
}
146146

147-
return b.localeCompare(a, undefined, { numeric: true })
147+
return b?.localeCompare(a, undefined, { numeric: true }) ?? 1
148148
}
149149

150150
export const getWebhookEventIcon = (eventName: WebhookEventNameType) => {

0 commit comments

Comments
 (0)