Skip to content

Commit

Permalink
fix: removing last zone was not reflected in full data
Browse files Browse the repository at this point in the history
This changes the behavior of saving metadata so that an empty
zones array resulting from removing the last, previously added
zone, will be handled as null value. The code handling full
model deals properly with nulls, while empty arrays are
silently ignored as updates.
  • Loading branch information
tkurki committed May 22, 2024
1 parent d7ff005 commit 6d30d2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/server-admin-ui/src/views/DataBrowser/Meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export default function Meta({ meta, path }) {
/>
)}
<Zones
zones={zones}
zones={zones !== undefined && zones !== null ? zones : []}
isEditing={isEditing}
setZones={(zones) => setLocalMeta({ ...localMeta, zones })}
></Zones>
Expand Down
7 changes: 7 additions & 0 deletions src/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ module.exports = {
metaPath = parts.slice(0, parts.length - 1).join('.')
}

// set empty zones array explicitly to null
for (const prop in metaValue) {
if (Array.isArray(metaValue[prop]) && metaValue[prop].length === 0) {
metaValue[prop] = null
}
}

app.config.baseDeltaEditor.setMeta(context, metaPath, metaValue)

let full_meta = getMetadata('vessels.self.' + metaPath)
Expand Down

0 comments on commit 6d30d2f

Please sign in to comment.