From fa4927f08fc985285a102dc52e20d88f2056faaf Mon Sep 17 00:00:00 2001 From: adamviktora Date: Mon, 8 May 2023 13:53:03 +0200 Subject: [PATCH] feat(MultipleFileUpload): add event param to onFileDrop callback --- ...eFileUpload-add-event-param-to-callback.js | 7 +++ ...eFileUpload-add-event-param-to-callback.js | 7 +++ packages/pf-codemods/README.md | 62 +++++++++++++------ test/test.tsx | 3 +- 4 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 packages/eslint-plugin-pf-codemods/lib/rules/v5/multipleFileUpload-add-event-param-to-callback.js create mode 100644 packages/eslint-plugin-pf-codemods/test/rules/v5/multipleFileUpload-add-event-param-to-callback.js diff --git a/packages/eslint-plugin-pf-codemods/lib/rules/v5/multipleFileUpload-add-event-param-to-callback.js b/packages/eslint-plugin-pf-codemods/lib/rules/v5/multipleFileUpload-add-event-param-to-callback.js new file mode 100644 index 000000000..f8744b177 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/lib/rules/v5/multipleFileUpload-add-event-param-to-callback.js @@ -0,0 +1,7 @@ +const { addCallbackParam } = require("../../helpers"); + +// https://github.com/patternfly/patternfly-react/pull/8995 +module.exports = { + meta: { fixable: "code" }, + create: addCallbackParam(["MultipleFileUpload"], { onFileDrop: "_event" }), +}; diff --git a/packages/eslint-plugin-pf-codemods/test/rules/v5/multipleFileUpload-add-event-param-to-callback.js b/packages/eslint-plugin-pf-codemods/test/rules/v5/multipleFileUpload-add-event-param-to-callback.js new file mode 100644 index 000000000..ddb4e8bf8 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/test/rules/v5/multipleFileUpload-add-event-param-to-callback.js @@ -0,0 +1,7 @@ +const { addCallbackParamTester } = require("../../testHelpers"); + +addCallbackParamTester( + "multipleFileUpload-add-event-param-to-callback", + "MultipleFileUpload", + "onFileDrop" +); diff --git a/packages/pf-codemods/README.md b/packages/pf-codemods/README.md index d993dfd7d..7dd81a355 100644 --- a/packages/pf-codemods/README.md +++ b/packages/pf-codemods/README.md @@ -1401,6 +1401,32 @@ Out: We've update the `aria-label` prop on MenuItemAction, making it required instead of optional. +### multipleFileUpload-add-event-param-to-callback [(#8995)](https://github.com/patternfly/patternfly-react/pull/8995) + +We've updated the `onFileDrop` prop for MultipleFileUpload so that the `event` parameter is the first parameter. Handlers may require an update. + +#### Examples + +In: + +```jsx + handler(id)} /> +const handler1 = (id) => {}; + +function handler2(id) {}; + +``` + +Out: + +```jsx + handler(id)} /> +const handler1 = (_event, id) => {}; + +function handler2(_event, id) {}; + +``` + ### nav-warn-flyouts-now-inline [(#8628)](https://github.com/patternfly/patternfly-react/pull/8628) The placement Nav flyouts in the DOM has been changed, if you have Nav elements with flyouts you may need to update some selectors or snapshots in your test suites. This rule will raise a warning, but will not make any changes. @@ -1551,50 +1577,50 @@ Out: ``` -### pageheader-update-logoComponent [(#8655)](https://github.com/patternfly/patternfly-react/pull/8655) +### page-rename-props [(#8942)](https://github.com/patternfly/patternfly-react/pull/8942) -We've updated `PageHeader`'s logo to only be an anchor if an `href` is specified, otherwise it will be a `span`. Explicitly declared `logoComponent` properties will remain unchanged, but if it is not specified a default will be added. +The following props have been updated for the specified Page sub-components: + +| Sub-component | Old prop name | New prop name | +|--|--|--| +| `PageSidebar` | `isNavOpen` | `isSidebarOpen` | +| `PageToggleButton` | `isNavOpen` | `isSidebarOpen` | +| `PageToggleButton` | `onNavToggle` | `onSidebarToggle` | #### Examples In: ```jsx - - + + {}} /> ``` Out: ```jsx - - + + {}} /> ``` -### page-rename-props [(#8942)](https://github.com/patternfly/patternfly-react/pull/8942) - -The following props have been updated for the specified Page sub-components: +### pageheader-update-logoComponent [(#8655)](https://github.com/patternfly/patternfly-react/pull/8655) -| Sub-component | Old prop name | New prop name | -|--|--|--| -| `PageSidebar` | `isNavOpen` | `isSidebarOpen` | -| `PageToggleButton` | `isNavOpen` | `isSidebarOpen` | -| `PageToggleButton` | `onNavToggle` | `onSidebarToggle` | +We've updated `PageHeader`'s logo to only be an anchor if an `href` is specified, otherwise it will be a `span`. Explicitly declared `logoComponent` properties will remain unchanged, but if it is not specified a default will be added. #### Examples In: ```jsx - - {}} /> + + ``` Out: ```jsx - - {}} /> + + ``` ### pageSidebar-update-api [(#8942)](https://github.com/patternfly/patternfly-react/pull/8942) diff --git a/test/test.tsx b/test/test.tsx index f6aa7d666..98269eb46 100644 --- a/test/test.tsx +++ b/test/test.tsx @@ -161,6 +161,7 @@ const backgroundImgSrcObj: BackgroundImageSrcMap = {}; + handler(foo)} />