mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix panel errors seen when click on partitions.
This commit is contained in:
committed by
Dave Page
parent
cb9fffc7de
commit
2d1e835d32
@@ -240,10 +240,6 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings):
|
|||||||
else:
|
else:
|
||||||
nodes.extend(module.get_nodes(**kwargs))
|
nodes.extend(module.get_nodes(**kwargs))
|
||||||
|
|
||||||
# Explicitly include 'partition' module as we had excluded it during
|
|
||||||
# registration.
|
|
||||||
nodes.extend(self.blueprint.get_nodes(**kwargs))
|
|
||||||
|
|
||||||
# Return sorted nodes based on label
|
# Return sorted nodes based on label
|
||||||
return make_json_response(
|
return make_json_response(
|
||||||
data=sorted(
|
data=sorted(
|
||||||
|
|||||||
@@ -48,12 +48,13 @@ export function getTreeNodeHierarchyFromIdentifier(aciTreeNodeIdentifier) {
|
|||||||
|
|
||||||
export function getTreeNodeHierarchy(currentNode) {
|
export function getTreeNodeHierarchy(currentNode) {
|
||||||
let idx = 0;
|
let idx = 0;
|
||||||
|
let node_cnt = 0;
|
||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
do {
|
do {
|
||||||
const currentNodeData = currentNode.getData();
|
const currentNodeData = currentNode.getData();
|
||||||
if (currentNodeData._type in this.Nodes && this.Nodes[currentNodeData._type].hasId) {
|
if (currentNodeData._type in this.Nodes && this.Nodes[currentNodeData._type].hasId) {
|
||||||
const nodeType = mapType(currentNodeData._type);
|
const nodeType = mapType(currentNodeData._type, node_cnt);
|
||||||
if (result[nodeType] === undefined) {
|
if (result[nodeType] === undefined) {
|
||||||
result[nodeType] = _.extend({}, currentNodeData, {
|
result[nodeType] = _.extend({}, currentNodeData, {
|
||||||
'priority': idx,
|
'priority': idx,
|
||||||
@@ -61,12 +62,13 @@ export function getTreeNodeHierarchy(currentNode) {
|
|||||||
idx -= 1;
|
idx -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
node_cnt += 1;
|
||||||
currentNode = currentNode.hasParent() ? currentNode.parent() : null;
|
currentNode = currentNode.hasParent() ? currentNode.parent() : null;
|
||||||
} while (currentNode);
|
} while (currentNode);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapType(type) {
|
function mapType(type, idx) {
|
||||||
return type === 'partition' ? 'table' : type;
|
return (type === 'partition' && idx > 0) ? 'table' : type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,9 +178,14 @@ describe('tree#node#getTreeNodeHierarchy', () => {
|
|||||||
'special one': {
|
'special one': {
|
||||||
'some key': 'some value',
|
'some key': 'some value',
|
||||||
'_type': 'special one',
|
'_type': 'special one',
|
||||||
'priority': -1,
|
'priority': -2,
|
||||||
},
|
},
|
||||||
'table': {
|
'table': {
|
||||||
|
'some key': 'some value',
|
||||||
|
'_type': 'table',
|
||||||
|
'priority': -1,
|
||||||
|
},
|
||||||
|
'partition': {
|
||||||
'some key': 'expected value',
|
'some key': 'expected value',
|
||||||
'some other key': 'some other value',
|
'some other key': 'some other value',
|
||||||
'_type': 'partition',
|
'_type': 'partition',
|
||||||
@@ -337,9 +342,14 @@ describe('tree#node#getTreeNodeHierarchy', () => {
|
|||||||
'special one': {
|
'special one': {
|
||||||
'some key': 'some value',
|
'some key': 'some value',
|
||||||
'_type': 'special one',
|
'_type': 'special one',
|
||||||
'priority': -1,
|
'priority': -2,
|
||||||
},
|
},
|
||||||
'table': {
|
'table': {
|
||||||
|
'some key': 'some value',
|
||||||
|
'_type': 'table',
|
||||||
|
'priority': -1,
|
||||||
|
},
|
||||||
|
'partition': {
|
||||||
'some key': 'expected value',
|
'some key': 'expected value',
|
||||||
'some other key': 'some other value',
|
'some other key': 'some other value',
|
||||||
'_type': 'partition',
|
'_type': 'partition',
|
||||||
|
|||||||
Reference in New Issue
Block a user