Skip to content

Commit

Permalink
fix(dashboard): recursive parent on dashboard components (apache#16933)
Browse files Browse the repository at this point in the history
* fix(dashboard): don't add recursive parents on wrapper component

* add test

* refine logic and add new test
  • Loading branch information
villebro authored Oct 1, 2021
1 parent 05ddaeb commit b28caeb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ describe('newEntitiesFromDrop', () => {

expect(result.a.children).toHaveLength(1);
expect(Object.keys(result)).toHaveLength(3);
expect(result[newRowId].type).toBe(ROW_TYPE);
expect(result[newChartId].type).toBe(CHART_TYPE);
const newRow = result[newRowId];
expect(newRow.type).toBe(ROW_TYPE);
expect(newRow.parents).toEqual(['a']);
const newChart = result[newChartId];
expect(newChart.type).toBe(CHART_TYPE);
expect(newChart.parents).toEqual(['a', newRowId]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export default function newEntitiesFromDrop({ dropResult, layout }) {
rowWrapper.children = [newDropChild.id];
rowWrapper.parents = (dropEntity.parents || []).concat(dropEntity.id);
newEntities[rowWrapper.id] = rowWrapper;
newDropChild = rowWrapper;
newDropChild.parents = rowWrapper.parents.concat(rowWrapper.id);
newDropChild = rowWrapper;
} else if (dragType === TABS_TYPE) {
// create a new tab component
const tabChild = newComponentFactory(TAB_TYPE);
Expand Down

0 comments on commit b28caeb

Please sign in to comment.