-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(UnavailableContent): Rename props (#717)
- Loading branch information
1 parent
2822f5c
commit 265fcb6
Showing
6 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...MultiContentCardRemoveProps/component-groups-multi-content-card-remove-props.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
23 changes: 23 additions & 0 deletions
23
...vailableContentRenameProps/component-groups-unavailable-content-rename-props.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,23 @@ | ||
### component-groups-unavailable-content-rename-props [(react-component-groups/#145)](https://github.com/patternfly/react-component-groups/pull/145) | ||
|
||
The UnavailableContent component of React Component Groups has had the following props renamed: | ||
|
||
| Old prop name | New prop name | | ||
| ----------------------------------- | ------------------ | | ||
| `unavailableTitleText` | `titleText` | | ||
| `unavailableBodyPreStatusLinkText` | `preLinkBodyText` | | ||
| `unavailableBodyPostStatusLinkText` | `postLinkBodyText` | | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
58 changes: 58 additions & 0 deletions
58
...psUnavailableContentRenameProps/component-groups-unavailable-content-rename-props.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,58 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./component-groups-unavailable-content-rename-props"; | ||
|
||
const renames = [ | ||
{ oldName: "unavailableTitleText", newName: "titleText" }, | ||
{ oldName: "unavailableBodyPreStatusLinkText", newName: "preLinkBodyText" }, | ||
{ oldName: "unavailableBodyPostStatusLinkText", newName: "postLinkBodyText" }, | ||
]; | ||
|
||
const errors = renames.map( | ||
({ oldName, newName }: { oldName: string; newName: string }) => ({ | ||
message: `The \`${oldName}\` prop for UnavailableContent has been renamed to \`${newName}\`.`, | ||
type: "JSXOpeningElement", | ||
}) | ||
); | ||
|
||
ruleTester.run("component-groups-unavailable-content-rename-props", rule, { | ||
valid: [ | ||
{ | ||
code: `<UnavailableContent unavailableTitleText />`, | ||
}, | ||
{ | ||
code: `import { UnavailableContent } from '@patternfly/react-component-groups'; <UnavailableContent someOtherProp />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { UnavailableContent } from '@patternfly/react-component-groups'; <UnavailableContent unavailableTitleText="foo" unavailableBodyPreStatusLinkText="bar" unavailableBodyPostStatusLinkText="bash" />`, | ||
output: `import { UnavailableContent } from '@patternfly/react-component-groups'; <UnavailableContent titleText="foo" preLinkBodyText="bar" postLinkBodyText="bash" />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import { UnavailableContent } from '@patternfly/react-component-groups'; const foo = "foo"; const bar = "bar"; const bash = "bash"; <UnavailableContent unavailableTitleText={foo} unavailableBodyPreStatusLinkText={bar} unavailableBodyPostStatusLinkText={bash} />`, | ||
output: `import { UnavailableContent } from '@patternfly/react-component-groups'; const foo = "foo"; const bar = "bar"; const bash = "bash"; <UnavailableContent titleText={foo} preLinkBodyText={bar} postLinkBodyText={bash} />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import { UnavailableContent } from '@patternfly/react-component-groups/dist/js/UnavailableContent'; <UnavailableContent unavailableTitleText="foo" unavailableBodyPreStatusLinkText="bar" unavailableBodyPostStatusLinkText="bash" />`, | ||
output: `import { UnavailableContent } from '@patternfly/react-component-groups/dist/js/UnavailableContent'; <UnavailableContent titleText="foo" preLinkBodyText="bar" postLinkBodyText="bash" />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import { UnavailableContent } from '@patternfly/react-component-groups/dist/esm/UnavailableContent'; <UnavailableContent unavailableTitleText="foo" unavailableBodyPreStatusLinkText="bar" unavailableBodyPostStatusLinkText="bash" />`, | ||
output: `import { UnavailableContent } from '@patternfly/react-component-groups/dist/esm/UnavailableContent'; <UnavailableContent titleText="foo" preLinkBodyText="bar" postLinkBodyText="bash" />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import { UnavailableContent } from '@patternfly/react-component-groups/dist/dynamic/UnavailableContent'; <UnavailableContent unavailableTitleText="foo" unavailableBodyPreStatusLinkText="bar" unavailableBodyPostStatusLinkText="bash" />`, | ||
output: `import { UnavailableContent } from '@patternfly/react-component-groups/dist/dynamic/UnavailableContent'; <UnavailableContent titleText="foo" preLinkBodyText="bar" postLinkBodyText="bash" />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import UC from '@patternfly/react-component-groups/dist/dynamic/UnavailableContent'; <UC unavailableTitleText="foo" unavailableBodyPreStatusLinkText="bar" unavailableBodyPostStatusLinkText="bash" />`, | ||
output: `import UC from '@patternfly/react-component-groups/dist/dynamic/UnavailableContent'; <UC titleText="foo" preLinkBodyText="bar" postLinkBodyText="bash" />`, | ||
errors, | ||
}, | ||
], | ||
}); |
35 changes: 35 additions & 0 deletions
35
...tGroupsUnavailableContentRenameProps/component-groups-unavailable-content-rename-props.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 { renameProps } from "../../helpers"; | ||
import { Renames } from "../../helpers/renameSinglePropOnNode"; | ||
|
||
// https://github.com/patternfly/react-component-groups/pull/145 | ||
|
||
const formatMessage = (oldPropName: string, newPropName: string) => | ||
`The \`${oldPropName}\` prop for UnavailableContent has been renamed to \`${newPropName}\`.`; | ||
|
||
const renames: Renames = { | ||
UnavailableContent: { | ||
unavailableTitleText: { | ||
newName: "titleText", | ||
message: formatMessage("unavailableTitleText", "titleText"), | ||
}, | ||
unavailableBodyPreStatusLinkText: { | ||
newName: "preLinkBodyText", | ||
message: formatMessage( | ||
"unavailableBodyPreStatusLinkText", | ||
"preLinkBodyText" | ||
), | ||
}, | ||
unavailableBodyPostStatusLinkText: { | ||
newName: "postLinkBodyText", | ||
message: formatMessage( | ||
"unavailableBodyPostStatusLinkText", | ||
"postLinkBodyText" | ||
), | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = { | ||
meta: { fixable: "code" }, | ||
create: renameProps(renames, "@patternfly/react-component-groups"), | ||
}; |
9 changes: 9 additions & 0 deletions
9
...GroupsUnavailableContentRenameProps/componentGroupsUnavailableContentRenamePropsInput.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,9 @@ | ||
import { UnavailableContent } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsUnavailableContentRenamePropsInput = () => ( | ||
<UnavailableContent | ||
unavailableTitleText="foo" | ||
unavailableBodyPreStatusLinkText="bar" | ||
unavailableBodyPostStatusLinkText="bash" | ||
/> | ||
); |
9 changes: 9 additions & 0 deletions
9
...roupsUnavailableContentRenameProps/componentGroupsUnavailableContentRenamePropsOutput.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,9 @@ | ||
import { UnavailableContent } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsUnavailableContentRenamePropsInput = () => ( | ||
<UnavailableContent | ||
titleText="foo" | ||
preLinkBodyText="bar" | ||
postLinkBodyText="bash" | ||
/> | ||
); |