mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
fix: Properties had a null description (#1581)
* fix: Properties had a null description * Update frontend/projects/ui/src/app/util/properties.util.ts
This commit is contained in:
@@ -24,9 +24,9 @@ const matchPropertiesV1 = shape(
|
||||
{
|
||||
name: string,
|
||||
value: string,
|
||||
description: string,
|
||||
copyable: boolean,
|
||||
qr: boolean,
|
||||
description: string.optional(),
|
||||
copyable: boolean.optional(),
|
||||
qr: boolean.optional(),
|
||||
},
|
||||
['description', 'copyable', 'qr'],
|
||||
{ copyable: false, qr: false } as const,
|
||||
@@ -41,11 +41,11 @@ const [matchPackagePropertiesV2, setPPV2] = deferred<PackagePropertiesV2>()
|
||||
const matchPackagePropertyString = shape(
|
||||
{
|
||||
type: literal('string'),
|
||||
description: string,
|
||||
description: string.optional(),
|
||||
value: string,
|
||||
copyable: boolean,
|
||||
qr: boolean,
|
||||
masked: boolean,
|
||||
copyable: boolean.optional(),
|
||||
qr: boolean.optional(),
|
||||
masked: boolean.optional(),
|
||||
},
|
||||
['description', 'copyable', 'qr', 'masked'],
|
||||
{
|
||||
@@ -149,12 +149,12 @@ function parsePropertiesV1Permissive(
|
||||
} else {
|
||||
const error = result.error
|
||||
const message = Parser.validatorErrorAsString(error)
|
||||
let dataPath = error.keys.map(x => JSON.parse(x)).join('/')
|
||||
const dataPath = error.keys.map(removeQuotes).join('/')
|
||||
errorCallback(new Error(`/data/${idx}: ${message}`))
|
||||
if (dataPath) {
|
||||
applyOperation(cur, {
|
||||
op: 'replace',
|
||||
path: dataPath,
|
||||
path: `/${dataPath}`,
|
||||
value: undefined,
|
||||
})
|
||||
}
|
||||
@@ -179,12 +179,12 @@ function parsePropertiesV2Permissive(
|
||||
} else {
|
||||
const error = result.error
|
||||
const message = Parser.validatorErrorAsString(error)
|
||||
let dataPath = error.keys.map(x => JSON.parse(x)).join('/')
|
||||
const dataPath = error.keys.map(removeQuotes).join('/')
|
||||
errorCallback(new Error(`/data/${idx}: ${message}`))
|
||||
if (dataPath) {
|
||||
applyOperation(properties, {
|
||||
op: 'replace',
|
||||
path: dataPath,
|
||||
path: `/${dataPath}`,
|
||||
value: undefined,
|
||||
})
|
||||
}
|
||||
@@ -196,6 +196,14 @@ function parsePropertiesV2Permissive(
|
||||
)
|
||||
}
|
||||
|
||||
const removeRegex = /('|")/
|
||||
function removeQuotes(x: string) {
|
||||
while (removeRegex.test(x)) {
|
||||
x = x.replace(removeRegex, '')
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
type PackagePropertiesV1 = PropertiesV1[]
|
||||
export type PackageProperties = PackagePropertiesV2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user