-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat(Menu): updated markup for MenuItemAction #590
Merged
wise-king-sullyman
merged 2 commits into
patternfly:main
from
thatblindgeye:iss589_menuPenta
Feb 28, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...f-codemods/src/rules/v6/jumpLinksItemWarnMarkupChange/jumpLinksItem-warn-markup-change.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...rc/rules/v6/menuItemActionWarnUpdateMarkup/menuItemAction-warn-update-markup.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### menuItemAction-warn-update-markup [(#10089)](https://github.com/patternfly/patternfly-react/pull/10089) | ||
|
||
The markup for MenuItemAction has been updated. It now uses our Button component internally, has a wrapper around the action button, and no longer renders an icon wrapper inside the action button. |
22 changes: 22 additions & 0 deletions
22
...ods/src/rules/v6/menuItemActionWarnUpdateMarkup/menuItemAction-warn-update-markup.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./menuItemAction-warn-update-markup"; | ||
|
||
ruleTester.run("menuItemAction-warn-update-markup", rule, { | ||
valid: [ | ||
{ | ||
code: `import { MenuItemAction } from '@someOtherPackage';`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { MenuItemAction } from '@patternfly/react-core';`, | ||
output: `import { MenuItemAction } from '@patternfly/react-core';`, | ||
errors: [ | ||
{ | ||
message: `The markup for MenuItemAction has been updated. It now uses our Button component internally, has a wrapper around the action button, and no longer renders an icon wrapper inside the action button.`, | ||
type: "ImportDeclaration", | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
35 changes: 35 additions & 0 deletions
35
...codemods/src/rules/v6/menuItemActionWarnUpdateMarkup/menuItemAction-warn-update-markup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getFromPackage } from "../../helpers"; | ||
import { Rule } from "eslint"; | ||
import { ImportDeclaration } from "estree-jsx"; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10089 | ||
module.exports = { | ||
meta: {}, | ||
create: function (context: Rule.RuleContext) { | ||
const { imports } = getFromPackage(context, "@patternfly/react-core"); | ||
|
||
const menuItemActionImport = imports.find( | ||
(specifier) => specifier.imported.name === "MenuItemAction" | ||
); | ||
|
||
return !menuItemActionImport | ||
? {} | ||
: { | ||
ImportDeclaration(node: ImportDeclaration) { | ||
if ( | ||
node.specifiers.find( | ||
(specifier) => | ||
specifier.type === "ImportSpecifier" && | ||
specifier.imported.name === menuItemActionImport.imported.name | ||
) | ||
) { | ||
context.report({ | ||
node, | ||
message: | ||
"The markup for MenuItemAction has been updated. It now uses our Button component internally, has a wrapper around the action button, and no longer renders an icon wrapper inside the action button.", | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |
1 change: 1 addition & 0 deletions
1
...emods/src/rules/v6/menuItemActionWarnUpdateMarkup/menuItemActionWarnUpdateMarkupInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import { MenuItemAction } from "@patternfly/react-core"; |
1 change: 1 addition & 0 deletions
1
...mods/src/rules/v6/menuItemActionWarnUpdateMarkup/menuItemActionWarnUpdateMarkupOutput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import { MenuItemAction } from "@patternfly/react-core"; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about what if someone imports Patternfly and uses it this way:
I hope nobody does it, I checked the
getFromPackage
helper and we don't handle thisImportNamespaceSpecifier
there either. So if we don't know of any team who would do it, we don't have to worry about it, it would bring too many complications.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's an interesting point! I don't think we had any consumers bring this to our attention during the v5 release (@wise-king-sullyman do you recall if we did?), but worth keeping an eye out for with v6 alpha and beta releases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's in the same realm as the root problem behind #541, IMO it is probably worth us properly handling all of those import cases, but I don't think ironing those edge cases out is worth holding up the alpha release of the mods.
I think TS will be a big help with these kinds of problems, typing
getFromPackage
made it pretty obvious that we aren't logically setup for all of the potential import declarations.