Skip to content

Commit

Permalink
feat(DragDrop): deprecate (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamviktora authored Apr 23, 2024
1 parent 262eb07 commit e0f6dd0
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
### dragDrop-deprecated [(#10181)](https://github.com/patternfly/patternfly-react/pull/10181)

DragDrop has been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using our new drag and drop implementation (DragDropSort component), that lives in '@patternfly/react-drag-drop' package.

#### Examples

In:

```jsx
%inputExample%
```

Out:

```jsx
%outputExample%
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const ruleTester = require('../../ruletester');
import * as rule from './dragDrop-deprecated';

ruleTester.run('dragDrop-deprecated', rule, {
valid: [
{
code: `<DragDrop onDrop={onDrop}>
<Droppable>
<Draggable key={1}>Item 1</Draggable>
<Draggable key={2}>Item 2</Draggable>
</Droppable>
</DragDrop>`,
},
],
invalid: [
{
code: `import { DragDrop, Droppable, Draggable } from '@patternfly/react-core';
export const DragDropDeprecatedInput = () => (
<DragDrop onDrop={onDrop}>
<Droppable>
<Draggable key={1}>Item 1</Draggable>
<Draggable key={2}>Item 2</Draggable>
</Droppable>
</DragDrop>
);
`,
output: `import {\n\tDragDrop,\n\tDroppable,\n\tDraggable\n} from '@patternfly/react-core/deprecated';
export const DragDropDeprecatedInput = () => (
<DragDrop onDrop={onDrop}>
<Droppable>
<Draggable key={1}>Item 1</Draggable>
<Draggable key={2}>Item 2</Draggable>
</Droppable>
</DragDrop>
);
`,
errors: [
{
message: `DragDrop, Droppable, and Draggable have been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using our new drag and drop implementation (DragDropSort component), that lives in '@patternfly/react-drag-drop' package.`,
type: 'ImportDeclaration',
},
],
},
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { moveSpecifiers } from '../../helpers';

const specifiersToMove = [
'DraggableItemPosition',
'DragDropContext',
'DragDrop',
'DraggableProps',
'Draggable',
'Droppable',
'DroppableContext',
];

const fromPackage = '@patternfly/react-core';
const toPackage = '@patternfly/react-core/deprecated';
const messageAfterImportNameChange =
"been deprecated. Running the fix flag will update your imports to our deprecated package, but we suggest using our new drag and drop implementation (DragDropSort component), that lives in '@patternfly/react-drag-drop' package.";

// https://github.com/patternfly/patternfly-react/pull/10181
module.exports = {
meta: { fixable: 'code' },
create: moveSpecifiers(
specifiersToMove,
fromPackage,
toPackage,
messageAfterImportNameChange
),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { DragDrop, Droppable, Draggable } from '@patternfly/react-core';

export const DragDropDeprecatedInput = () => (
<DragDrop onDrop={onDrop}>
<Droppable>
<Draggable key={1}>Item 1</Draggable>
<Draggable key={2}>Item 2</Draggable>
</Droppable>
</DragDrop>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
DragDrop,
Droppable,
Draggable,
} from '@patternfly/react-core/deprecated';

export const DragDropDeprecatedInput = () => (
<DragDrop onDrop={onDrop}>
<Droppable>
<Draggable key={1}>Item 1</Draggable>
<Draggable key={2}>Item 2</Draggable>
</Droppable>
</DragDrop>
);

0 comments on commit e0f6dd0

Please sign in to comment.