Skip to content

Commit

Permalink
feat(UnavailableContent): Rename props (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
wise-king-sullyman authored Jul 26, 2024
1 parent 2822f5c commit 265fcb6
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### component-groups-multi-content-card-remove-props [(#145)](https://github.com/patternfly/patternfly-react/pull/145)
### component-groups-multi-content-card-remove-props [(react-component-groups/#145)](https://github.com/patternfly/react-component-groups/pull/145)

The `leftBorderVariant` and `withHeaderBorder` props have been removed from MultiContentCard.

Expand Down
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%
```
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,
},
],
});
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"),
};
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"
/>
);
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"
/>
);

0 comments on commit 265fcb6

Please sign in to comment.