mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +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,
|
name: string,
|
||||||
value: string,
|
value: string,
|
||||||
description: string,
|
description: string.optional(),
|
||||||
copyable: boolean,
|
copyable: boolean.optional(),
|
||||||
qr: boolean,
|
qr: boolean.optional(),
|
||||||
},
|
},
|
||||||
['description', 'copyable', 'qr'],
|
['description', 'copyable', 'qr'],
|
||||||
{ copyable: false, qr: false } as const,
|
{ copyable: false, qr: false } as const,
|
||||||
@@ -41,11 +41,11 @@ const [matchPackagePropertiesV2, setPPV2] = deferred<PackagePropertiesV2>()
|
|||||||
const matchPackagePropertyString = shape(
|
const matchPackagePropertyString = shape(
|
||||||
{
|
{
|
||||||
type: literal('string'),
|
type: literal('string'),
|
||||||
description: string,
|
description: string.optional(),
|
||||||
value: string,
|
value: string,
|
||||||
copyable: boolean,
|
copyable: boolean.optional(),
|
||||||
qr: boolean,
|
qr: boolean.optional(),
|
||||||
masked: boolean,
|
masked: boolean.optional(),
|
||||||
},
|
},
|
||||||
['description', 'copyable', 'qr', 'masked'],
|
['description', 'copyable', 'qr', 'masked'],
|
||||||
{
|
{
|
||||||
@@ -149,12 +149,12 @@ function parsePropertiesV1Permissive(
|
|||||||
} else {
|
} else {
|
||||||
const error = result.error
|
const error = result.error
|
||||||
const message = Parser.validatorErrorAsString(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}`))
|
errorCallback(new Error(`/data/${idx}: ${message}`))
|
||||||
if (dataPath) {
|
if (dataPath) {
|
||||||
applyOperation(cur, {
|
applyOperation(cur, {
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: dataPath,
|
path: `/${dataPath}`,
|
||||||
value: undefined,
|
value: undefined,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -179,12 +179,12 @@ function parsePropertiesV2Permissive(
|
|||||||
} else {
|
} else {
|
||||||
const error = result.error
|
const error = result.error
|
||||||
const message = Parser.validatorErrorAsString(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}`))
|
errorCallback(new Error(`/data/${idx}: ${message}`))
|
||||||
if (dataPath) {
|
if (dataPath) {
|
||||||
applyOperation(properties, {
|
applyOperation(properties, {
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: dataPath,
|
path: `/${dataPath}`,
|
||||||
value: undefined,
|
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[]
|
type PackagePropertiesV1 = PropertiesV1[]
|
||||||
export type PackageProperties = PackagePropertiesV2
|
export type PackageProperties = PackagePropertiesV2
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user