fix locked items can be deleted

This commit is contained in:
srgooglo 2022-03-02 20:36:32 +01:00
parent b1b1a7fc38
commit 0ac5a3f3e8

View File

@ -105,6 +105,12 @@ export default class SidebarEditor extends React.Component {
} }
deleteItem = (key) => { deleteItem = (key) => {
// check if item is locked
if (allItems[key].locked) {
console.warn("Cannot delete an locked item")
return false
}
this.setState({ items: this.state.items.filter((item) => item !== key) }) this.setState({ items: this.state.items.filter((item) => item !== key) })
} }
@ -207,10 +213,13 @@ export default class SidebarEditor extends React.Component {
droppableSnapshot.isDraggingOver, droppableSnapshot.isDraggingOver,
)} )}
> >
<Icons.Trash {!allItems[key].locked &&
onClick={() => this.deleteItem(key)} <Icons.Trash
className="sidebar_editor_deleteBtn" onClick={() => this.deleteItem(key)}
/> className="sidebar_editor_deleteBtn"
/>
}
{itemComponent.icon && createIconRender(itemComponent.icon)}
{itemComponent.title ?? itemComponent.id} {itemComponent.title ?? itemComponent.id}
</div> </div>
)} )}