fix cluster configuration bugs
@@ -33,8 +33,10 @@ const createTree = (ls) =>
}, {})
// render tree view from tree object
-const createTreeView = ({ getKey, setKey, deleteKey, kdb }, tree, prefix = '') =>
- Object.keys(tree).map((key) => {
+const createTreeView =
+ ({ getKey, setKey, deleteKey, kdb }, tree, prefix = '') => {
+ let root = true
+ return Object.keys(tree).map((key) => {
const path = prefix ? `${prefix}/${key}` : key
const loadChildren = () =>
@@ -43,7 +45,8 @@ const createTreeView = ({ getKey, setKey, deleteKey, kdb }, tree, prefix = '') =
)
// only allow deletion of items without subtrees
- const allowDelete = Object.keys(tree[key]).length === 0
+ const allowDelete = root ? false : Object.keys(tree[key]).length === 0
+ root = false
const { value, meta } = (kdb && kdb[path]) || { value: '', meta: {} }
@@ -65,6 +68,7 @@ const createTreeView = ({ getKey, setKey, deleteKey, kdb }, tree, prefix = '') =
</TreeItem>
)
})
+ }
// get configuration of the selected cluster/instance
const getConfiguration = (instance, cluster) => {
@@ -121,7 +125,7 @@ const Configuration = ({
getKey: getCorrectKey,
setKey: setCorrectKey,
deleteKey: deleteCorrectKey,
- }, { '/': tree.user }) // only show user/ namespace
+ }, { '/': (tree && tree.user) || {} }) // only show user/ namespace
return (
<Card>
