Skip to content

Commit 4ef35fd

Browse files
committed
feat: only parse the selected source on useraction commit
1 parent 4d58ce8 commit 4ef35fd

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

packages/webui/src/client/styles/propertiesPanel.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
}
4343

4444
> .propertiespanel-pop-up__header {
45-
background: #0A20ED;
45+
background: #484848;
4646
color: #ddd;
4747

4848
min-width: 2.5rem;

packages/webui/src/client/ui/UserEditOperations/PropertiesPanel.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ function EditingTypeChangeSourceLayerSource(props: {
406406
)
407407
const [schemaValues, setSchemaValues] = React.useState({
408408
type: selectedSourceGroup,
409-
value:
409+
values:
410410
props.pendingChanges.find((change) => change.operationId === props.userEditOperation.id)?.value ||
411411
props.userEditOperation.currentValues.value,
412412
})
@@ -422,7 +422,7 @@ function EditingTypeChangeSourceLayerSource(props: {
422422
const handleSourceChange = () => {
423423
setSchemaValues({
424424
type: selectedSourceGroup,
425-
value: schemaValues.value,
425+
values: schemaValues.values,
426426
})
427427
// Add to pending changes instead of executing immediately
428428
props.setPendingChanges((prev) => {
@@ -433,13 +433,20 @@ function EditingTypeChangeSourceLayerSource(props: {
433433
change.userEditingType === UserEditingType.SOURCE_LAYER_FORM
434434
)
435435
)
436+
// Only use the key,value pair from the selected source group:
437+
const newKey = Object.keys(schemaValues.values).find((key) => {
438+
return props.userEditOperation.schemas[key].sourceLayerType === selectedSourceGroup
439+
})
440+
if (!newKey) return filtered
441+
const newValue = props.userEditOperation.currentValues.value[newKey]
442+
436443
return [
437444
...filtered,
438445
{
439446
operationId: props.userEditOperation.id,
440447
userEditingType: UserEditingType.SOURCE_LAYER_FORM,
441448
sourceLayerType: selectedSourceGroup,
442-
values: schemaValues.value,
449+
value: { [newKey]: newValue },
443450
},
444451
]
445452
})
@@ -472,7 +479,7 @@ function EditingTypeChangeSourceLayerSource(props: {
472479
<a className="propertiespanel-pop-up__label">{t('Source')}:</a>
473480
<SchemaFormInPlace
474481
schema={schema}
475-
object={schemaValues.value}
482+
object={schemaValues.values}
476483
translationNamespaces={props.userEditOperation.translationNamespaces}
477484
/>
478485
<br />

packages/webui/src/client/ui/UserEditOperations/RenderUserEditOperations.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function RenderUserEditOperations(
7171
disabled={!isFormEditable}
7272
key={`${userEditOperation.id}_${i}`}
7373
onClick={(e) => {
74-
const schema = JSONBlobParse(userEditOperation.schemas['camera'])
74+
const schema = JSONBlobParse(userEditOperation.schema)
7575
const values = clone(userEditOperation.currentValues)
7676

7777
// TODO:
@@ -101,6 +101,8 @@ export function RenderUserEditOperations(
101101
<span>Open Properties</span>
102102
</MenuItem>
103103
)
104+
case UserEditingType.SOURCE_LAYER_FORM:
105+
return <></>
104106
default:
105107
assertNever(userEditOperation)
106108
return null

0 commit comments

Comments
 (0)