Skip to content

Commit a1486d8

Browse files
authored
chore(Table): warn ActionsColumn uses Dropdown-next (#259)
* chore(Table): warn ActionsColumn updated * update readme and PR link * update fixer text
1 parent d95bb74 commit a1486d8

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// https://github.com/patternfly/patternfly-react/pull/8629
2+
module.exports = {
3+
create: function (context) {
4+
return {
5+
ImportDeclaration(node) {
6+
const TableImport = node.specifiers.find(
7+
(specifier) =>
8+
(specifier.imported.name === "Table" || specifier.imported.name === "TableComposable") &&
9+
node.source.value === "@patternfly/react-table"
10+
);
11+
12+
if (TableImport) {
13+
context.report({
14+
node,
15+
message: "The ActionsColumn now uses the Next version of Dropdown. The action toggle should now pass a MenuToggle rather than a DropdownToggle, and direction and position properties are now passed under the new popperProps property.",
16+
});
17+
}
18+
},
19+
};
20+
},
21+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const ruleTester = require('../../ruletester');
2+
const rule = require('../../../lib/rules/v5/table-warn-actionsColumn');
3+
4+
ruleTester.run("table-warn-actionsColumn", rule, {
5+
valid: [
6+
{
7+
code: `<Table />`,
8+
},
9+
{
10+
code: `<TableComposable />`,
11+
}
12+
],
13+
invalid: [
14+
{
15+
code: `import { Table } from '@patternfly/react-table';`,
16+
output: `import { Table } from '@patternfly/react-table';`,
17+
errors: [{
18+
message: `The ActionsColumn now uses the Next version of Dropdown. The action toggle should now pass a MenuToggle rather than a DropdownToggle, and direction and position properties are now passed under the new popperProps property.`,
19+
type: "ImportDeclaration",
20+
}]
21+
},
22+
{
23+
code: `import { TableComposable } from '@patternfly/react-table';`,
24+
output: `import { TableComposable } from '@patternfly/react-table';`,
25+
errors: [{
26+
message: `The ActionsColumn now uses the Next version of Dropdown. The action toggle should now pass a MenuToggle rather than a DropdownToggle, and direction and position properties are now passed under the new popperProps property.`,
27+
type: "ImportDeclaration",
28+
}]
29+
},
30+
]
31+
});

packages/pf-codemods/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,14 @@ Out:
664664
<Spinner />
665665
```
666666

667+
### table-warn-actionsColumn [(#8629)](https://github.com/patternfly/patternfly-react/pull/8629)
668+
669+
Table and TableComposable's `ActionsColumn` has been updated to use the newer 'next' version of Dropdown. The toggle passed to the actions column should now be a `MenuToggle` instead of a `DropdownToggle`. The `dropdownPosition`, `dropdownDirection` and `menuAppendTo` properties are removed and `Popper` properties can be passed in using `popperProps` instead (via `direction`, `position`, `appendTo`, etc.).
670+
667671
### table-warn-thExpandType [(#8634)](https://github.com/patternfly/patternfly-react/pull/8634)
668672

669673
`collapseAllAriaLabel` on `ThExpandType` has been updated to a `string` from `''`. Workarounds casting this property to an empty string are no longer required.
670674

671-
672675
### tableComposable-remove-hasSelectableRowCaption [(#8352)](https://github.com/patternfly/patternfly-react/pull/8352)
673676

674677
We've removed the deprecated `hasSelectableRowCaption` prop.

0 commit comments

Comments
 (0)