Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard): unable to drop tabs in columns #28242

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -243,18 +243,15 @@ class Column extends React.PureComponent {
{editMode && (
<Droppable
component={columnComponent}
parentComponent={parentComponent}
parentComponent={columnComponent}
{...(columnItems.length === 0
? {
component: columnComponent,
parentComponent,
dropToChild: true,
}
: {
component: columnItems,
parentComponent: columnComponent,
component: columnItems[0],
})}
depth={depth + 1}
depth={depth}
index={0}
orientation="column"
onDrop={handleComponentDrop}
Expand Down Expand Up @@ -291,7 +288,7 @@ class Column extends React.PureComponent {
<Droppable
component={columnItems}
parentComponent={columnComponent}
depth={depth + 1}
depth={depth}
index={itemIndex + 1}
orientation="column"
onDrop={handleComponentDrop}
Expand Down
Expand Up @@ -31,8 +31,10 @@ jest.mock('src/dashboard/components/dnd/DragDroppable', () => ({
Draggable: ({ children }) => (
<div data-test="mock-draggable">{children({})}</div>
),
Droppable: ({ children }) => (
<div data-test="mock-droppable">{children({})}</div>
Droppable: ({ children, depth }) => (
<div data-test="mock-droppable" depth={depth}>
{children({})}
</div>
),
}));
jest.mock(
Expand Down Expand Up @@ -130,14 +132,20 @@ test('should render a ResizableContainer', () => {

test('should render a HoverMenu in editMode', () => {
// we cannot set props on the Row because of the WithDragDropContext wrapper
const { container, getAllByTestId } = setup({
const { container, getAllByTestId, getByTestId } = setup({
component: columnWithoutChildren,
editMode: true,
});
expect(container.querySelector('.hover-menu')).toBeInTheDocument();

// Droppable area enabled in editMode
expect(getAllByTestId('mock-droppable').length).toBe(1);

// pass the same depth of its droppable area
expect(getByTestId('mock-droppable')).toHaveAttribute(
'depth',
`${props.depth}`,
);
});

test('should render a DeleteComponentButton in editMode', () => {
Expand Down
Expand Up @@ -323,14 +323,14 @@ class Row extends React.PureComponent {
{...(rowItems.length === 0
? {
component: rowComponent,
parentComponent,
parentComponent: rowComponent,
dropToChild: true,
}
: {
component: rowItems,
component: rowItems[0],
parentComponent: rowComponent,
})}
depth={depth + 1}
depth={depth}
index={0}
orientation="row"
onDrop={handleComponentDrop}
Expand Down Expand Up @@ -375,7 +375,7 @@ class Row extends React.PureComponent {
<Droppable
component={rowItems}
parentComponent={rowComponent}
depth={depth + 1}
depth={depth}
index={itemIndex + 1}
orientation="row"
onDrop={handleComponentDrop}
Expand Down
Expand Up @@ -32,8 +32,10 @@ jest.mock('src/dashboard/components/dnd/DragDroppable', () => ({
Draggable: ({ children }) => (
<div data-test="mock-draggable">{children({})}</div>
),
Droppable: ({ children }) => (
<div data-test="mock-droppable">{children({})}</div>
Droppable: ({ children, depth }) => (
<div data-test="mock-droppable" depth={depth}>
{children({})}
</div>
),
}));
jest.mock(
Expand Down Expand Up @@ -125,14 +127,20 @@ test('should render a WithPopoverMenu', () => {
});

test('should render a HoverMenu in editMode', () => {
const { container, getAllByTestId } = setup({
const { container, getAllByTestId, getByTestId } = setup({
component: rowWithoutChildren,
editMode: true,
});
expect(container.querySelector('.hover-menu')).toBeInTheDocument();

// Droppable area enabled in editMode
expect(getAllByTestId('mock-droppable').length).toBe(1);

// pass the same depth of its droppable area
expect(getByTestId('mock-droppable')).toHaveAttribute(
'depth',
`${props.depth}`,
);
});

test('should render a DeleteComponentButton in editMode', () => {
Expand Down